dba7f31e131516b47d7051ae5c7dd48a08551a9f
[ldk-java] / src / main / jni / bindings.c.body
1 #include <jni.h>
2 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
3 #define int64_t jlong
4 #include "org_ldk_impl_bindings.h"
5 #include <lightning.h>
6 #include <string.h>
7 #include <stdatomic.h>
8 #include <stdlib.h>
9
10 #define LIKELY(v) __builtin_expect(!!(v), 1)
11 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
12
13 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
14 #define MALLOC(a, _) malloc(a)
15 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
16 #define CHECK_ACCESS(p)
17 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
18 #define DO_ASSERT(a) (void)(a)
19 #define CHECK(a)
20
21 static jmethodID ordinal_meth = NULL;
22 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class) {
23         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
24         CHECK(ordinal_meth != NULL);
25 }
26
27 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
28 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
29 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
30 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
31
32 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
33 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
34 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
35
36 typedef jlongArray int64_tArray;
37 typedef jbyteArray int8_tArray;
38 typedef jshortArray int16_tArray;
39
40 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
41         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
42         char* conv_buf = MALLOC(len + 1, "str conv buf");
43         memcpy(conv_buf, chars, len);
44         conv_buf[len] = 0;
45         jstring ret = (*env)->NewStringUTF(env, conv_buf);
46         FREE(conv_buf);
47         return ret;
48 }
49 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
50         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
51         char* newchars = MALLOC(str_len + 1, "String chars");
52         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
53         memcpy(newchars, jchars, str_len);
54         newchars[str_len] = 0;
55         (*env)->ReleaseStringUTFChars(env, str, jchars);
56         LDKStr res = {
57                 .chars = newchars,
58                 .len = str_len,
59                 .chars_is_owned = true
60         };
61         return res;
62 }
63
64 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
65         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
66 }
67 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
68         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
69 }
70 #include "version.c"
71 static jclass arr_of_B_clz = NULL;
72 static jclass String_clz = NULL;
73 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
74         arr_of_B_clz = (*env)->FindClass(env, "[B");
75         CHECK(arr_of_B_clz != NULL);
76         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
77         String_clz = (*env)->FindClass(env, "java/lang/String");
78         CHECK(String_clz != NULL);
79         String_clz = (*env)->NewGlobalRef(env, String_clz);
80 }
81 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
82
83 static inline void* untag_ptr(uint64_t ptr) {
84         if (ptr < 4096) return (void*)ptr;
85         if (sizeof(void*) == 4) {
86                 // For 32-bit systems, store pointers as 64-bit ints and use the 31st bit
87                 return (void*)(uintptr_t)ptr;
88         } else {
89                 // For 64-bit systems, assume the top byte is used for tagging, then
90                 // use bit 9 ^ bit 10.
91                 uint64_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
92                 uintptr_t p = (ptr & ~(1ULL << 55)) | (tenth_bit << 55);
93 #ifdef LDK_DEBUG_BUILD
94                 // On debug builds we also use the 11th bit as a debug flag
95                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
96                 CHECK(tenth_bit != eleventh_bit);
97                 p ^= 1ULL << 53;
98 #endif
99                 return (void*)p;
100         }
101 }
102 static inline bool ptr_is_owned(uint64_t ptr) {
103         if(ptr < 4096) return true;
104         if (sizeof(void*) == 4) {
105                 return ptr & (1ULL << 32);
106         } else {
107                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
108                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
109 #ifdef LDK_DEBUG_BUILD
110                 // On debug builds we also use the 11th bit as a debug flag
111                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
112                 CHECK(tenth_bit != eleventh_bit);
113 #endif
114                 return (ninth_bit ^ tenth_bit) ? true : false;
115         }
116 }
117 static inline uint64_t tag_ptr(const void* ptr, bool is_owned) {
118         if ((uintptr_t)ptr < 4096) return (uint64_t)ptr;
119         if (sizeof(void*) == 4) {
120                 return (((uint64_t)ptr) | ((is_owned ? 1ULL : 0) << 32));
121         } else {
122                 CHECK(sizeof(uintptr_t) == 8);
123                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
124                 uintptr_t t = (((uintptr_t)ptr) | (((is_owned ? 1ULL : 0ULL) ^ tenth_bit) << 55));
125 #ifdef LDK_DEBUG_BUILD
126                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
127                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
128                 CHECK(ninth_bit == tenth_bit);
129                 CHECK(ninth_bit == eleventh_bit);
130                 t ^= 1ULL << 53;
131 #endif
132                 CHECK(ptr_is_owned(t) == is_owned);
133                 CHECK(untag_ptr(t) == ptr);
134                 return t;
135         }
136 }
137
138 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
139         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
140         if (UNLIKELY((*env)->ExceptionCheck(env))) {
141                 (*env)->ExceptionDescribe(env);
142                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
143         }
144         switch (ord) {
145                 case 0: return LDKCOption_NoneZ_Some;
146                 case 1: return LDKCOption_NoneZ_None;
147         }
148         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
149         abort(); // Unreachable, but will let the compiler know we don't return here
150 }
151 static jclass COption_NoneZ_class = NULL;
152 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
153 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
154 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
155         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
156         CHECK(COption_NoneZ_class != NULL);
157         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
158         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
159         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
160         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
161 }
162 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
163         switch (val) {
164                 case LDKCOption_NoneZ_Some:
165                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
166                 case LDKCOption_NoneZ_None:
167                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
168                 default: abort();
169         }
170 }
171
172 static inline LDKChannelMonitorUpdateStatus LDKChannelMonitorUpdateStatus_from_java(JNIEnv *env, jclass clz) {
173         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
174         if (UNLIKELY((*env)->ExceptionCheck(env))) {
175                 (*env)->ExceptionDescribe(env);
176                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateStatus.ordinal() from rust threw an exception.");
177         }
178         switch (ord) {
179                 case 0: return LDKChannelMonitorUpdateStatus_Completed;
180                 case 1: return LDKChannelMonitorUpdateStatus_InProgress;
181                 case 2: return LDKChannelMonitorUpdateStatus_PermanentFailure;
182         }
183         (*env)->FatalError(env, "A call to ChannelMonitorUpdateStatus.ordinal() from rust returned an invalid value.");
184         abort(); // Unreachable, but will let the compiler know we don't return here
185 }
186 static jclass ChannelMonitorUpdateStatus_class = NULL;
187 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed = NULL;
188 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress = NULL;
189 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure = NULL;
190 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateStatus_init (JNIEnv *env, jclass clz) {
191         ChannelMonitorUpdateStatus_class = (*env)->NewGlobalRef(env, clz);
192         CHECK(ChannelMonitorUpdateStatus_class != NULL);
193         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_Completed", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
194         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed != NULL);
195         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_InProgress", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
196         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress != NULL);
197         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
198         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure != NULL);
199 }
200 static inline jclass LDKChannelMonitorUpdateStatus_to_java(JNIEnv *env, LDKChannelMonitorUpdateStatus val) {
201         switch (val) {
202                 case LDKChannelMonitorUpdateStatus_Completed:
203                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed);
204                 case LDKChannelMonitorUpdateStatus_InProgress:
205                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress);
206                 case LDKChannelMonitorUpdateStatus_PermanentFailure:
207                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure);
208                 default: abort();
209         }
210 }
211
212 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
213         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
214         if (UNLIKELY((*env)->ExceptionCheck(env))) {
215                 (*env)->ExceptionDescribe(env);
216                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
217         }
218         switch (ord) {
219                 case 0: return LDKConfirmationTarget_Background;
220                 case 1: return LDKConfirmationTarget_Normal;
221                 case 2: return LDKConfirmationTarget_HighPriority;
222         }
223         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
224         abort(); // Unreachable, but will let the compiler know we don't return here
225 }
226 static jclass ConfirmationTarget_class = NULL;
227 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
228 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
229 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
230 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
231         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
232         CHECK(ConfirmationTarget_class != NULL);
233         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
234         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
235         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
236         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
237         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
238         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
239 }
240 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
241         switch (val) {
242                 case LDKConfirmationTarget_Background:
243                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
244                 case LDKConfirmationTarget_Normal:
245                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
246                 case LDKConfirmationTarget_HighPriority:
247                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
248                 default: abort();
249         }
250 }
251
252 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
253         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
254         if (UNLIKELY((*env)->ExceptionCheck(env))) {
255                 (*env)->ExceptionDescribe(env);
256                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
257         }
258         switch (ord) {
259                 case 0: return LDKCreationError_DescriptionTooLong;
260                 case 1: return LDKCreationError_RouteTooLong;
261                 case 2: return LDKCreationError_TimestampOutOfBounds;
262                 case 3: return LDKCreationError_InvalidAmount;
263                 case 4: return LDKCreationError_MissingRouteHints;
264                 case 5: return LDKCreationError_MinFinalCltvExpiryDeltaTooShort;
265         }
266         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
267         abort(); // Unreachable, but will let the compiler know we don't return here
268 }
269 static jclass CreationError_class = NULL;
270 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
271 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
272 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
273 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
274 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
275 static jfieldID CreationError_LDKCreationError_MinFinalCltvExpiryDeltaTooShort = NULL;
276 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
277         CreationError_class = (*env)->NewGlobalRef(env, clz);
278         CHECK(CreationError_class != NULL);
279         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
280         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
281         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
282         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
283         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
284         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
285         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
286         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
287         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
288         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
289         CreationError_LDKCreationError_MinFinalCltvExpiryDeltaTooShort = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MinFinalCltvExpiryDeltaTooShort", "Lorg/ldk/enums/CreationError;");
290         CHECK(CreationError_LDKCreationError_MinFinalCltvExpiryDeltaTooShort != NULL);
291 }
292 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
293         switch (val) {
294                 case LDKCreationError_DescriptionTooLong:
295                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
296                 case LDKCreationError_RouteTooLong:
297                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
298                 case LDKCreationError_TimestampOutOfBounds:
299                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
300                 case LDKCreationError_InvalidAmount:
301                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
302                 case LDKCreationError_MissingRouteHints:
303                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
304                 case LDKCreationError_MinFinalCltvExpiryDeltaTooShort:
305                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MinFinalCltvExpiryDeltaTooShort);
306                 default: abort();
307         }
308 }
309
310 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
311         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
312         if (UNLIKELY((*env)->ExceptionCheck(env))) {
313                 (*env)->ExceptionDescribe(env);
314                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
315         }
316         switch (ord) {
317                 case 0: return LDKCurrency_Bitcoin;
318                 case 1: return LDKCurrency_BitcoinTestnet;
319                 case 2: return LDKCurrency_Regtest;
320                 case 3: return LDKCurrency_Simnet;
321                 case 4: return LDKCurrency_Signet;
322         }
323         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
324         abort(); // Unreachable, but will let the compiler know we don't return here
325 }
326 static jclass Currency_class = NULL;
327 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
328 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
329 static jfieldID Currency_LDKCurrency_Regtest = NULL;
330 static jfieldID Currency_LDKCurrency_Simnet = NULL;
331 static jfieldID Currency_LDKCurrency_Signet = NULL;
332 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
333         Currency_class = (*env)->NewGlobalRef(env, clz);
334         CHECK(Currency_class != NULL);
335         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
336         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
337         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
338         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
339         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
340         CHECK(Currency_LDKCurrency_Regtest != NULL);
341         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
342         CHECK(Currency_LDKCurrency_Simnet != NULL);
343         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
344         CHECK(Currency_LDKCurrency_Signet != NULL);
345 }
346 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
347         switch (val) {
348                 case LDKCurrency_Bitcoin:
349                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
350                 case LDKCurrency_BitcoinTestnet:
351                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
352                 case LDKCurrency_Regtest:
353                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
354                 case LDKCurrency_Simnet:
355                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
356                 case LDKCurrency_Signet:
357                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
358                 default: abort();
359         }
360 }
361
362 static inline LDKFailureCode LDKFailureCode_from_java(JNIEnv *env, jclass clz) {
363         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
364         if (UNLIKELY((*env)->ExceptionCheck(env))) {
365                 (*env)->ExceptionDescribe(env);
366                 (*env)->FatalError(env, "A call to FailureCode.ordinal() from rust threw an exception.");
367         }
368         switch (ord) {
369                 case 0: return LDKFailureCode_TemporaryNodeFailure;
370                 case 1: return LDKFailureCode_RequiredNodeFeatureMissing;
371                 case 2: return LDKFailureCode_IncorrectOrUnknownPaymentDetails;
372         }
373         (*env)->FatalError(env, "A call to FailureCode.ordinal() from rust returned an invalid value.");
374         abort(); // Unreachable, but will let the compiler know we don't return here
375 }
376 static jclass FailureCode_class = NULL;
377 static jfieldID FailureCode_LDKFailureCode_TemporaryNodeFailure = NULL;
378 static jfieldID FailureCode_LDKFailureCode_RequiredNodeFeatureMissing = NULL;
379 static jfieldID FailureCode_LDKFailureCode_IncorrectOrUnknownPaymentDetails = NULL;
380 JNIEXPORT void JNICALL Java_org_ldk_enums_FailureCode_init (JNIEnv *env, jclass clz) {
381         FailureCode_class = (*env)->NewGlobalRef(env, clz);
382         CHECK(FailureCode_class != NULL);
383         FailureCode_LDKFailureCode_TemporaryNodeFailure = (*env)->GetStaticFieldID(env, FailureCode_class, "LDKFailureCode_TemporaryNodeFailure", "Lorg/ldk/enums/FailureCode;");
384         CHECK(FailureCode_LDKFailureCode_TemporaryNodeFailure != NULL);
385         FailureCode_LDKFailureCode_RequiredNodeFeatureMissing = (*env)->GetStaticFieldID(env, FailureCode_class, "LDKFailureCode_RequiredNodeFeatureMissing", "Lorg/ldk/enums/FailureCode;");
386         CHECK(FailureCode_LDKFailureCode_RequiredNodeFeatureMissing != NULL);
387         FailureCode_LDKFailureCode_IncorrectOrUnknownPaymentDetails = (*env)->GetStaticFieldID(env, FailureCode_class, "LDKFailureCode_IncorrectOrUnknownPaymentDetails", "Lorg/ldk/enums/FailureCode;");
388         CHECK(FailureCode_LDKFailureCode_IncorrectOrUnknownPaymentDetails != NULL);
389 }
390 static inline jclass LDKFailureCode_to_java(JNIEnv *env, LDKFailureCode val) {
391         switch (val) {
392                 case LDKFailureCode_TemporaryNodeFailure:
393                         return (*env)->GetStaticObjectField(env, FailureCode_class, FailureCode_LDKFailureCode_TemporaryNodeFailure);
394                 case LDKFailureCode_RequiredNodeFeatureMissing:
395                         return (*env)->GetStaticObjectField(env, FailureCode_class, FailureCode_LDKFailureCode_RequiredNodeFeatureMissing);
396                 case LDKFailureCode_IncorrectOrUnknownPaymentDetails:
397                         return (*env)->GetStaticObjectField(env, FailureCode_class, FailureCode_LDKFailureCode_IncorrectOrUnknownPaymentDetails);
398                 default: abort();
399         }
400 }
401
402 static inline LDKHTLCClaim LDKHTLCClaim_from_java(JNIEnv *env, jclass clz) {
403         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
404         if (UNLIKELY((*env)->ExceptionCheck(env))) {
405                 (*env)->ExceptionDescribe(env);
406                 (*env)->FatalError(env, "A call to HTLCClaim.ordinal() from rust threw an exception.");
407         }
408         switch (ord) {
409                 case 0: return LDKHTLCClaim_OfferedTimeout;
410                 case 1: return LDKHTLCClaim_OfferedPreimage;
411                 case 2: return LDKHTLCClaim_AcceptedTimeout;
412                 case 3: return LDKHTLCClaim_AcceptedPreimage;
413                 case 4: return LDKHTLCClaim_Revocation;
414         }
415         (*env)->FatalError(env, "A call to HTLCClaim.ordinal() from rust returned an invalid value.");
416         abort(); // Unreachable, but will let the compiler know we don't return here
417 }
418 static jclass HTLCClaim_class = NULL;
419 static jfieldID HTLCClaim_LDKHTLCClaim_OfferedTimeout = NULL;
420 static jfieldID HTLCClaim_LDKHTLCClaim_OfferedPreimage = NULL;
421 static jfieldID HTLCClaim_LDKHTLCClaim_AcceptedTimeout = NULL;
422 static jfieldID HTLCClaim_LDKHTLCClaim_AcceptedPreimage = NULL;
423 static jfieldID HTLCClaim_LDKHTLCClaim_Revocation = NULL;
424 JNIEXPORT void JNICALL Java_org_ldk_enums_HTLCClaim_init (JNIEnv *env, jclass clz) {
425         HTLCClaim_class = (*env)->NewGlobalRef(env, clz);
426         CHECK(HTLCClaim_class != NULL);
427         HTLCClaim_LDKHTLCClaim_OfferedTimeout = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_OfferedTimeout", "Lorg/ldk/enums/HTLCClaim;");
428         CHECK(HTLCClaim_LDKHTLCClaim_OfferedTimeout != NULL);
429         HTLCClaim_LDKHTLCClaim_OfferedPreimage = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_OfferedPreimage", "Lorg/ldk/enums/HTLCClaim;");
430         CHECK(HTLCClaim_LDKHTLCClaim_OfferedPreimage != NULL);
431         HTLCClaim_LDKHTLCClaim_AcceptedTimeout = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_AcceptedTimeout", "Lorg/ldk/enums/HTLCClaim;");
432         CHECK(HTLCClaim_LDKHTLCClaim_AcceptedTimeout != NULL);
433         HTLCClaim_LDKHTLCClaim_AcceptedPreimage = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_AcceptedPreimage", "Lorg/ldk/enums/HTLCClaim;");
434         CHECK(HTLCClaim_LDKHTLCClaim_AcceptedPreimage != NULL);
435         HTLCClaim_LDKHTLCClaim_Revocation = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_Revocation", "Lorg/ldk/enums/HTLCClaim;");
436         CHECK(HTLCClaim_LDKHTLCClaim_Revocation != NULL);
437 }
438 static inline jclass LDKHTLCClaim_to_java(JNIEnv *env, LDKHTLCClaim val) {
439         switch (val) {
440                 case LDKHTLCClaim_OfferedTimeout:
441                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_OfferedTimeout);
442                 case LDKHTLCClaim_OfferedPreimage:
443                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_OfferedPreimage);
444                 case LDKHTLCClaim_AcceptedTimeout:
445                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_AcceptedTimeout);
446                 case LDKHTLCClaim_AcceptedPreimage:
447                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_AcceptedPreimage);
448                 case LDKHTLCClaim_Revocation:
449                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_Revocation);
450                 default: abort();
451         }
452 }
453
454 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
455         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
456         if (UNLIKELY((*env)->ExceptionCheck(env))) {
457                 (*env)->ExceptionDescribe(env);
458                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
459         }
460         switch (ord) {
461                 case 0: return LDKIOError_NotFound;
462                 case 1: return LDKIOError_PermissionDenied;
463                 case 2: return LDKIOError_ConnectionRefused;
464                 case 3: return LDKIOError_ConnectionReset;
465                 case 4: return LDKIOError_ConnectionAborted;
466                 case 5: return LDKIOError_NotConnected;
467                 case 6: return LDKIOError_AddrInUse;
468                 case 7: return LDKIOError_AddrNotAvailable;
469                 case 8: return LDKIOError_BrokenPipe;
470                 case 9: return LDKIOError_AlreadyExists;
471                 case 10: return LDKIOError_WouldBlock;
472                 case 11: return LDKIOError_InvalidInput;
473                 case 12: return LDKIOError_InvalidData;
474                 case 13: return LDKIOError_TimedOut;
475                 case 14: return LDKIOError_WriteZero;
476                 case 15: return LDKIOError_Interrupted;
477                 case 16: return LDKIOError_Other;
478                 case 17: return LDKIOError_UnexpectedEof;
479         }
480         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
481         abort(); // Unreachable, but will let the compiler know we don't return here
482 }
483 static jclass IOError_class = NULL;
484 static jfieldID IOError_LDKIOError_NotFound = NULL;
485 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
486 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
487 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
488 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
489 static jfieldID IOError_LDKIOError_NotConnected = NULL;
490 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
491 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
492 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
493 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
494 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
495 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
496 static jfieldID IOError_LDKIOError_InvalidData = NULL;
497 static jfieldID IOError_LDKIOError_TimedOut = NULL;
498 static jfieldID IOError_LDKIOError_WriteZero = NULL;
499 static jfieldID IOError_LDKIOError_Interrupted = NULL;
500 static jfieldID IOError_LDKIOError_Other = NULL;
501 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
502 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
503         IOError_class = (*env)->NewGlobalRef(env, clz);
504         CHECK(IOError_class != NULL);
505         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
506         CHECK(IOError_LDKIOError_NotFound != NULL);
507         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
508         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
509         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
510         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
511         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
512         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
513         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
514         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
515         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
516         CHECK(IOError_LDKIOError_NotConnected != NULL);
517         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
518         CHECK(IOError_LDKIOError_AddrInUse != NULL);
519         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
520         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
521         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
522         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
523         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
524         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
525         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
526         CHECK(IOError_LDKIOError_WouldBlock != NULL);
527         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
528         CHECK(IOError_LDKIOError_InvalidInput != NULL);
529         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
530         CHECK(IOError_LDKIOError_InvalidData != NULL);
531         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
532         CHECK(IOError_LDKIOError_TimedOut != NULL);
533         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
534         CHECK(IOError_LDKIOError_WriteZero != NULL);
535         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
536         CHECK(IOError_LDKIOError_Interrupted != NULL);
537         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
538         CHECK(IOError_LDKIOError_Other != NULL);
539         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
540         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
541 }
542 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
543         switch (val) {
544                 case LDKIOError_NotFound:
545                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
546                 case LDKIOError_PermissionDenied:
547                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
548                 case LDKIOError_ConnectionRefused:
549                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
550                 case LDKIOError_ConnectionReset:
551                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
552                 case LDKIOError_ConnectionAborted:
553                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
554                 case LDKIOError_NotConnected:
555                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
556                 case LDKIOError_AddrInUse:
557                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
558                 case LDKIOError_AddrNotAvailable:
559                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
560                 case LDKIOError_BrokenPipe:
561                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
562                 case LDKIOError_AlreadyExists:
563                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
564                 case LDKIOError_WouldBlock:
565                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
566                 case LDKIOError_InvalidInput:
567                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
568                 case LDKIOError_InvalidData:
569                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
570                 case LDKIOError_TimedOut:
571                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
572                 case LDKIOError_WriteZero:
573                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
574                 case LDKIOError_Interrupted:
575                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
576                 case LDKIOError_Other:
577                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
578                 case LDKIOError_UnexpectedEof:
579                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
580                 default: abort();
581         }
582 }
583
584 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
585         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
586         if (UNLIKELY((*env)->ExceptionCheck(env))) {
587                 (*env)->ExceptionDescribe(env);
588                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
589         }
590         switch (ord) {
591                 case 0: return LDKLevel_Gossip;
592                 case 1: return LDKLevel_Trace;
593                 case 2: return LDKLevel_Debug;
594                 case 3: return LDKLevel_Info;
595                 case 4: return LDKLevel_Warn;
596                 case 5: return LDKLevel_Error;
597         }
598         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
599         abort(); // Unreachable, but will let the compiler know we don't return here
600 }
601 static jclass Level_class = NULL;
602 static jfieldID Level_LDKLevel_Gossip = NULL;
603 static jfieldID Level_LDKLevel_Trace = NULL;
604 static jfieldID Level_LDKLevel_Debug = NULL;
605 static jfieldID Level_LDKLevel_Info = NULL;
606 static jfieldID Level_LDKLevel_Warn = NULL;
607 static jfieldID Level_LDKLevel_Error = NULL;
608 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
609         Level_class = (*env)->NewGlobalRef(env, clz);
610         CHECK(Level_class != NULL);
611         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
612         CHECK(Level_LDKLevel_Gossip != NULL);
613         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
614         CHECK(Level_LDKLevel_Trace != NULL);
615         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
616         CHECK(Level_LDKLevel_Debug != NULL);
617         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
618         CHECK(Level_LDKLevel_Info != NULL);
619         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
620         CHECK(Level_LDKLevel_Warn != NULL);
621         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
622         CHECK(Level_LDKLevel_Error != NULL);
623 }
624 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
625         switch (val) {
626                 case LDKLevel_Gossip:
627                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
628                 case LDKLevel_Trace:
629                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
630                 case LDKLevel_Debug:
631                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
632                 case LDKLevel_Info:
633                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
634                 case LDKLevel_Warn:
635                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
636                 case LDKLevel_Error:
637                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
638                 default: abort();
639         }
640 }
641
642 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
643         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
644         if (UNLIKELY((*env)->ExceptionCheck(env))) {
645                 (*env)->ExceptionDescribe(env);
646                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
647         }
648         switch (ord) {
649                 case 0: return LDKNetwork_Bitcoin;
650                 case 1: return LDKNetwork_Testnet;
651                 case 2: return LDKNetwork_Regtest;
652                 case 3: return LDKNetwork_Signet;
653         }
654         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
655         abort(); // Unreachable, but will let the compiler know we don't return here
656 }
657 static jclass Network_class = NULL;
658 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
659 static jfieldID Network_LDKNetwork_Testnet = NULL;
660 static jfieldID Network_LDKNetwork_Regtest = NULL;
661 static jfieldID Network_LDKNetwork_Signet = NULL;
662 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
663         Network_class = (*env)->NewGlobalRef(env, clz);
664         CHECK(Network_class != NULL);
665         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
666         CHECK(Network_LDKNetwork_Bitcoin != NULL);
667         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
668         CHECK(Network_LDKNetwork_Testnet != NULL);
669         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
670         CHECK(Network_LDKNetwork_Regtest != NULL);
671         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
672         CHECK(Network_LDKNetwork_Signet != NULL);
673 }
674 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
675         switch (val) {
676                 case LDKNetwork_Bitcoin:
677                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
678                 case LDKNetwork_Testnet:
679                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
680                 case LDKNetwork_Regtest:
681                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
682                 case LDKNetwork_Signet:
683                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
684                 default: abort();
685         }
686 }
687
688 static inline LDKPaymentFailureReason LDKPaymentFailureReason_from_java(JNIEnv *env, jclass clz) {
689         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
690         if (UNLIKELY((*env)->ExceptionCheck(env))) {
691                 (*env)->ExceptionDescribe(env);
692                 (*env)->FatalError(env, "A call to PaymentFailureReason.ordinal() from rust threw an exception.");
693         }
694         switch (ord) {
695                 case 0: return LDKPaymentFailureReason_RecipientRejected;
696                 case 1: return LDKPaymentFailureReason_UserAbandoned;
697                 case 2: return LDKPaymentFailureReason_RetriesExhausted;
698                 case 3: return LDKPaymentFailureReason_PaymentExpired;
699                 case 4: return LDKPaymentFailureReason_RouteNotFound;
700                 case 5: return LDKPaymentFailureReason_UnexpectedError;
701         }
702         (*env)->FatalError(env, "A call to PaymentFailureReason.ordinal() from rust returned an invalid value.");
703         abort(); // Unreachable, but will let the compiler know we don't return here
704 }
705 static jclass PaymentFailureReason_class = NULL;
706 static jfieldID PaymentFailureReason_LDKPaymentFailureReason_RecipientRejected = NULL;
707 static jfieldID PaymentFailureReason_LDKPaymentFailureReason_UserAbandoned = NULL;
708 static jfieldID PaymentFailureReason_LDKPaymentFailureReason_RetriesExhausted = NULL;
709 static jfieldID PaymentFailureReason_LDKPaymentFailureReason_PaymentExpired = NULL;
710 static jfieldID PaymentFailureReason_LDKPaymentFailureReason_RouteNotFound = NULL;
711 static jfieldID PaymentFailureReason_LDKPaymentFailureReason_UnexpectedError = NULL;
712 JNIEXPORT void JNICALL Java_org_ldk_enums_PaymentFailureReason_init (JNIEnv *env, jclass clz) {
713         PaymentFailureReason_class = (*env)->NewGlobalRef(env, clz);
714         CHECK(PaymentFailureReason_class != NULL);
715         PaymentFailureReason_LDKPaymentFailureReason_RecipientRejected = (*env)->GetStaticFieldID(env, PaymentFailureReason_class, "LDKPaymentFailureReason_RecipientRejected", "Lorg/ldk/enums/PaymentFailureReason;");
716         CHECK(PaymentFailureReason_LDKPaymentFailureReason_RecipientRejected != NULL);
717         PaymentFailureReason_LDKPaymentFailureReason_UserAbandoned = (*env)->GetStaticFieldID(env, PaymentFailureReason_class, "LDKPaymentFailureReason_UserAbandoned", "Lorg/ldk/enums/PaymentFailureReason;");
718         CHECK(PaymentFailureReason_LDKPaymentFailureReason_UserAbandoned != NULL);
719         PaymentFailureReason_LDKPaymentFailureReason_RetriesExhausted = (*env)->GetStaticFieldID(env, PaymentFailureReason_class, "LDKPaymentFailureReason_RetriesExhausted", "Lorg/ldk/enums/PaymentFailureReason;");
720         CHECK(PaymentFailureReason_LDKPaymentFailureReason_RetriesExhausted != NULL);
721         PaymentFailureReason_LDKPaymentFailureReason_PaymentExpired = (*env)->GetStaticFieldID(env, PaymentFailureReason_class, "LDKPaymentFailureReason_PaymentExpired", "Lorg/ldk/enums/PaymentFailureReason;");
722         CHECK(PaymentFailureReason_LDKPaymentFailureReason_PaymentExpired != NULL);
723         PaymentFailureReason_LDKPaymentFailureReason_RouteNotFound = (*env)->GetStaticFieldID(env, PaymentFailureReason_class, "LDKPaymentFailureReason_RouteNotFound", "Lorg/ldk/enums/PaymentFailureReason;");
724         CHECK(PaymentFailureReason_LDKPaymentFailureReason_RouteNotFound != NULL);
725         PaymentFailureReason_LDKPaymentFailureReason_UnexpectedError = (*env)->GetStaticFieldID(env, PaymentFailureReason_class, "LDKPaymentFailureReason_UnexpectedError", "Lorg/ldk/enums/PaymentFailureReason;");
726         CHECK(PaymentFailureReason_LDKPaymentFailureReason_UnexpectedError != NULL);
727 }
728 static inline jclass LDKPaymentFailureReason_to_java(JNIEnv *env, LDKPaymentFailureReason val) {
729         switch (val) {
730                 case LDKPaymentFailureReason_RecipientRejected:
731                         return (*env)->GetStaticObjectField(env, PaymentFailureReason_class, PaymentFailureReason_LDKPaymentFailureReason_RecipientRejected);
732                 case LDKPaymentFailureReason_UserAbandoned:
733                         return (*env)->GetStaticObjectField(env, PaymentFailureReason_class, PaymentFailureReason_LDKPaymentFailureReason_UserAbandoned);
734                 case LDKPaymentFailureReason_RetriesExhausted:
735                         return (*env)->GetStaticObjectField(env, PaymentFailureReason_class, PaymentFailureReason_LDKPaymentFailureReason_RetriesExhausted);
736                 case LDKPaymentFailureReason_PaymentExpired:
737                         return (*env)->GetStaticObjectField(env, PaymentFailureReason_class, PaymentFailureReason_LDKPaymentFailureReason_PaymentExpired);
738                 case LDKPaymentFailureReason_RouteNotFound:
739                         return (*env)->GetStaticObjectField(env, PaymentFailureReason_class, PaymentFailureReason_LDKPaymentFailureReason_RouteNotFound);
740                 case LDKPaymentFailureReason_UnexpectedError:
741                         return (*env)->GetStaticObjectField(env, PaymentFailureReason_class, PaymentFailureReason_LDKPaymentFailureReason_UnexpectedError);
742                 default: abort();
743         }
744 }
745
746 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
747         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
748         if (UNLIKELY((*env)->ExceptionCheck(env))) {
749                 (*env)->ExceptionDescribe(env);
750                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
751         }
752         switch (ord) {
753                 case 0: return LDKRecipient_Node;
754                 case 1: return LDKRecipient_PhantomNode;
755         }
756         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
757         abort(); // Unreachable, but will let the compiler know we don't return here
758 }
759 static jclass Recipient_class = NULL;
760 static jfieldID Recipient_LDKRecipient_Node = NULL;
761 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
762 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
763         Recipient_class = (*env)->NewGlobalRef(env, clz);
764         CHECK(Recipient_class != NULL);
765         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
766         CHECK(Recipient_LDKRecipient_Node != NULL);
767         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
768         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
769 }
770 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
771         switch (val) {
772                 case LDKRecipient_Node:
773                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
774                 case LDKRecipient_PhantomNode:
775                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
776                 default: abort();
777         }
778 }
779
780 static inline LDKRetryableSendFailure LDKRetryableSendFailure_from_java(JNIEnv *env, jclass clz) {
781         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
782         if (UNLIKELY((*env)->ExceptionCheck(env))) {
783                 (*env)->ExceptionDescribe(env);
784                 (*env)->FatalError(env, "A call to RetryableSendFailure.ordinal() from rust threw an exception.");
785         }
786         switch (ord) {
787                 case 0: return LDKRetryableSendFailure_PaymentExpired;
788                 case 1: return LDKRetryableSendFailure_RouteNotFound;
789                 case 2: return LDKRetryableSendFailure_DuplicatePayment;
790         }
791         (*env)->FatalError(env, "A call to RetryableSendFailure.ordinal() from rust returned an invalid value.");
792         abort(); // Unreachable, but will let the compiler know we don't return here
793 }
794 static jclass RetryableSendFailure_class = NULL;
795 static jfieldID RetryableSendFailure_LDKRetryableSendFailure_PaymentExpired = NULL;
796 static jfieldID RetryableSendFailure_LDKRetryableSendFailure_RouteNotFound = NULL;
797 static jfieldID RetryableSendFailure_LDKRetryableSendFailure_DuplicatePayment = NULL;
798 JNIEXPORT void JNICALL Java_org_ldk_enums_RetryableSendFailure_init (JNIEnv *env, jclass clz) {
799         RetryableSendFailure_class = (*env)->NewGlobalRef(env, clz);
800         CHECK(RetryableSendFailure_class != NULL);
801         RetryableSendFailure_LDKRetryableSendFailure_PaymentExpired = (*env)->GetStaticFieldID(env, RetryableSendFailure_class, "LDKRetryableSendFailure_PaymentExpired", "Lorg/ldk/enums/RetryableSendFailure;");
802         CHECK(RetryableSendFailure_LDKRetryableSendFailure_PaymentExpired != NULL);
803         RetryableSendFailure_LDKRetryableSendFailure_RouteNotFound = (*env)->GetStaticFieldID(env, RetryableSendFailure_class, "LDKRetryableSendFailure_RouteNotFound", "Lorg/ldk/enums/RetryableSendFailure;");
804         CHECK(RetryableSendFailure_LDKRetryableSendFailure_RouteNotFound != NULL);
805         RetryableSendFailure_LDKRetryableSendFailure_DuplicatePayment = (*env)->GetStaticFieldID(env, RetryableSendFailure_class, "LDKRetryableSendFailure_DuplicatePayment", "Lorg/ldk/enums/RetryableSendFailure;");
806         CHECK(RetryableSendFailure_LDKRetryableSendFailure_DuplicatePayment != NULL);
807 }
808 static inline jclass LDKRetryableSendFailure_to_java(JNIEnv *env, LDKRetryableSendFailure val) {
809         switch (val) {
810                 case LDKRetryableSendFailure_PaymentExpired:
811                         return (*env)->GetStaticObjectField(env, RetryableSendFailure_class, RetryableSendFailure_LDKRetryableSendFailure_PaymentExpired);
812                 case LDKRetryableSendFailure_RouteNotFound:
813                         return (*env)->GetStaticObjectField(env, RetryableSendFailure_class, RetryableSendFailure_LDKRetryableSendFailure_RouteNotFound);
814                 case LDKRetryableSendFailure_DuplicatePayment:
815                         return (*env)->GetStaticObjectField(env, RetryableSendFailure_class, RetryableSendFailure_LDKRetryableSendFailure_DuplicatePayment);
816                 default: abort();
817         }
818 }
819
820 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
821         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
822         if (UNLIKELY((*env)->ExceptionCheck(env))) {
823                 (*env)->ExceptionDescribe(env);
824                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
825         }
826         switch (ord) {
827                 case 0: return LDKSecp256k1Error_IncorrectSignature;
828                 case 1: return LDKSecp256k1Error_InvalidMessage;
829                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
830                 case 3: return LDKSecp256k1Error_InvalidSignature;
831                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
832                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
833                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
834                 case 7: return LDKSecp256k1Error_InvalidTweak;
835                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
836                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
837                 case 10: return LDKSecp256k1Error_InvalidParityValue;
838         }
839         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
840         abort(); // Unreachable, but will let the compiler know we don't return here
841 }
842 static jclass Secp256k1Error_class = NULL;
843 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
844 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
845 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
846 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
847 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
848 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = NULL;
849 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
850 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
851 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
852 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = NULL;
853 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = NULL;
854 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
855         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
856         CHECK(Secp256k1Error_class != NULL);
857         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
858         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
859         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
860         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
861         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
862         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
863         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
864         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
865         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
866         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
867         Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSharedSecret", "Lorg/ldk/enums/Secp256k1Error;");
868         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret != NULL);
869         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
870         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
871         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
872         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
873         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
874         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
875         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKeySum", "Lorg/ldk/enums/Secp256k1Error;");
876         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum != NULL);
877         Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidParityValue", "Lorg/ldk/enums/Secp256k1Error;");
878         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidParityValue != NULL);
879 }
880 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
881         switch (val) {
882                 case LDKSecp256k1Error_IncorrectSignature:
883                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
884                 case LDKSecp256k1Error_InvalidMessage:
885                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
886                 case LDKSecp256k1Error_InvalidPublicKey:
887                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
888                 case LDKSecp256k1Error_InvalidSignature:
889                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
890                 case LDKSecp256k1Error_InvalidSecretKey:
891                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
892                 case LDKSecp256k1Error_InvalidSharedSecret:
893                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret);
894                 case LDKSecp256k1Error_InvalidRecoveryId:
895                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
896                 case LDKSecp256k1Error_InvalidTweak:
897                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
898                 case LDKSecp256k1Error_NotEnoughMemory:
899                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
900                 case LDKSecp256k1Error_InvalidPublicKeySum:
901                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum);
902                 case LDKSecp256k1Error_InvalidParityValue:
903                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidParityValue);
904                 default: abort();
905         }
906 }
907
908 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
909         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
910         if (UNLIKELY((*env)->ExceptionCheck(env))) {
911                 (*env)->ExceptionDescribe(env);
912                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
913         }
914         switch (ord) {
915                 case 0: return LDKSemanticError_NoPaymentHash;
916                 case 1: return LDKSemanticError_MultiplePaymentHashes;
917                 case 2: return LDKSemanticError_NoDescription;
918                 case 3: return LDKSemanticError_MultipleDescriptions;
919                 case 4: return LDKSemanticError_NoPaymentSecret;
920                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
921                 case 6: return LDKSemanticError_InvalidFeatures;
922                 case 7: return LDKSemanticError_InvalidRecoveryId;
923                 case 8: return LDKSemanticError_InvalidSignature;
924                 case 9: return LDKSemanticError_ImpreciseAmount;
925         }
926         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
927         abort(); // Unreachable, but will let the compiler know we don't return here
928 }
929 static jclass SemanticError_class = NULL;
930 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
931 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
932 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
933 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
934 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
935 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
936 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
937 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
938 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
939 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
940 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
941         SemanticError_class = (*env)->NewGlobalRef(env, clz);
942         CHECK(SemanticError_class != NULL);
943         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
944         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
945         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
946         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
947         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
948         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
949         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
950         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
951         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
952         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
953         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
954         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
955         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
956         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
957         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
958         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
959         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
960         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
961         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
962         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
963 }
964 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
965         switch (val) {
966                 case LDKSemanticError_NoPaymentHash:
967                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
968                 case LDKSemanticError_MultiplePaymentHashes:
969                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
970                 case LDKSemanticError_NoDescription:
971                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
972                 case LDKSemanticError_MultipleDescriptions:
973                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
974                 case LDKSemanticError_NoPaymentSecret:
975                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
976                 case LDKSemanticError_MultiplePaymentSecrets:
977                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
978                 case LDKSemanticError_InvalidFeatures:
979                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
980                 case LDKSemanticError_InvalidRecoveryId:
981                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
982                 case LDKSemanticError_InvalidSignature:
983                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
984                 case LDKSemanticError_ImpreciseAmount:
985                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
986                 default: abort();
987         }
988 }
989
990 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
991         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
992         if (UNLIKELY((*env)->ExceptionCheck(env))) {
993                 (*env)->ExceptionDescribe(env);
994                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
995         }
996         switch (ord) {
997                 case 0: return LDKSiPrefix_Milli;
998                 case 1: return LDKSiPrefix_Micro;
999                 case 2: return LDKSiPrefix_Nano;
1000                 case 3: return LDKSiPrefix_Pico;
1001         }
1002         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
1003         abort(); // Unreachable, but will let the compiler know we don't return here
1004 }
1005 static jclass SiPrefix_class = NULL;
1006 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
1007 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
1008 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
1009 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
1010 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
1011         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
1012         CHECK(SiPrefix_class != NULL);
1013         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
1014         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
1015         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
1016         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
1017         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
1018         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
1019         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
1020         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
1021 }
1022 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
1023         switch (val) {
1024                 case LDKSiPrefix_Milli:
1025                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
1026                 case LDKSiPrefix_Micro:
1027                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
1028                 case LDKSiPrefix_Nano:
1029                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
1030                 case LDKSiPrefix_Pico:
1031                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
1032                 default: abort();
1033         }
1034 }
1035
1036 static inline LDKUtxoLookupError LDKUtxoLookupError_from_java(JNIEnv *env, jclass clz) {
1037         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
1038         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1039                 (*env)->ExceptionDescribe(env);
1040                 (*env)->FatalError(env, "A call to UtxoLookupError.ordinal() from rust threw an exception.");
1041         }
1042         switch (ord) {
1043                 case 0: return LDKUtxoLookupError_UnknownChain;
1044                 case 1: return LDKUtxoLookupError_UnknownTx;
1045         }
1046         (*env)->FatalError(env, "A call to UtxoLookupError.ordinal() from rust returned an invalid value.");
1047         abort(); // Unreachable, but will let the compiler know we don't return here
1048 }
1049 static jclass UtxoLookupError_class = NULL;
1050 static jfieldID UtxoLookupError_LDKUtxoLookupError_UnknownChain = NULL;
1051 static jfieldID UtxoLookupError_LDKUtxoLookupError_UnknownTx = NULL;
1052 JNIEXPORT void JNICALL Java_org_ldk_enums_UtxoLookupError_init (JNIEnv *env, jclass clz) {
1053         UtxoLookupError_class = (*env)->NewGlobalRef(env, clz);
1054         CHECK(UtxoLookupError_class != NULL);
1055         UtxoLookupError_LDKUtxoLookupError_UnknownChain = (*env)->GetStaticFieldID(env, UtxoLookupError_class, "LDKUtxoLookupError_UnknownChain", "Lorg/ldk/enums/UtxoLookupError;");
1056         CHECK(UtxoLookupError_LDKUtxoLookupError_UnknownChain != NULL);
1057         UtxoLookupError_LDKUtxoLookupError_UnknownTx = (*env)->GetStaticFieldID(env, UtxoLookupError_class, "LDKUtxoLookupError_UnknownTx", "Lorg/ldk/enums/UtxoLookupError;");
1058         CHECK(UtxoLookupError_LDKUtxoLookupError_UnknownTx != NULL);
1059 }
1060 static inline jclass LDKUtxoLookupError_to_java(JNIEnv *env, LDKUtxoLookupError val) {
1061         switch (val) {
1062                 case LDKUtxoLookupError_UnknownChain:
1063                         return (*env)->GetStaticObjectField(env, UtxoLookupError_class, UtxoLookupError_LDKUtxoLookupError_UnknownChain);
1064                 case LDKUtxoLookupError_UnknownTx:
1065                         return (*env)->GetStaticObjectField(env, UtxoLookupError_class, UtxoLookupError_LDKUtxoLookupError_UnknownTx);
1066                 default: abort();
1067         }
1068 }
1069
1070 struct LDKThirtyTwoBytes BigEndianScalar_get_bytes (struct LDKBigEndianScalar* thing) {
1071         LDKThirtyTwoBytes ret = { .data = *thing->big_endian_bytes };
1072         return ret;
1073 }
1074 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1get_1bytes(JNIEnv *env, jclass clz, int64_t thing) {
1075         LDKBigEndianScalar* thing_conv = (LDKBigEndianScalar*)untag_ptr(thing);
1076         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1077         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BigEndianScalar_get_bytes(thing_conv).data);
1078         return ret_arr;
1079 }
1080
1081 static void BigEndianScalar_free (struct LDKBigEndianScalar thing) {}
1082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1free(JNIEnv *env, jclass clz, int64_t thing) {
1083         if (!ptr_is_owned(thing)) return;
1084         void* thing_ptr = untag_ptr(thing);
1085         CHECK_ACCESS(thing_ptr);
1086         LDKBigEndianScalar thing_conv = *(LDKBigEndianScalar*)(thing_ptr);
1087         FREE(untag_ptr(thing));
1088         BigEndianScalar_free(thing_conv);
1089 }
1090
1091 static jclass LDKBech32Error_MissingSeparator_class = NULL;
1092 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
1093 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
1094 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
1095 static jclass LDKBech32Error_InvalidLength_class = NULL;
1096 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
1097 static jclass LDKBech32Error_InvalidChar_class = NULL;
1098 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
1099 static jclass LDKBech32Error_InvalidData_class = NULL;
1100 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
1101 static jclass LDKBech32Error_InvalidPadding_class = NULL;
1102 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
1103 static jclass LDKBech32Error_MixedCase_class = NULL;
1104 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
1105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
1106         LDKBech32Error_MissingSeparator_class =
1107                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
1108         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
1109         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
1110         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
1111         LDKBech32Error_InvalidChecksum_class =
1112                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
1113         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
1114         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
1115         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
1116         LDKBech32Error_InvalidLength_class =
1117                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
1118         CHECK(LDKBech32Error_InvalidLength_class != NULL);
1119         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
1120         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
1121         LDKBech32Error_InvalidChar_class =
1122                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
1123         CHECK(LDKBech32Error_InvalidChar_class != NULL);
1124         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
1125         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
1126         LDKBech32Error_InvalidData_class =
1127                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
1128         CHECK(LDKBech32Error_InvalidData_class != NULL);
1129         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
1130         CHECK(LDKBech32Error_InvalidData_meth != NULL);
1131         LDKBech32Error_InvalidPadding_class =
1132                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
1133         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
1134         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
1135         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
1136         LDKBech32Error_MixedCase_class =
1137                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
1138         CHECK(LDKBech32Error_MixedCase_class != NULL);
1139         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
1140         CHECK(LDKBech32Error_MixedCase_meth != NULL);
1141 }
1142 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1143         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
1144         switch(obj->tag) {
1145                 case LDKBech32Error_MissingSeparator: {
1146                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
1147                 }
1148                 case LDKBech32Error_InvalidChecksum: {
1149                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
1150                 }
1151                 case LDKBech32Error_InvalidLength: {
1152                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
1153                 }
1154                 case LDKBech32Error_InvalidChar: {
1155                         int32_t invalid_char_conv = obj->invalid_char;
1156                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
1157                 }
1158                 case LDKBech32Error_InvalidData: {
1159                         int8_t invalid_data_conv = obj->invalid_data;
1160                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
1161                 }
1162                 case LDKBech32Error_InvalidPadding: {
1163                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
1164                 }
1165                 case LDKBech32Error_MixedCase: {
1166                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
1167                 }
1168                 default: abort();
1169         }
1170 }
1171 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
1172         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
1173         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
1174         return ret;
1175 }
1176 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) {
1177         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1178         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
1179         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1180         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1181         CVec_u8Z_free(ret_var);
1182         return ret_arr;
1183 }
1184
1185 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) {
1186         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1187         int64_t ret_conv = TxOut_get_value(thing_conv);
1188         return ret_conv;
1189 }
1190
1191 static jclass LDKCOption_DurationZ_Some_class = NULL;
1192 static jmethodID LDKCOption_DurationZ_Some_meth = NULL;
1193 static jclass LDKCOption_DurationZ_None_class = NULL;
1194 static jmethodID LDKCOption_DurationZ_None_meth = NULL;
1195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1DurationZ_init (JNIEnv *env, jclass clz) {
1196         LDKCOption_DurationZ_Some_class =
1197                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_DurationZ$Some"));
1198         CHECK(LDKCOption_DurationZ_Some_class != NULL);
1199         LDKCOption_DurationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_DurationZ_Some_class, "<init>", "(J)V");
1200         CHECK(LDKCOption_DurationZ_Some_meth != NULL);
1201         LDKCOption_DurationZ_None_class =
1202                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_DurationZ$None"));
1203         CHECK(LDKCOption_DurationZ_None_class != NULL);
1204         LDKCOption_DurationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_DurationZ_None_class, "<init>", "()V");
1205         CHECK(LDKCOption_DurationZ_None_meth != NULL);
1206 }
1207 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1DurationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1208         LDKCOption_DurationZ *obj = (LDKCOption_DurationZ*)untag_ptr(ptr);
1209         switch(obj->tag) {
1210                 case LDKCOption_DurationZ_Some: {
1211                         int64_t some_conv = obj->some;
1212                         return (*env)->NewObject(env, LDKCOption_DurationZ_Some_class, LDKCOption_DurationZ_Some_meth, some_conv);
1213                 }
1214                 case LDKCOption_DurationZ_None: {
1215                         return (*env)->NewObject(env, LDKCOption_DurationZ_None_class, LDKCOption_DurationZ_None_meth);
1216                 }
1217                 default: abort();
1218         }
1219 }
1220 static inline LDKCVec_BlindedPathZ CVec_BlindedPathZ_clone(const LDKCVec_BlindedPathZ *orig) {
1221         LDKCVec_BlindedPathZ ret = { .data = MALLOC(sizeof(LDKBlindedPath) * orig->datalen, "LDKCVec_BlindedPathZ clone bytes"), .datalen = orig->datalen };
1222         for (size_t i = 0; i < ret.datalen; i++) {
1223                 ret.data[i] = BlindedPath_clone(&orig->data[i]);
1224         }
1225         return ret;
1226 }
1227 static jclass LDKCOption_u64Z_Some_class = NULL;
1228 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1229 static jclass LDKCOption_u64Z_None_class = NULL;
1230 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1232         LDKCOption_u64Z_Some_class =
1233                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1234         CHECK(LDKCOption_u64Z_Some_class != NULL);
1235         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1236         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1237         LDKCOption_u64Z_None_class =
1238                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1239         CHECK(LDKCOption_u64Z_None_class != NULL);
1240         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1241         CHECK(LDKCOption_u64Z_None_meth != NULL);
1242 }
1243 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1244         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
1245         switch(obj->tag) {
1246                 case LDKCOption_u64Z_Some: {
1247                         int64_t some_conv = obj->some;
1248                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
1249                 }
1250                 case LDKCOption_u64Z_None: {
1251                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1252                 }
1253                 default: abort();
1254         }
1255 }
1256 static jclass LDKAPIError_APIMisuseError_class = NULL;
1257 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
1258 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
1259 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
1260 static jclass LDKAPIError_InvalidRoute_class = NULL;
1261 static jmethodID LDKAPIError_InvalidRoute_meth = NULL;
1262 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
1263 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
1264 static jclass LDKAPIError_MonitorUpdateInProgress_class = NULL;
1265 static jmethodID LDKAPIError_MonitorUpdateInProgress_meth = NULL;
1266 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
1267 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
1268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
1269         LDKAPIError_APIMisuseError_class =
1270                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
1271         CHECK(LDKAPIError_APIMisuseError_class != NULL);
1272         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
1273         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
1274         LDKAPIError_FeeRateTooHigh_class =
1275                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
1276         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
1277         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
1278         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
1279         LDKAPIError_InvalidRoute_class =
1280                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$InvalidRoute"));
1281         CHECK(LDKAPIError_InvalidRoute_class != NULL);
1282         LDKAPIError_InvalidRoute_meth = (*env)->GetMethodID(env, LDKAPIError_InvalidRoute_class, "<init>", "(Ljava/lang/String;)V");
1283         CHECK(LDKAPIError_InvalidRoute_meth != NULL);
1284         LDKAPIError_ChannelUnavailable_class =
1285                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
1286         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
1287         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
1288         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
1289         LDKAPIError_MonitorUpdateInProgress_class =
1290                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateInProgress"));
1291         CHECK(LDKAPIError_MonitorUpdateInProgress_class != NULL);
1292         LDKAPIError_MonitorUpdateInProgress_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateInProgress_class, "<init>", "()V");
1293         CHECK(LDKAPIError_MonitorUpdateInProgress_meth != NULL);
1294         LDKAPIError_IncompatibleShutdownScript_class =
1295                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
1296         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
1297         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
1298         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
1299 }
1300 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1301         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1302         switch(obj->tag) {
1303                 case LDKAPIError_APIMisuseError: {
1304                         LDKStr err_str = obj->api_misuse_error.err;
1305                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1306                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
1307                 }
1308                 case LDKAPIError_FeeRateTooHigh: {
1309                         LDKStr err_str = obj->fee_rate_too_high.err;
1310                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1311                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
1312                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
1313                 }
1314                 case LDKAPIError_InvalidRoute: {
1315                         LDKStr err_str = obj->invalid_route.err;
1316                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1317                         return (*env)->NewObject(env, LDKAPIError_InvalidRoute_class, LDKAPIError_InvalidRoute_meth, err_conv);
1318                 }
1319                 case LDKAPIError_ChannelUnavailable: {
1320                         LDKStr err_str = obj->channel_unavailable.err;
1321                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1322                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
1323                 }
1324                 case LDKAPIError_MonitorUpdateInProgress: {
1325                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateInProgress_class, LDKAPIError_MonitorUpdateInProgress_meth);
1326                 }
1327                 case LDKAPIError_IncompatibleShutdownScript: {
1328                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
1329                         int64_t script_ref = 0;
1330                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
1331                         script_ref = tag_ptr(script_var.inner, false);
1332                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
1333                 }
1334                 default: abort();
1335         }
1336 }
1337 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
1338 CHECK(owner->result_ok);
1339         return *owner->contents.result;
1340 }
1341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1342         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
1343         CResult_NoneAPIErrorZ_get_ok(owner_conv);
1344 }
1345
1346 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
1347 CHECK(!owner->result_ok);
1348         return APIError_clone(&*owner->contents.err);
1349 }
1350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1351         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
1352         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
1353         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
1354         int64_t ret_ref = tag_ptr(ret_copy, true);
1355         return ret_ref;
1356 }
1357
1358 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
1359         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
1360         for (size_t i = 0; i < ret.datalen; i++) {
1361                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
1362         }
1363         return ret;
1364 }
1365 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
1366         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
1367         for (size_t i = 0; i < ret.datalen; i++) {
1368                 ret.data[i] = APIError_clone(&orig->data[i]);
1369         }
1370         return ret;
1371 }
1372 static jclass LDKCOption_CVec_u8ZZ_Some_class = NULL;
1373 static jmethodID LDKCOption_CVec_u8ZZ_Some_meth = NULL;
1374 static jclass LDKCOption_CVec_u8ZZ_None_class = NULL;
1375 static jmethodID LDKCOption_CVec_u8ZZ_None_meth = NULL;
1376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1u8ZZ_init (JNIEnv *env, jclass clz) {
1377         LDKCOption_CVec_u8ZZ_Some_class =
1378                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_u8ZZ$Some"));
1379         CHECK(LDKCOption_CVec_u8ZZ_Some_class != NULL);
1380         LDKCOption_CVec_u8ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_u8ZZ_Some_class, "<init>", "([B)V");
1381         CHECK(LDKCOption_CVec_u8ZZ_Some_meth != NULL);
1382         LDKCOption_CVec_u8ZZ_None_class =
1383                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_u8ZZ$None"));
1384         CHECK(LDKCOption_CVec_u8ZZ_None_class != NULL);
1385         LDKCOption_CVec_u8ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_u8ZZ_None_class, "<init>", "()V");
1386         CHECK(LDKCOption_CVec_u8ZZ_None_meth != NULL);
1387 }
1388 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1u8ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1389         LDKCOption_CVec_u8ZZ *obj = (LDKCOption_CVec_u8ZZ*)untag_ptr(ptr);
1390         switch(obj->tag) {
1391                 case LDKCOption_CVec_u8ZZ_Some: {
1392                         LDKCVec_u8Z some_var = obj->some;
1393                         int8_tArray some_arr = (*env)->NewByteArray(env, some_var.datalen);
1394                         (*env)->SetByteArrayRegion(env, some_arr, 0, some_var.datalen, some_var.data);
1395                         return (*env)->NewObject(env, LDKCOption_CVec_u8ZZ_Some_class, LDKCOption_CVec_u8ZZ_Some_meth, some_arr);
1396                 }
1397                 case LDKCOption_CVec_u8ZZ_None: {
1398                         return (*env)->NewObject(env, LDKCOption_CVec_u8ZZ_None_class, LDKCOption_CVec_u8ZZ_None_meth);
1399                 }
1400                 default: abort();
1401         }
1402 }
1403 static jclass LDKDecodeError_UnknownVersion_class = NULL;
1404 static jmethodID LDKDecodeError_UnknownVersion_meth = NULL;
1405 static jclass LDKDecodeError_UnknownRequiredFeature_class = NULL;
1406 static jmethodID LDKDecodeError_UnknownRequiredFeature_meth = NULL;
1407 static jclass LDKDecodeError_InvalidValue_class = NULL;
1408 static jmethodID LDKDecodeError_InvalidValue_meth = NULL;
1409 static jclass LDKDecodeError_ShortRead_class = NULL;
1410 static jmethodID LDKDecodeError_ShortRead_meth = NULL;
1411 static jclass LDKDecodeError_BadLengthDescriptor_class = NULL;
1412 static jmethodID LDKDecodeError_BadLengthDescriptor_meth = NULL;
1413 static jclass LDKDecodeError_Io_class = NULL;
1414 static jmethodID LDKDecodeError_Io_meth = NULL;
1415 static jclass LDKDecodeError_UnsupportedCompression_class = NULL;
1416 static jmethodID LDKDecodeError_UnsupportedCompression_meth = NULL;
1417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDecodeError_init (JNIEnv *env, jclass clz) {
1418         LDKDecodeError_UnknownVersion_class =
1419                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownVersion"));
1420         CHECK(LDKDecodeError_UnknownVersion_class != NULL);
1421         LDKDecodeError_UnknownVersion_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownVersion_class, "<init>", "()V");
1422         CHECK(LDKDecodeError_UnknownVersion_meth != NULL);
1423         LDKDecodeError_UnknownRequiredFeature_class =
1424                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownRequiredFeature"));
1425         CHECK(LDKDecodeError_UnknownRequiredFeature_class != NULL);
1426         LDKDecodeError_UnknownRequiredFeature_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownRequiredFeature_class, "<init>", "()V");
1427         CHECK(LDKDecodeError_UnknownRequiredFeature_meth != NULL);
1428         LDKDecodeError_InvalidValue_class =
1429                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$InvalidValue"));
1430         CHECK(LDKDecodeError_InvalidValue_class != NULL);
1431         LDKDecodeError_InvalidValue_meth = (*env)->GetMethodID(env, LDKDecodeError_InvalidValue_class, "<init>", "()V");
1432         CHECK(LDKDecodeError_InvalidValue_meth != NULL);
1433         LDKDecodeError_ShortRead_class =
1434                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$ShortRead"));
1435         CHECK(LDKDecodeError_ShortRead_class != NULL);
1436         LDKDecodeError_ShortRead_meth = (*env)->GetMethodID(env, LDKDecodeError_ShortRead_class, "<init>", "()V");
1437         CHECK(LDKDecodeError_ShortRead_meth != NULL);
1438         LDKDecodeError_BadLengthDescriptor_class =
1439                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$BadLengthDescriptor"));
1440         CHECK(LDKDecodeError_BadLengthDescriptor_class != NULL);
1441         LDKDecodeError_BadLengthDescriptor_meth = (*env)->GetMethodID(env, LDKDecodeError_BadLengthDescriptor_class, "<init>", "()V");
1442         CHECK(LDKDecodeError_BadLengthDescriptor_meth != NULL);
1443         LDKDecodeError_Io_class =
1444                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$Io"));
1445         CHECK(LDKDecodeError_Io_class != NULL);
1446         LDKDecodeError_Io_meth = (*env)->GetMethodID(env, LDKDecodeError_Io_class, "<init>", "(Lorg/ldk/enums/IOError;)V");
1447         CHECK(LDKDecodeError_Io_meth != NULL);
1448         LDKDecodeError_UnsupportedCompression_class =
1449                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnsupportedCompression"));
1450         CHECK(LDKDecodeError_UnsupportedCompression_class != NULL);
1451         LDKDecodeError_UnsupportedCompression_meth = (*env)->GetMethodID(env, LDKDecodeError_UnsupportedCompression_class, "<init>", "()V");
1452         CHECK(LDKDecodeError_UnsupportedCompression_meth != NULL);
1453 }
1454 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDecodeError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1455         LDKDecodeError *obj = (LDKDecodeError*)untag_ptr(ptr);
1456         switch(obj->tag) {
1457                 case LDKDecodeError_UnknownVersion: {
1458                         return (*env)->NewObject(env, LDKDecodeError_UnknownVersion_class, LDKDecodeError_UnknownVersion_meth);
1459                 }
1460                 case LDKDecodeError_UnknownRequiredFeature: {
1461                         return (*env)->NewObject(env, LDKDecodeError_UnknownRequiredFeature_class, LDKDecodeError_UnknownRequiredFeature_meth);
1462                 }
1463                 case LDKDecodeError_InvalidValue: {
1464                         return (*env)->NewObject(env, LDKDecodeError_InvalidValue_class, LDKDecodeError_InvalidValue_meth);
1465                 }
1466                 case LDKDecodeError_ShortRead: {
1467                         return (*env)->NewObject(env, LDKDecodeError_ShortRead_class, LDKDecodeError_ShortRead_meth);
1468                 }
1469                 case LDKDecodeError_BadLengthDescriptor: {
1470                         return (*env)->NewObject(env, LDKDecodeError_BadLengthDescriptor_class, LDKDecodeError_BadLengthDescriptor_meth);
1471                 }
1472                 case LDKDecodeError_Io: {
1473                         jclass io_conv = LDKIOError_to_java(env, obj->io);
1474                         return (*env)->NewObject(env, LDKDecodeError_Io_class, LDKDecodeError_Io_meth, io_conv);
1475                 }
1476                 case LDKDecodeError_UnsupportedCompression: {
1477                         return (*env)->NewObject(env, LDKDecodeError_UnsupportedCompression_class, LDKDecodeError_UnsupportedCompression_meth);
1478                 }
1479                 default: abort();
1480         }
1481 }
1482 static inline struct LDKRecipientOnionFields CResult_RecipientOnionFieldsDecodeErrorZ_get_ok(LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR owner){
1483         LDKRecipientOnionFields ret = *owner->contents.result;
1484         ret.is_owned = false;
1485         return ret;
1486 }
1487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1488         LDKCResult_RecipientOnionFieldsDecodeErrorZ* owner_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(owner);
1489         LDKRecipientOnionFields ret_var = CResult_RecipientOnionFieldsDecodeErrorZ_get_ok(owner_conv);
1490         int64_t ret_ref = 0;
1491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1492         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1493         return ret_ref;
1494 }
1495
1496 static inline struct LDKDecodeError CResult_RecipientOnionFieldsDecodeErrorZ_get_err(LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR owner){
1497 CHECK(!owner->result_ok);
1498         return DecodeError_clone(&*owner->contents.err);
1499 }
1500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1501         LDKCResult_RecipientOnionFieldsDecodeErrorZ* owner_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(owner);
1502         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1503         *ret_copy = CResult_RecipientOnionFieldsDecodeErrorZ_get_err(owner_conv);
1504         int64_t ret_ref = tag_ptr(ret_copy, true);
1505         return ret_ref;
1506 }
1507
1508 static jclass LDKCOption_HTLCClaimZ_Some_class = NULL;
1509 static jmethodID LDKCOption_HTLCClaimZ_Some_meth = NULL;
1510 static jclass LDKCOption_HTLCClaimZ_None_class = NULL;
1511 static jmethodID LDKCOption_HTLCClaimZ_None_meth = NULL;
1512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCClaimZ_init (JNIEnv *env, jclass clz) {
1513         LDKCOption_HTLCClaimZ_Some_class =
1514                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCClaimZ$Some"));
1515         CHECK(LDKCOption_HTLCClaimZ_Some_class != NULL);
1516         LDKCOption_HTLCClaimZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCClaimZ_Some_class, "<init>", "(Lorg/ldk/enums/HTLCClaim;)V");
1517         CHECK(LDKCOption_HTLCClaimZ_Some_meth != NULL);
1518         LDKCOption_HTLCClaimZ_None_class =
1519                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCClaimZ$None"));
1520         CHECK(LDKCOption_HTLCClaimZ_None_class != NULL);
1521         LDKCOption_HTLCClaimZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCClaimZ_None_class, "<init>", "()V");
1522         CHECK(LDKCOption_HTLCClaimZ_None_meth != NULL);
1523 }
1524 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCClaimZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1525         LDKCOption_HTLCClaimZ *obj = (LDKCOption_HTLCClaimZ*)untag_ptr(ptr);
1526         switch(obj->tag) {
1527                 case LDKCOption_HTLCClaimZ_Some: {
1528                         jclass some_conv = LDKHTLCClaim_to_java(env, obj->some);
1529                         return (*env)->NewObject(env, LDKCOption_HTLCClaimZ_Some_class, LDKCOption_HTLCClaimZ_Some_meth, some_conv);
1530                 }
1531                 case LDKCOption_HTLCClaimZ_None: {
1532                         return (*env)->NewObject(env, LDKCOption_HTLCClaimZ_None_class, LDKCOption_HTLCClaimZ_None_meth);
1533                 }
1534                 default: abort();
1535         }
1536 }
1537 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1538 CHECK(owner->result_ok);
1539         return *owner->contents.result;
1540 }
1541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1542         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1543         CResult_NoneNoneZ_get_ok(owner_conv);
1544 }
1545
1546 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1547 CHECK(!owner->result_ok);
1548         return *owner->contents.err;
1549 }
1550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1551         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1552         CResult_NoneNoneZ_get_err(owner_conv);
1553 }
1554
1555 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1556         LDKCounterpartyCommitmentSecrets ret = *owner->contents.result;
1557         ret.is_owned = false;
1558         return ret;
1559 }
1560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1561         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1562         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1563         int64_t ret_ref = 0;
1564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1565         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1566         return ret_ref;
1567 }
1568
1569 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1570 CHECK(!owner->result_ok);
1571         return DecodeError_clone(&*owner->contents.err);
1572 }
1573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1574         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1575         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1576         *ret_copy = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1577         int64_t ret_ref = tag_ptr(ret_copy, true);
1578         return ret_ref;
1579 }
1580
1581 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1582         LDKTxCreationKeys ret = *owner->contents.result;
1583         ret.is_owned = false;
1584         return ret;
1585 }
1586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1587         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1588         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1589         int64_t ret_ref = 0;
1590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1591         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1592         return ret_ref;
1593 }
1594
1595 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1596 CHECK(!owner->result_ok);
1597         return DecodeError_clone(&*owner->contents.err);
1598 }
1599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1600         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1601         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1602         *ret_copy = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1603         int64_t ret_ref = tag_ptr(ret_copy, true);
1604         return ret_ref;
1605 }
1606
1607 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1608         LDKChannelPublicKeys ret = *owner->contents.result;
1609         ret.is_owned = false;
1610         return ret;
1611 }
1612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1613         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1614         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1615         int64_t ret_ref = 0;
1616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1617         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1618         return ret_ref;
1619 }
1620
1621 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1622 CHECK(!owner->result_ok);
1623         return DecodeError_clone(&*owner->contents.err);
1624 }
1625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1626         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1627         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1628         *ret_copy = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1629         int64_t ret_ref = tag_ptr(ret_copy, true);
1630         return ret_ref;
1631 }
1632
1633 static jclass LDKCOption_u32Z_Some_class = NULL;
1634 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1635 static jclass LDKCOption_u32Z_None_class = NULL;
1636 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1638         LDKCOption_u32Z_Some_class =
1639                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1640         CHECK(LDKCOption_u32Z_Some_class != NULL);
1641         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1642         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1643         LDKCOption_u32Z_None_class =
1644                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1645         CHECK(LDKCOption_u32Z_None_class != NULL);
1646         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1647         CHECK(LDKCOption_u32Z_None_meth != NULL);
1648 }
1649 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1650         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
1651         switch(obj->tag) {
1652                 case LDKCOption_u32Z_Some: {
1653                         int32_t some_conv = obj->some;
1654                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1655                 }
1656                 case LDKCOption_u32Z_None: {
1657                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1658                 }
1659                 default: abort();
1660         }
1661 }
1662 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1663         LDKHTLCOutputInCommitment ret = *owner->contents.result;
1664         ret.is_owned = false;
1665         return ret;
1666 }
1667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1668         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1669         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1670         int64_t ret_ref = 0;
1671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1672         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1673         return ret_ref;
1674 }
1675
1676 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1677 CHECK(!owner->result_ok);
1678         return DecodeError_clone(&*owner->contents.err);
1679 }
1680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1681         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1682         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1683         *ret_copy = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1684         int64_t ret_ref = tag_ptr(ret_copy, true);
1685         return ret_ref;
1686 }
1687
1688 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1689         LDKCounterpartyChannelTransactionParameters ret = *owner->contents.result;
1690         ret.is_owned = false;
1691         return ret;
1692 }
1693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1694         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1695         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1696         int64_t ret_ref = 0;
1697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1698         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1699         return ret_ref;
1700 }
1701
1702 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1703 CHECK(!owner->result_ok);
1704         return DecodeError_clone(&*owner->contents.err);
1705 }
1706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1707         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1708         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1709         *ret_copy = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1710         int64_t ret_ref = tag_ptr(ret_copy, true);
1711         return ret_ref;
1712 }
1713
1714 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1715         LDKChannelTransactionParameters ret = *owner->contents.result;
1716         ret.is_owned = false;
1717         return ret;
1718 }
1719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1720         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1721         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_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_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *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_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1733         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1734         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1735         *ret_copy = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1736         int64_t ret_ref = tag_ptr(ret_copy, true);
1737         return ret_ref;
1738 }
1739
1740 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1741         LDKHolderCommitmentTransaction ret = *owner->contents.result;
1742         ret.is_owned = false;
1743         return ret;
1744 }
1745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1746         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1747         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_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 LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1755 CHECK(!owner->result_ok);
1756         return DecodeError_clone(&*owner->contents.err);
1757 }
1758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1759         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1760         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1761         *ret_copy = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1762         int64_t ret_ref = tag_ptr(ret_copy, true);
1763         return ret_ref;
1764 }
1765
1766 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1767         LDKBuiltCommitmentTransaction ret = *owner->contents.result;
1768         ret.is_owned = false;
1769         return ret;
1770 }
1771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1772         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1773         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1774         int64_t ret_ref = 0;
1775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1777         return ret_ref;
1778 }
1779
1780 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1781 CHECK(!owner->result_ok);
1782         return DecodeError_clone(&*owner->contents.err);
1783 }
1784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1785         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1786         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1787         *ret_copy = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1788         int64_t ret_ref = tag_ptr(ret_copy, true);
1789         return ret_ref;
1790 }
1791
1792 static inline struct LDKTrustedClosingTransaction CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1793         LDKTrustedClosingTransaction ret = *owner->contents.result;
1794         ret.is_owned = false;
1795         return ret;
1796 }
1797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1798         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1799         LDKTrustedClosingTransaction ret_var = CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1800         int64_t ret_ref = 0;
1801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1802         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1803         return ret_ref;
1804 }
1805
1806 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1807 CHECK(!owner->result_ok);
1808         return *owner->contents.err;
1809 }
1810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1811         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1812         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1813 }
1814
1815 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1816         LDKCommitmentTransaction ret = *owner->contents.result;
1817         ret.is_owned = false;
1818         return ret;
1819 }
1820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1821         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1822         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1823         int64_t ret_ref = 0;
1824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1825         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1826         return ret_ref;
1827 }
1828
1829 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1830 CHECK(!owner->result_ok);
1831         return DecodeError_clone(&*owner->contents.err);
1832 }
1833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1834         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1835         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1836         *ret_copy = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1837         int64_t ret_ref = tag_ptr(ret_copy, true);
1838         return ret_ref;
1839 }
1840
1841 static inline struct LDKTrustedCommitmentTransaction CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1842         LDKTrustedCommitmentTransaction ret = *owner->contents.result;
1843         ret.is_owned = false;
1844         return ret;
1845 }
1846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1847         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1848         LDKTrustedCommitmentTransaction ret_var = CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1849         int64_t ret_ref = 0;
1850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1851         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1852         return ret_ref;
1853 }
1854
1855 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1856 CHECK(!owner->result_ok);
1857         return *owner->contents.err;
1858 }
1859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1860         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1861         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1862 }
1863
1864 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1865 CHECK(owner->result_ok);
1866         return *owner->contents.result;
1867 }
1868 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1869         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1870         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1871         jobjectArray ret_arr = NULL;
1872         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1873         ;
1874         for (size_t i = 0; i < ret_var.datalen; i++) {
1875                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1876                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1877                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1878         }
1879         
1880         return ret_arr;
1881 }
1882
1883 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1884 CHECK(!owner->result_ok);
1885         return *owner->contents.err;
1886 }
1887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1888         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1889         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1890 }
1891
1892 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1893         LDKShutdownScript ret = *owner->contents.result;
1894         ret.is_owned = false;
1895         return ret;
1896 }
1897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1898         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1899         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1900         int64_t ret_ref = 0;
1901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1902         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1903         return ret_ref;
1904 }
1905
1906 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1907 CHECK(!owner->result_ok);
1908         return DecodeError_clone(&*owner->contents.err);
1909 }
1910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1911         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1912         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1913         *ret_copy = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1914         int64_t ret_ref = tag_ptr(ret_copy, true);
1915         return ret_ref;
1916 }
1917
1918 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1919         LDKShutdownScript ret = *owner->contents.result;
1920         ret.is_owned = false;
1921         return ret;
1922 }
1923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1924         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1925         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1926         int64_t ret_ref = 0;
1927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1928         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1929         return ret_ref;
1930 }
1931
1932 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1933         LDKInvalidShutdownScript ret = *owner->contents.err;
1934         ret.is_owned = false;
1935         return ret;
1936 }
1937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1938         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1939         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1940         int64_t ret_ref = 0;
1941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1942         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1943         return ret_ref;
1944 }
1945
1946 static inline struct LDKBlindedPayInfo CResult_BlindedPayInfoDecodeErrorZ_get_ok(LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR owner){
1947         LDKBlindedPayInfo ret = *owner->contents.result;
1948         ret.is_owned = false;
1949         return ret;
1950 }
1951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1952         LDKCResult_BlindedPayInfoDecodeErrorZ* owner_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(owner);
1953         LDKBlindedPayInfo ret_var = CResult_BlindedPayInfoDecodeErrorZ_get_ok(owner_conv);
1954         int64_t ret_ref = 0;
1955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1956         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1957         return ret_ref;
1958 }
1959
1960 static inline struct LDKDecodeError CResult_BlindedPayInfoDecodeErrorZ_get_err(LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR owner){
1961 CHECK(!owner->result_ok);
1962         return DecodeError_clone(&*owner->contents.err);
1963 }
1964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1965         LDKCResult_BlindedPayInfoDecodeErrorZ* owner_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(owner);
1966         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1967         *ret_copy = CResult_BlindedPayInfoDecodeErrorZ_get_err(owner_conv);
1968         int64_t ret_ref = tag_ptr(ret_copy, true);
1969         return ret_ref;
1970 }
1971
1972 typedef struct LDKScore_JCalls {
1973         atomic_size_t refcnt;
1974         JavaVM *vm;
1975         jweak o;
1976         jmethodID channel_penalty_msat_meth;
1977         jmethodID payment_path_failed_meth;
1978         jmethodID payment_path_successful_meth;
1979         jmethodID probe_failed_meth;
1980         jmethodID probe_successful_meth;
1981         jmethodID write_meth;
1982 } LDKScore_JCalls;
1983 static void LDKScore_JCalls_free(void* this_arg) {
1984         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1985         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1986                 JNIEnv *env;
1987                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1988                 if (get_jenv_res == JNI_EDETACHED) {
1989                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1990                 } else {
1991                         DO_ASSERT(get_jenv_res == JNI_OK);
1992                 }
1993                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1994                 if (get_jenv_res == JNI_EDETACHED) {
1995                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1996                 }
1997                 FREE(j_calls);
1998         }
1999 }
2000 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
2001         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2002         JNIEnv *env;
2003         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2004         if (get_jenv_res == JNI_EDETACHED) {
2005                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2006         } else {
2007                 DO_ASSERT(get_jenv_res == JNI_OK);
2008         }
2009         int64_t short_channel_id_conv = short_channel_id;
2010         LDKNodeId source_var = *source;
2011         int64_t source_ref = 0;
2012         source_var = NodeId_clone(&source_var);
2013         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
2014         source_ref = tag_ptr(source_var.inner, source_var.is_owned);
2015         LDKNodeId target_var = *target;
2016         int64_t target_ref = 0;
2017         target_var = NodeId_clone(&target_var);
2018         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
2019         target_ref = tag_ptr(target_var.inner, target_var.is_owned);
2020         LDKChannelUsage usage_var = usage;
2021         int64_t usage_ref = 0;
2022         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
2023         usage_ref = tag_ptr(usage_var.inner, usage_var.is_owned);
2024         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2025         CHECK(obj != NULL);
2026         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
2027         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2028                 (*env)->ExceptionDescribe(env);
2029                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
2030         }
2031         if (get_jenv_res == JNI_EDETACHED) {
2032                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2033         }
2034         return ret;
2035 }
2036 void payment_path_failed_LDKScore_jcall(void* this_arg, const LDKPath * path, uint64_t short_channel_id) {
2037         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2038         JNIEnv *env;
2039         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2040         if (get_jenv_res == JNI_EDETACHED) {
2041                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2042         } else {
2043                 DO_ASSERT(get_jenv_res == JNI_OK);
2044         }
2045         LDKPath path_var = *path;
2046         int64_t path_ref = 0;
2047         path_var = Path_clone(&path_var);
2048         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2049         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2050         int64_t short_channel_id_conv = short_channel_id;
2051         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2052         CHECK(obj != NULL);
2053         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_ref, short_channel_id_conv);
2054         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2055                 (*env)->ExceptionDescribe(env);
2056                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
2057         }
2058         if (get_jenv_res == JNI_EDETACHED) {
2059                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2060         }
2061 }
2062 void payment_path_successful_LDKScore_jcall(void* this_arg, const LDKPath * path) {
2063         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2064         JNIEnv *env;
2065         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2066         if (get_jenv_res == JNI_EDETACHED) {
2067                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2068         } else {
2069                 DO_ASSERT(get_jenv_res == JNI_OK);
2070         }
2071         LDKPath path_var = *path;
2072         int64_t path_ref = 0;
2073         path_var = Path_clone(&path_var);
2074         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2075         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2076         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2077         CHECK(obj != NULL);
2078         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_ref);
2079         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2080                 (*env)->ExceptionDescribe(env);
2081                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
2082         }
2083         if (get_jenv_res == JNI_EDETACHED) {
2084                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2085         }
2086 }
2087 void probe_failed_LDKScore_jcall(void* this_arg, const LDKPath * path, uint64_t short_channel_id) {
2088         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2089         JNIEnv *env;
2090         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2091         if (get_jenv_res == JNI_EDETACHED) {
2092                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2093         } else {
2094                 DO_ASSERT(get_jenv_res == JNI_OK);
2095         }
2096         LDKPath path_var = *path;
2097         int64_t path_ref = 0;
2098         path_var = Path_clone(&path_var);
2099         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2100         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2101         int64_t short_channel_id_conv = short_channel_id;
2102         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2103         CHECK(obj != NULL);
2104         (*env)->CallVoidMethod(env, obj, j_calls->probe_failed_meth, path_ref, short_channel_id_conv);
2105         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2106                 (*env)->ExceptionDescribe(env);
2107                 (*env)->FatalError(env, "A call to probe_failed in LDKScore from rust threw an exception.");
2108         }
2109         if (get_jenv_res == JNI_EDETACHED) {
2110                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2111         }
2112 }
2113 void probe_successful_LDKScore_jcall(void* this_arg, const LDKPath * path) {
2114         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2115         JNIEnv *env;
2116         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2117         if (get_jenv_res == JNI_EDETACHED) {
2118                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2119         } else {
2120                 DO_ASSERT(get_jenv_res == JNI_OK);
2121         }
2122         LDKPath path_var = *path;
2123         int64_t path_ref = 0;
2124         path_var = Path_clone(&path_var);
2125         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2126         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2127         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2128         CHECK(obj != NULL);
2129         (*env)->CallVoidMethod(env, obj, j_calls->probe_successful_meth, path_ref);
2130         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2131                 (*env)->ExceptionDescribe(env);
2132                 (*env)->FatalError(env, "A call to probe_successful in LDKScore from rust threw an exception.");
2133         }
2134         if (get_jenv_res == JNI_EDETACHED) {
2135                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2136         }
2137 }
2138 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
2139         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
2140         JNIEnv *env;
2141         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2142         if (get_jenv_res == JNI_EDETACHED) {
2143                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2144         } else {
2145                 DO_ASSERT(get_jenv_res == JNI_OK);
2146         }
2147         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2148         CHECK(obj != NULL);
2149         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2150         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2151                 (*env)->ExceptionDescribe(env);
2152                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
2153         }
2154         LDKCVec_u8Z ret_ref;
2155         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2156         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2157         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2158         if (get_jenv_res == JNI_EDETACHED) {
2159                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2160         }
2161         return ret_ref;
2162 }
2163 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
2164         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
2165         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2166 }
2167 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
2168         jclass c = (*env)->GetObjectClass(env, o);
2169         CHECK(c != NULL);
2170         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
2171         atomic_init(&calls->refcnt, 1);
2172         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2173         calls->o = (*env)->NewWeakGlobalRef(env, o);
2174         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
2175         CHECK(calls->channel_penalty_msat_meth != NULL);
2176         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "(JJ)V");
2177         CHECK(calls->payment_path_failed_meth != NULL);
2178         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "(J)V");
2179         CHECK(calls->payment_path_successful_meth != NULL);
2180         calls->probe_failed_meth = (*env)->GetMethodID(env, c, "probe_failed", "(JJ)V");
2181         CHECK(calls->probe_failed_meth != NULL);
2182         calls->probe_successful_meth = (*env)->GetMethodID(env, c, "probe_successful", "(J)V");
2183         CHECK(calls->probe_successful_meth != NULL);
2184         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2185         CHECK(calls->write_meth != NULL);
2186
2187         LDKScore ret = {
2188                 .this_arg = (void*) calls,
2189                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
2190                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
2191                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
2192                 .probe_failed = probe_failed_LDKScore_jcall,
2193                 .probe_successful = probe_successful_LDKScore_jcall,
2194                 .write = write_LDKScore_jcall,
2195                 .free = LDKScore_JCalls_free,
2196         };
2197         return ret;
2198 }
2199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
2200         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
2201         *res_ptr = LDKScore_init(env, clz, o);
2202         return tag_ptr(res_ptr, true);
2203 }
2204 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) {
2205         void* this_arg_ptr = untag_ptr(this_arg);
2206         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2207         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2208         LDKNodeId source_conv;
2209         source_conv.inner = untag_ptr(source);
2210         source_conv.is_owned = ptr_is_owned(source);
2211         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
2212         source_conv.is_owned = false;
2213         LDKNodeId target_conv;
2214         target_conv.inner = untag_ptr(target);
2215         target_conv.is_owned = ptr_is_owned(target);
2216         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
2217         target_conv.is_owned = false;
2218         LDKChannelUsage usage_conv;
2219         usage_conv.inner = untag_ptr(usage);
2220         usage_conv.is_owned = ptr_is_owned(usage);
2221         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
2222         usage_conv = ChannelUsage_clone(&usage_conv);
2223         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
2224         return ret_conv;
2225 }
2226
2227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path, int64_t short_channel_id) {
2228         void* this_arg_ptr = untag_ptr(this_arg);
2229         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2230         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2231         LDKPath path_conv;
2232         path_conv.inner = untag_ptr(path);
2233         path_conv.is_owned = ptr_is_owned(path);
2234         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2235         path_conv.is_owned = false;
2236         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, &path_conv, short_channel_id);
2237 }
2238
2239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path) {
2240         void* this_arg_ptr = untag_ptr(this_arg);
2241         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2242         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2243         LDKPath path_conv;
2244         path_conv.inner = untag_ptr(path);
2245         path_conv.is_owned = ptr_is_owned(path);
2246         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2247         path_conv.is_owned = false;
2248         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, &path_conv);
2249 }
2250
2251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path, int64_t short_channel_id) {
2252         void* this_arg_ptr = untag_ptr(this_arg);
2253         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2254         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2255         LDKPath path_conv;
2256         path_conv.inner = untag_ptr(path);
2257         path_conv.is_owned = ptr_is_owned(path);
2258         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2259         path_conv.is_owned = false;
2260         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, &path_conv, short_channel_id);
2261 }
2262
2263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path) {
2264         void* this_arg_ptr = untag_ptr(this_arg);
2265         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2266         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2267         LDKPath path_conv;
2268         path_conv.inner = untag_ptr(path);
2269         path_conv.is_owned = ptr_is_owned(path);
2270         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2271         path_conv.is_owned = false;
2272         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, &path_conv);
2273 }
2274
2275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2276         void* this_arg_ptr = untag_ptr(this_arg);
2277         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2278         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2279         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2280         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2281         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2282         CVec_u8Z_free(ret_var);
2283         return ret_arr;
2284 }
2285
2286 typedef struct LDKLockableScore_JCalls {
2287         atomic_size_t refcnt;
2288         JavaVM *vm;
2289         jweak o;
2290         jmethodID lock_meth;
2291 } LDKLockableScore_JCalls;
2292 static void LDKLockableScore_JCalls_free(void* this_arg) {
2293         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2294         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2295                 JNIEnv *env;
2296                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2297                 if (get_jenv_res == JNI_EDETACHED) {
2298                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2299                 } else {
2300                         DO_ASSERT(get_jenv_res == JNI_OK);
2301                 }
2302                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2303                 if (get_jenv_res == JNI_EDETACHED) {
2304                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2305                 }
2306                 FREE(j_calls);
2307         }
2308 }
2309 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
2310         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2311         JNIEnv *env;
2312         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2313         if (get_jenv_res == JNI_EDETACHED) {
2314                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2315         } else {
2316                 DO_ASSERT(get_jenv_res == JNI_OK);
2317         }
2318         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2319         CHECK(obj != NULL);
2320         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
2321         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2322                 (*env)->ExceptionDescribe(env);
2323                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
2324         }
2325         void* ret_ptr = untag_ptr(ret);
2326         CHECK_ACCESS(ret_ptr);
2327         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
2328         if (ret_conv.free == LDKScore_JCalls_free) {
2329                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2330                 LDKScore_JCalls_cloned(&ret_conv);
2331         }// WARNING: we may need a move here but no clone is available for LDKScore
2332         
2333         if (get_jenv_res == JNI_EDETACHED) {
2334                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2335         }
2336         return ret_conv;
2337 }
2338 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
2339         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
2340         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2341 }
2342 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
2343         jclass c = (*env)->GetObjectClass(env, o);
2344         CHECK(c != NULL);
2345         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
2346         atomic_init(&calls->refcnt, 1);
2347         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2348         calls->o = (*env)->NewWeakGlobalRef(env, o);
2349         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
2350         CHECK(calls->lock_meth != NULL);
2351
2352         LDKLockableScore ret = {
2353                 .this_arg = (void*) calls,
2354                 .lock = lock_LDKLockableScore_jcall,
2355                 .free = LDKLockableScore_JCalls_free,
2356         };
2357         return ret;
2358 }
2359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
2360         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
2361         *res_ptr = LDKLockableScore_init(env, clz, o);
2362         return tag_ptr(res_ptr, true);
2363 }
2364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
2365         void* this_arg_ptr = untag_ptr(this_arg);
2366         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2367         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
2368         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
2369         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
2370         return tag_ptr(ret_ret, true);
2371 }
2372
2373 typedef struct LDKWriteableScore_JCalls {
2374         atomic_size_t refcnt;
2375         JavaVM *vm;
2376         jweak o;
2377         LDKLockableScore_JCalls* LockableScore;
2378         jmethodID write_meth;
2379 } LDKWriteableScore_JCalls;
2380 static void LDKWriteableScore_JCalls_free(void* this_arg) {
2381         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2382         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2383                 JNIEnv *env;
2384                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2385                 if (get_jenv_res == JNI_EDETACHED) {
2386                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2387                 } else {
2388                         DO_ASSERT(get_jenv_res == JNI_OK);
2389                 }
2390                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2391                 if (get_jenv_res == JNI_EDETACHED) {
2392                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2393                 }
2394                 FREE(j_calls);
2395         }
2396 }
2397 LDKCVec_u8Z write_LDKWriteableScore_jcall(const void* this_arg) {
2398         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2399         JNIEnv *env;
2400         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2401         if (get_jenv_res == JNI_EDETACHED) {
2402                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2403         } else {
2404                 DO_ASSERT(get_jenv_res == JNI_OK);
2405         }
2406         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2407         CHECK(obj != NULL);
2408         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2409         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2410                 (*env)->ExceptionDescribe(env);
2411                 (*env)->FatalError(env, "A call to write in LDKWriteableScore from rust threw an exception.");
2412         }
2413         LDKCVec_u8Z ret_ref;
2414         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2415         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2416         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2417         if (get_jenv_res == JNI_EDETACHED) {
2418                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2419         }
2420         return ret_ref;
2421 }
2422 static void LDKWriteableScore_JCalls_cloned(LDKWriteableScore* new_obj) {
2423         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) new_obj->this_arg;
2424         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2425         atomic_fetch_add_explicit(&j_calls->LockableScore->refcnt, 1, memory_order_release);
2426 }
2427 static inline LDKWriteableScore LDKWriteableScore_init (JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2428         jclass c = (*env)->GetObjectClass(env, o);
2429         CHECK(c != NULL);
2430         LDKWriteableScore_JCalls *calls = MALLOC(sizeof(LDKWriteableScore_JCalls), "LDKWriteableScore_JCalls");
2431         atomic_init(&calls->refcnt, 1);
2432         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2433         calls->o = (*env)->NewWeakGlobalRef(env, o);
2434         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2435         CHECK(calls->write_meth != NULL);
2436
2437         LDKWriteableScore ret = {
2438                 .this_arg = (void*) calls,
2439                 .write = write_LDKWriteableScore_jcall,
2440                 .free = LDKWriteableScore_JCalls_free,
2441                 .LockableScore = LDKLockableScore_init(env, clz, LockableScore),
2442         };
2443         calls->LockableScore = ret.LockableScore.this_arg;
2444         return ret;
2445 }
2446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1new(JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2447         LDKWriteableScore *res_ptr = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2448         *res_ptr = LDKWriteableScore_init(env, clz, o, LockableScore);
2449         return tag_ptr(res_ptr, true);
2450 }
2451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1get_1LockableScore(JNIEnv *env, jclass clz, int64_t arg) {
2452         LDKWriteableScore *inp = (LDKWriteableScore *)untag_ptr(arg);
2453         return tag_ptr(&inp->LockableScore, false);
2454 }
2455 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WriteableScore_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2456         void* this_arg_ptr = untag_ptr(this_arg);
2457         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2458         LDKWriteableScore* this_arg_conv = (LDKWriteableScore*)this_arg_ptr;
2459         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2460         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2461         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2462         CVec_u8Z_free(ret_var);
2463         return ret_arr;
2464 }
2465
2466 static jclass LDKCOption_WriteableScoreZ_Some_class = NULL;
2467 static jmethodID LDKCOption_WriteableScoreZ_Some_meth = NULL;
2468 static jclass LDKCOption_WriteableScoreZ_None_class = NULL;
2469 static jmethodID LDKCOption_WriteableScoreZ_None_meth = NULL;
2470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1WriteableScoreZ_init (JNIEnv *env, jclass clz) {
2471         LDKCOption_WriteableScoreZ_Some_class =
2472                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$Some"));
2473         CHECK(LDKCOption_WriteableScoreZ_Some_class != NULL);
2474         LDKCOption_WriteableScoreZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_Some_class, "<init>", "(J)V");
2475         CHECK(LDKCOption_WriteableScoreZ_Some_meth != NULL);
2476         LDKCOption_WriteableScoreZ_None_class =
2477                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$None"));
2478         CHECK(LDKCOption_WriteableScoreZ_None_class != NULL);
2479         LDKCOption_WriteableScoreZ_None_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_None_class, "<init>", "()V");
2480         CHECK(LDKCOption_WriteableScoreZ_None_meth != NULL);
2481 }
2482 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1WriteableScoreZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2483         LDKCOption_WriteableScoreZ *obj = (LDKCOption_WriteableScoreZ*)untag_ptr(ptr);
2484         switch(obj->tag) {
2485                 case LDKCOption_WriteableScoreZ_Some: {
2486                         LDKWriteableScore* some_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2487                         *some_ret = obj->some;
2488                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
2489                         if ((*some_ret).free == LDKWriteableScore_JCalls_free) {
2490                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2491                                 LDKWriteableScore_JCalls_cloned(&(*some_ret));
2492                         }
2493                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_Some_class, LDKCOption_WriteableScoreZ_Some_meth, tag_ptr(some_ret, true));
2494                 }
2495                 case LDKCOption_WriteableScoreZ_None: {
2496                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_None_class, LDKCOption_WriteableScoreZ_None_meth);
2497                 }
2498                 default: abort();
2499         }
2500 }
2501 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2502 CHECK(owner->result_ok);
2503         return *owner->contents.result;
2504 }
2505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2506         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2507         CResult_NoneErrorZ_get_ok(owner_conv);
2508 }
2509
2510 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2511 CHECK(!owner->result_ok);
2512         return *owner->contents.err;
2513 }
2514 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2515         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2516         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
2517         return ret_conv;
2518 }
2519
2520 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2521         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2522         for (size_t i = 0; i < ret.datalen; i++) {
2523                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2524         }
2525         return ret;
2526 }
2527 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2528         LDKRoute ret = *owner->contents.result;
2529         ret.is_owned = false;
2530         return ret;
2531 }
2532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2533         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2534         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
2535         int64_t ret_ref = 0;
2536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2537         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2538         return ret_ref;
2539 }
2540
2541 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2542         LDKLightningError ret = *owner->contents.err;
2543         ret.is_owned = false;
2544         return ret;
2545 }
2546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2547         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2548         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
2549         int64_t ret_ref = 0;
2550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2552         return ret_ref;
2553 }
2554
2555 static inline struct LDKInFlightHtlcs CResult_InFlightHtlcsDecodeErrorZ_get_ok(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2556         LDKInFlightHtlcs ret = *owner->contents.result;
2557         ret.is_owned = false;
2558         return ret;
2559 }
2560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2561         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2562         LDKInFlightHtlcs ret_var = CResult_InFlightHtlcsDecodeErrorZ_get_ok(owner_conv);
2563         int64_t ret_ref = 0;
2564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2565         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2566         return ret_ref;
2567 }
2568
2569 static inline struct LDKDecodeError CResult_InFlightHtlcsDecodeErrorZ_get_err(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2570 CHECK(!owner->result_ok);
2571         return DecodeError_clone(&*owner->contents.err);
2572 }
2573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2574         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2575         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2576         *ret_copy = CResult_InFlightHtlcsDecodeErrorZ_get_err(owner_conv);
2577         int64_t ret_ref = tag_ptr(ret_copy, true);
2578         return ret_ref;
2579 }
2580
2581 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2582         LDKRouteHop ret = *owner->contents.result;
2583         ret.is_owned = false;
2584         return ret;
2585 }
2586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2587         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2588         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
2589         int64_t ret_ref = 0;
2590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2591         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2592         return ret_ref;
2593 }
2594
2595 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2596 CHECK(!owner->result_ok);
2597         return DecodeError_clone(&*owner->contents.err);
2598 }
2599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2600         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2601         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2602         *ret_copy = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
2603         int64_t ret_ref = tag_ptr(ret_copy, true);
2604         return ret_ref;
2605 }
2606
2607 static inline LDKCVec_BlindedHopZ CVec_BlindedHopZ_clone(const LDKCVec_BlindedHopZ *orig) {
2608         LDKCVec_BlindedHopZ ret = { .data = MALLOC(sizeof(LDKBlindedHop) * orig->datalen, "LDKCVec_BlindedHopZ clone bytes"), .datalen = orig->datalen };
2609         for (size_t i = 0; i < ret.datalen; i++) {
2610                 ret.data[i] = BlindedHop_clone(&orig->data[i]);
2611         }
2612         return ret;
2613 }
2614 static inline struct LDKBlindedTail CResult_BlindedTailDecodeErrorZ_get_ok(LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR owner){
2615         LDKBlindedTail ret = *owner->contents.result;
2616         ret.is_owned = false;
2617         return ret;
2618 }
2619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2620         LDKCResult_BlindedTailDecodeErrorZ* owner_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(owner);
2621         LDKBlindedTail ret_var = CResult_BlindedTailDecodeErrorZ_get_ok(owner_conv);
2622         int64_t ret_ref = 0;
2623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2624         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2625         return ret_ref;
2626 }
2627
2628 static inline struct LDKDecodeError CResult_BlindedTailDecodeErrorZ_get_err(LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR owner){
2629 CHECK(!owner->result_ok);
2630         return DecodeError_clone(&*owner->contents.err);
2631 }
2632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2633         LDKCResult_BlindedTailDecodeErrorZ* owner_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(owner);
2634         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2635         *ret_copy = CResult_BlindedTailDecodeErrorZ_get_err(owner_conv);
2636         int64_t ret_ref = tag_ptr(ret_copy, true);
2637         return ret_ref;
2638 }
2639
2640 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
2641         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
2642         for (size_t i = 0; i < ret.datalen; i++) {
2643                 ret.data[i] = RouteHop_clone(&orig->data[i]);
2644         }
2645         return ret;
2646 }
2647 static inline LDKCVec_PathZ CVec_PathZ_clone(const LDKCVec_PathZ *orig) {
2648         LDKCVec_PathZ ret = { .data = MALLOC(sizeof(LDKPath) * orig->datalen, "LDKCVec_PathZ clone bytes"), .datalen = orig->datalen };
2649         for (size_t i = 0; i < ret.datalen; i++) {
2650                 ret.data[i] = Path_clone(&orig->data[i]);
2651         }
2652         return ret;
2653 }
2654 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2655         LDKRoute ret = *owner->contents.result;
2656         ret.is_owned = false;
2657         return ret;
2658 }
2659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2660         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2661         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
2662         int64_t ret_ref = 0;
2663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2664         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2665         return ret_ref;
2666 }
2667
2668 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2669 CHECK(!owner->result_ok);
2670         return DecodeError_clone(&*owner->contents.err);
2671 }
2672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2673         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2674         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2675         *ret_copy = CResult_RouteDecodeErrorZ_get_err(owner_conv);
2676         int64_t ret_ref = tag_ptr(ret_copy, true);
2677         return ret_ref;
2678 }
2679
2680 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2681         LDKRouteParameters ret = *owner->contents.result;
2682         ret.is_owned = false;
2683         return ret;
2684 }
2685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2686         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2687         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
2688         int64_t ret_ref = 0;
2689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2690         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2691         return ret_ref;
2692 }
2693
2694 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2695 CHECK(!owner->result_ok);
2696         return DecodeError_clone(&*owner->contents.err);
2697 }
2698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2699         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2700         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2701         *ret_copy = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
2702         int64_t ret_ref = tag_ptr(ret_copy, true);
2703         return ret_ref;
2704 }
2705
2706 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
2707         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
2708         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
2709         return ret;
2710 }
2711 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2712         LDKPaymentParameters ret = *owner->contents.result;
2713         ret.is_owned = false;
2714         return ret;
2715 }
2716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2717         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2718         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
2719         int64_t ret_ref = 0;
2720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2721         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2722         return ret_ref;
2723 }
2724
2725 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2726 CHECK(!owner->result_ok);
2727         return DecodeError_clone(&*owner->contents.err);
2728 }
2729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2730         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2731         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2732         *ret_copy = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
2733         int64_t ret_ref = tag_ptr(ret_copy, true);
2734         return ret_ref;
2735 }
2736
2737 static inline struct LDKBlindedPayInfo C2Tuple_BlindedPayInfoBlindedPathZ_get_a(LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR owner){
2738         LDKBlindedPayInfo ret = owner->a;
2739         ret.is_owned = false;
2740         return ret;
2741 }
2742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlindedPayInfoBlindedPathZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
2743         LDKC2Tuple_BlindedPayInfoBlindedPathZ* owner_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(owner);
2744         LDKBlindedPayInfo ret_var = C2Tuple_BlindedPayInfoBlindedPathZ_get_a(owner_conv);
2745         int64_t ret_ref = 0;
2746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2747         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2748         return ret_ref;
2749 }
2750
2751 static inline struct LDKBlindedPath C2Tuple_BlindedPayInfoBlindedPathZ_get_b(LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR owner){
2752         LDKBlindedPath ret = owner->b;
2753         ret.is_owned = false;
2754         return ret;
2755 }
2756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlindedPayInfoBlindedPathZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
2757         LDKC2Tuple_BlindedPayInfoBlindedPathZ* owner_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(owner);
2758         LDKBlindedPath ret_var = C2Tuple_BlindedPayInfoBlindedPathZ_get_b(owner_conv);
2759         int64_t ret_ref = 0;
2760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2762         return ret_ref;
2763 }
2764
2765 static inline LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_clone(const LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ *orig) {
2766         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ) * orig->datalen, "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ clone bytes"), .datalen = orig->datalen };
2767         for (size_t i = 0; i < ret.datalen; i++) {
2768                 ret.data[i] = C2Tuple_BlindedPayInfoBlindedPathZ_clone(&orig->data[i]);
2769         }
2770         return ret;
2771 }
2772 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2773         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2774         for (size_t i = 0; i < ret.datalen; i++) {
2775                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2776         }
2777         return ret;
2778 }
2779 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
2780         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
2781         for (size_t i = 0; i < ret.datalen; i++) {
2782                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
2783         }
2784         return ret;
2785 }
2786 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2787         LDKRouteHint ret = *owner->contents.result;
2788         ret.is_owned = false;
2789         return ret;
2790 }
2791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2792         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2793         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
2794         int64_t ret_ref = 0;
2795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2796         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2797         return ret_ref;
2798 }
2799
2800 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2801 CHECK(!owner->result_ok);
2802         return DecodeError_clone(&*owner->contents.err);
2803 }
2804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2805         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2806         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2807         *ret_copy = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
2808         int64_t ret_ref = tag_ptr(ret_copy, true);
2809         return ret_ref;
2810 }
2811
2812 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2813         LDKRouteHintHop ret = *owner->contents.result;
2814         ret.is_owned = false;
2815         return ret;
2816 }
2817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2818         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2819         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
2820         int64_t ret_ref = 0;
2821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2822         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2823         return ret_ref;
2824 }
2825
2826 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2827 CHECK(!owner->result_ok);
2828         return DecodeError_clone(&*owner->contents.err);
2829 }
2830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2831         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2832         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2833         *ret_copy = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
2834         int64_t ret_ref = tag_ptr(ret_copy, true);
2835         return ret_ref;
2836 }
2837
2838 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2839         return owner->a;
2840 }
2841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
2842         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
2843         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
2844         return ret_conv;
2845 }
2846
2847 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2848         return owner->b;
2849 }
2850 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
2851         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
2852         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
2853         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2854         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2855         return ret_arr;
2856 }
2857
2858 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
2859         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
2860         for (size_t i = 0; i < ret.datalen; i++) {
2861                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
2862         }
2863         return ret;
2864 }
2865 static inline struct LDKThirtyTwoBytes C2Tuple_TxidBlockHashZ_get_a(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR owner){
2866         return ThirtyTwoBytes_clone(&owner->a);
2867 }
2868 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
2869         LDKC2Tuple_TxidBlockHashZ* owner_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(owner);
2870         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2871         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidBlockHashZ_get_a(owner_conv).data);
2872         return ret_arr;
2873 }
2874
2875 static inline struct LDKThirtyTwoBytes C2Tuple_TxidBlockHashZ_get_b(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR owner){
2876         return ThirtyTwoBytes_clone(&owner->b);
2877 }
2878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
2879         LDKC2Tuple_TxidBlockHashZ* owner_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(owner);
2880         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2881         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidBlockHashZ_get_b(owner_conv).data);
2882         return ret_arr;
2883 }
2884
2885 static inline LDKCVec_C2Tuple_TxidBlockHashZZ CVec_C2Tuple_TxidBlockHashZZ_clone(const LDKCVec_C2Tuple_TxidBlockHashZZ *orig) {
2886         LDKCVec_C2Tuple_TxidBlockHashZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ) * orig->datalen, "LDKCVec_C2Tuple_TxidBlockHashZZ clone bytes"), .datalen = orig->datalen };
2887         for (size_t i = 0; i < ret.datalen; i++) {
2888                 ret.data[i] = C2Tuple_TxidBlockHashZ_clone(&orig->data[i]);
2889         }
2890         return ret;
2891 }
2892 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
2893 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
2894 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
2895 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
2896 static jclass LDKMonitorEvent_Completed_class = NULL;
2897 static jmethodID LDKMonitorEvent_Completed_meth = NULL;
2898 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
2899 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
2900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
2901         LDKMonitorEvent_HTLCEvent_class =
2902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
2903         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
2904         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
2905         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
2906         LDKMonitorEvent_CommitmentTxConfirmed_class =
2907                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
2908         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
2909         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
2910         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
2911         LDKMonitorEvent_Completed_class =
2912                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$Completed"));
2913         CHECK(LDKMonitorEvent_Completed_class != NULL);
2914         LDKMonitorEvent_Completed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_Completed_class, "<init>", "(JJ)V");
2915         CHECK(LDKMonitorEvent_Completed_meth != NULL);
2916         LDKMonitorEvent_UpdateFailed_class =
2917                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
2918         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
2919         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
2920         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
2921 }
2922 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2923         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
2924         switch(obj->tag) {
2925                 case LDKMonitorEvent_HTLCEvent: {
2926                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
2927                         int64_t htlc_event_ref = 0;
2928                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
2929                         htlc_event_ref = tag_ptr(htlc_event_var.inner, false);
2930                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
2931                 }
2932                 case LDKMonitorEvent_CommitmentTxConfirmed: {
2933                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
2934                         int64_t commitment_tx_confirmed_ref = 0;
2935                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
2936                         commitment_tx_confirmed_ref = tag_ptr(commitment_tx_confirmed_var.inner, false);
2937                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
2938                 }
2939                 case LDKMonitorEvent_Completed: {
2940                         LDKOutPoint funding_txo_var = obj->completed.funding_txo;
2941                         int64_t funding_txo_ref = 0;
2942                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2943                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
2944                         int64_t monitor_update_id_conv = obj->completed.monitor_update_id;
2945                         return (*env)->NewObject(env, LDKMonitorEvent_Completed_class, LDKMonitorEvent_Completed_meth, funding_txo_ref, monitor_update_id_conv);
2946                 }
2947                 case LDKMonitorEvent_UpdateFailed: {
2948                         LDKOutPoint update_failed_var = obj->update_failed;
2949                         int64_t update_failed_ref = 0;
2950                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
2951                         update_failed_ref = tag_ptr(update_failed_var.inner, false);
2952                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
2953                 }
2954                 default: abort();
2955         }
2956 }
2957 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
2958         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
2959         for (size_t i = 0; i < ret.datalen; i++) {
2960                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
2961         }
2962         return ret;
2963 }
2964 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2965         LDKOutPoint ret = owner->a;
2966         ret.is_owned = false;
2967         return ret;
2968 }
2969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
2970         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
2971         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
2972         int64_t ret_ref = 0;
2973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2974         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2975         return ret_ref;
2976 }
2977
2978 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2979         return CVec_MonitorEventZ_clone(&owner->b);
2980 }
2981 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
2982         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
2983         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
2984         int64_tArray ret_arr = NULL;
2985         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
2986         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
2987         for (size_t o = 0; o < ret_var.datalen; o++) {
2988                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2989                 *ret_conv_14_copy = ret_var.data[o];
2990                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
2991                 ret_arr_ptr[o] = ret_conv_14_ref;
2992         }
2993         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
2994         FREE(ret_var.data);
2995         return ret_arr;
2996 }
2997
2998 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2999         return owner->c;
3000 }
3001 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
3002         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3003         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3004         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form);
3005         return ret_arr;
3006 }
3007
3008 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
3009         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
3010         for (size_t i = 0; i < ret.datalen; i++) {
3011                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
3012         }
3013         return ret;
3014 }
3015 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3016         LDKFixedPenaltyScorer ret = *owner->contents.result;
3017         ret.is_owned = false;
3018         return ret;
3019 }
3020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3021         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3022         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3023         int64_t ret_ref = 0;
3024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3025         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3026         return ret_ref;
3027 }
3028
3029 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3030 CHECK(!owner->result_ok);
3031         return DecodeError_clone(&*owner->contents.err);
3032 }
3033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3034         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3035         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3036         *ret_copy = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3037         int64_t ret_ref = tag_ptr(ret_copy, true);
3038         return ret_ref;
3039 }
3040
3041 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3042         return owner->a;
3043 }
3044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3045         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
3046         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
3047         return ret_conv;
3048 }
3049
3050 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3051         return owner->b;
3052 }
3053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3054         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
3055         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
3056         return ret_conv;
3057 }
3058
3059 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
3060 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
3061 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
3062 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
3063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
3064         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
3065                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
3066         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
3067         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
3068         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
3069         LDKCOption_C2Tuple_u64u64ZZ_None_class =
3070                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
3071         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
3072         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
3073         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
3074 }
3075 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3076         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
3077         switch(obj->tag) {
3078                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
3079                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
3080                         *some_conv = obj->some;
3081                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
3082                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, tag_ptr(some_conv, true));
3083                 }
3084                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
3085                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
3086                 }
3087                 default: abort();
3088         }
3089 }
3090 static inline struct LDKEightU16s C2Tuple_Z_get_a(LDKC2Tuple_Z *NONNULL_PTR owner){
3091         return owner->a;
3092 }
3093 JNIEXPORT int16_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3094         LDKC2Tuple_Z* owner_conv = (LDKC2Tuple_Z*)untag_ptr(owner);
3095         int16_tArray ret_arr = (*env)->NewShortArray(env, 8);
3096         (*env)->SetShortArrayRegion(env, ret_arr, 0, 8, C2Tuple_Z_get_a(owner_conv).data);
3097         return ret_arr;
3098 }
3099
3100 static inline struct LDKEightU16s C2Tuple_Z_get_b(LDKC2Tuple_Z *NONNULL_PTR owner){
3101         return owner->b;
3102 }
3103 JNIEXPORT int16_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3104         LDKC2Tuple_Z* owner_conv = (LDKC2Tuple_Z*)untag_ptr(owner);
3105         int16_tArray ret_arr = (*env)->NewShortArray(env, 8);
3106         (*env)->SetShortArrayRegion(env, ret_arr, 0, 8, C2Tuple_Z_get_b(owner_conv).data);
3107         return ret_arr;
3108 }
3109
3110 static inline struct LDKEightU16s C2Tuple__u168_u168Z_get_a(LDKC2Tuple__u168_u168Z *NONNULL_PTR owner){
3111         return owner->a;
3112 }
3113 JNIEXPORT int16_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3114         LDKC2Tuple__u168_u168Z* owner_conv = (LDKC2Tuple__u168_u168Z*)untag_ptr(owner);
3115         int16_tArray ret_arr = (*env)->NewShortArray(env, 8);
3116         (*env)->SetShortArrayRegion(env, ret_arr, 0, 8, C2Tuple__u168_u168Z_get_a(owner_conv).data);
3117         return ret_arr;
3118 }
3119
3120 static inline struct LDKEightU16s C2Tuple__u168_u168Z_get_b(LDKC2Tuple__u168_u168Z *NONNULL_PTR owner){
3121         return owner->b;
3122 }
3123 JNIEXPORT int16_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3124         LDKC2Tuple__u168_u168Z* owner_conv = (LDKC2Tuple__u168_u168Z*)untag_ptr(owner);
3125         int16_tArray ret_arr = (*env)->NewShortArray(env, 8);
3126         (*env)->SetShortArrayRegion(env, ret_arr, 0, 8, C2Tuple__u168_u168Z_get_b(owner_conv).data);
3127         return ret_arr;
3128 }
3129
3130 static jclass LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class = NULL;
3131 static jmethodID LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_meth = NULL;
3132 static jclass LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class = NULL;
3133 static jmethodID LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_meth = NULL;
3134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1EightU16sEightU16sZZ_init (JNIEnv *env, jclass clz) {
3135         LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class =
3136                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_EightU16sEightU16sZZ$Some"));
3137         CHECK(LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class != NULL);
3138         LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class, "<init>", "(J)V");
3139         CHECK(LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_meth != NULL);
3140         LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class =
3141                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_EightU16sEightU16sZZ$None"));
3142         CHECK(LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class != NULL);
3143         LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class, "<init>", "()V");
3144         CHECK(LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_meth != NULL);
3145 }
3146 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1EightU16sEightU16sZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3147         LDKCOption_C2Tuple_EightU16sEightU16sZZ *obj = (LDKCOption_C2Tuple_EightU16sEightU16sZZ*)untag_ptr(ptr);
3148         switch(obj->tag) {
3149                 case LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some: {
3150                         LDKC2Tuple__u168_u168Z* some_conv = MALLOC(sizeof(LDKC2Tuple__u168_u168Z), "LDKC2Tuple__u168_u168Z");
3151                         *some_conv = obj->some;
3152                         *some_conv = C2Tuple__u168_u168Z_clone(some_conv);
3153                         return (*env)->NewObject(env, LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_class, LDKCOption_C2Tuple_EightU16sEightU16sZZ_Some_meth, tag_ptr(some_conv, true));
3154                 }
3155                 case LDKCOption_C2Tuple_EightU16sEightU16sZZ_None: {
3156                         return (*env)->NewObject(env, LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_class, LDKCOption_C2Tuple_EightU16sEightU16sZZ_None_meth);
3157                 }
3158                 default: abort();
3159         }
3160 }
3161 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
3162         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
3163         for (size_t i = 0; i < ret.datalen; i++) {
3164                 ret.data[i] = NodeId_clone(&orig->data[i]);
3165         }
3166         return ret;
3167 }
3168 typedef struct LDKLogger_JCalls {
3169         atomic_size_t refcnt;
3170         JavaVM *vm;
3171         jweak o;
3172         jmethodID log_meth;
3173 } LDKLogger_JCalls;
3174 static void LDKLogger_JCalls_free(void* this_arg) {
3175         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3176         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3177                 JNIEnv *env;
3178                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3179                 if (get_jenv_res == JNI_EDETACHED) {
3180                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3181                 } else {
3182                         DO_ASSERT(get_jenv_res == JNI_OK);
3183                 }
3184                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3185                 if (get_jenv_res == JNI_EDETACHED) {
3186                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3187                 }
3188                 FREE(j_calls);
3189         }
3190 }
3191 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
3192         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3193         JNIEnv *env;
3194         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3195         if (get_jenv_res == JNI_EDETACHED) {
3196                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3197         } else {
3198                 DO_ASSERT(get_jenv_res == JNI_OK);
3199         }
3200         LDKRecord record_var = *record;
3201         int64_t record_ref = 0;
3202         record_var = Record_clone(&record_var);
3203         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
3204         record_ref = tag_ptr(record_var.inner, record_var.is_owned);
3205         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3206         CHECK(obj != NULL);
3207         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
3208         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3209                 (*env)->ExceptionDescribe(env);
3210                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
3211         }
3212         if (get_jenv_res == JNI_EDETACHED) {
3213                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3214         }
3215 }
3216 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3217         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3218         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3219 }
3220 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3221         jclass c = (*env)->GetObjectClass(env, o);
3222         CHECK(c != NULL);
3223         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3224         atomic_init(&calls->refcnt, 1);
3225         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3226         calls->o = (*env)->NewWeakGlobalRef(env, o);
3227         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
3228         CHECK(calls->log_meth != NULL);
3229
3230         LDKLogger ret = {
3231                 .this_arg = (void*) calls,
3232                 .log = log_LDKLogger_jcall,
3233                 .free = LDKLogger_JCalls_free,
3234         };
3235         return ret;
3236 }
3237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3238         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3239         *res_ptr = LDKLogger_init(env, clz, o);
3240         return tag_ptr(res_ptr, true);
3241 }
3242 static inline struct LDKProbabilisticScorer CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3243         LDKProbabilisticScorer ret = *owner->contents.result;
3244         ret.is_owned = false;
3245         return ret;
3246 }
3247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3248         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
3249         LDKProbabilisticScorer ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3250         int64_t ret_ref = 0;
3251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3252         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3253         return ret_ref;
3254 }
3255
3256 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3257 CHECK(!owner->result_ok);
3258         return DecodeError_clone(&*owner->contents.err);
3259 }
3260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3261         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
3262         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3263         *ret_copy = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3264         int64_t ret_ref = tag_ptr(ret_copy, true);
3265         return ret_ref;
3266 }
3267
3268 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3269         LDKInitFeatures ret = *owner->contents.result;
3270         ret.is_owned = false;
3271         return ret;
3272 }
3273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3274         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
3275         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3276         int64_t ret_ref = 0;
3277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3278         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3279         return ret_ref;
3280 }
3281
3282 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3283 CHECK(!owner->result_ok);
3284         return DecodeError_clone(&*owner->contents.err);
3285 }
3286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3287         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
3288         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3289         *ret_copy = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3290         int64_t ret_ref = tag_ptr(ret_copy, true);
3291         return ret_ref;
3292 }
3293
3294 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3295         LDKChannelFeatures ret = *owner->contents.result;
3296         ret.is_owned = false;
3297         return ret;
3298 }
3299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3300         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
3301         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3302         int64_t ret_ref = 0;
3303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3304         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3305         return ret_ref;
3306 }
3307
3308 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3309 CHECK(!owner->result_ok);
3310         return DecodeError_clone(&*owner->contents.err);
3311 }
3312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3313         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
3314         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3315         *ret_copy = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3316         int64_t ret_ref = tag_ptr(ret_copy, true);
3317         return ret_ref;
3318 }
3319
3320 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3321         LDKNodeFeatures ret = *owner->contents.result;
3322         ret.is_owned = false;
3323         return ret;
3324 }
3325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3326         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
3327         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3328         int64_t ret_ref = 0;
3329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3330         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3331         return ret_ref;
3332 }
3333
3334 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3335 CHECK(!owner->result_ok);
3336         return DecodeError_clone(&*owner->contents.err);
3337 }
3338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3339         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
3340         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3341         *ret_copy = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3342         int64_t ret_ref = tag_ptr(ret_copy, true);
3343         return ret_ref;
3344 }
3345
3346 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3347         LDKInvoiceFeatures ret = *owner->contents.result;
3348         ret.is_owned = false;
3349         return ret;
3350 }
3351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3352         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3353         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3354         int64_t ret_ref = 0;
3355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3356         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3357         return ret_ref;
3358 }
3359
3360 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3361 CHECK(!owner->result_ok);
3362         return DecodeError_clone(&*owner->contents.err);
3363 }
3364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3365         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3366         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3367         *ret_copy = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3368         int64_t ret_ref = tag_ptr(ret_copy, true);
3369         return ret_ref;
3370 }
3371
3372 static inline struct LDKBlindedHopFeatures CResult_BlindedHopFeaturesDecodeErrorZ_get_ok(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR owner){
3373         LDKBlindedHopFeatures ret = *owner->contents.result;
3374         ret.is_owned = false;
3375         return ret;
3376 }
3377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3378         LDKCResult_BlindedHopFeaturesDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(owner);
3379         LDKBlindedHopFeatures ret_var = CResult_BlindedHopFeaturesDecodeErrorZ_get_ok(owner_conv);
3380         int64_t ret_ref = 0;
3381         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3382         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3383         return ret_ref;
3384 }
3385
3386 static inline struct LDKDecodeError CResult_BlindedHopFeaturesDecodeErrorZ_get_err(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR owner){
3387 CHECK(!owner->result_ok);
3388         return DecodeError_clone(&*owner->contents.err);
3389 }
3390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3391         LDKCResult_BlindedHopFeaturesDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(owner);
3392         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3393         *ret_copy = CResult_BlindedHopFeaturesDecodeErrorZ_get_err(owner_conv);
3394         int64_t ret_ref = tag_ptr(ret_copy, true);
3395         return ret_ref;
3396 }
3397
3398 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3399         LDKChannelTypeFeatures ret = *owner->contents.result;
3400         ret.is_owned = false;
3401         return ret;
3402 }
3403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3404         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
3405         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3406         int64_t ret_ref = 0;
3407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3408         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3409         return ret_ref;
3410 }
3411
3412 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3413 CHECK(!owner->result_ok);
3414         return DecodeError_clone(&*owner->contents.err);
3415 }
3416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3417         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
3418         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3419         *ret_copy = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3420         int64_t ret_ref = tag_ptr(ret_copy, true);
3421         return ret_ref;
3422 }
3423
3424 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
3425 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
3426 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
3427 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
3428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
3429         LDKPaymentPurpose_InvoicePayment_class =
3430                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
3431         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
3432         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
3433         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
3434         LDKPaymentPurpose_SpontaneousPayment_class =
3435                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
3436         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
3437         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
3438         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
3439 }
3440 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3441         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
3442         switch(obj->tag) {
3443                 case LDKPaymentPurpose_InvoicePayment: {
3444                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
3445                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
3446                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
3447                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
3448                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
3449                 }
3450                 case LDKPaymentPurpose_SpontaneousPayment: {
3451                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
3452                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
3453                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
3454                 }
3455                 default: abort();
3456         }
3457 }
3458 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
3459 CHECK(owner->result_ok);
3460         return PaymentPurpose_clone(&*owner->contents.result);
3461 }
3462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3463         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
3464         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
3465         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
3466         int64_t ret_ref = tag_ptr(ret_copy, true);
3467         return ret_ref;
3468 }
3469
3470 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
3471 CHECK(!owner->result_ok);
3472         return DecodeError_clone(&*owner->contents.err);
3473 }
3474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3475         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
3476         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3477         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
3478         int64_t ret_ref = tag_ptr(ret_copy, true);
3479         return ret_ref;
3480 }
3481
3482 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
3483 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
3484 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
3485 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
3486 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
3487 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
3488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
3489         LDKNetworkUpdate_ChannelUpdateMessage_class =
3490                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
3491         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
3492         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
3493         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
3494         LDKNetworkUpdate_ChannelFailure_class =
3495                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
3496         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
3497         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
3498         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
3499         LDKNetworkUpdate_NodeFailure_class =
3500                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
3501         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
3502         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
3503         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
3504 }
3505 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3506         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3507         switch(obj->tag) {
3508                 case LDKNetworkUpdate_ChannelUpdateMessage: {
3509                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
3510                         int64_t msg_ref = 0;
3511                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3512                         msg_ref = tag_ptr(msg_var.inner, false);
3513                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
3514                 }
3515                 case LDKNetworkUpdate_ChannelFailure: {
3516                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
3517                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
3518                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
3519                 }
3520                 case LDKNetworkUpdate_NodeFailure: {
3521                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3522                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
3523                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
3524                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
3525                 }
3526                 default: abort();
3527         }
3528 }
3529 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
3530 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
3531 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
3532 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
3533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
3534         LDKCOption_NetworkUpdateZ_Some_class =
3535                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
3536         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
3537         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
3538         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
3539         LDKCOption_NetworkUpdateZ_None_class =
3540                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
3541         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
3542         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
3543         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
3544 }
3545 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3546         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
3547         switch(obj->tag) {
3548                 case LDKCOption_NetworkUpdateZ_Some: {
3549                         int64_t some_ref = tag_ptr(&obj->some, false);
3550                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
3551                 }
3552                 case LDKCOption_NetworkUpdateZ_None: {
3553                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
3554                 }
3555                 default: abort();
3556         }
3557 }
3558 static jclass LDKPathFailure_InitialSend_class = NULL;
3559 static jmethodID LDKPathFailure_InitialSend_meth = NULL;
3560 static jclass LDKPathFailure_OnPath_class = NULL;
3561 static jmethodID LDKPathFailure_OnPath_meth = NULL;
3562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPathFailure_init (JNIEnv *env, jclass clz) {
3563         LDKPathFailure_InitialSend_class =
3564                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPathFailure$InitialSend"));
3565         CHECK(LDKPathFailure_InitialSend_class != NULL);
3566         LDKPathFailure_InitialSend_meth = (*env)->GetMethodID(env, LDKPathFailure_InitialSend_class, "<init>", "(J)V");
3567         CHECK(LDKPathFailure_InitialSend_meth != NULL);
3568         LDKPathFailure_OnPath_class =
3569                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPathFailure$OnPath"));
3570         CHECK(LDKPathFailure_OnPath_class != NULL);
3571         LDKPathFailure_OnPath_meth = (*env)->GetMethodID(env, LDKPathFailure_OnPath_class, "<init>", "(J)V");
3572         CHECK(LDKPathFailure_OnPath_meth != NULL);
3573 }
3574 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPathFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3575         LDKPathFailure *obj = (LDKPathFailure*)untag_ptr(ptr);
3576         switch(obj->tag) {
3577                 case LDKPathFailure_InitialSend: {
3578                         int64_t err_ref = tag_ptr(&obj->initial_send.err, false);
3579                         return (*env)->NewObject(env, LDKPathFailure_InitialSend_class, LDKPathFailure_InitialSend_meth, err_ref);
3580                 }
3581                 case LDKPathFailure_OnPath: {
3582                         int64_t network_update_ref = tag_ptr(&obj->on_path.network_update, false);
3583                         return (*env)->NewObject(env, LDKPathFailure_OnPath_class, LDKPathFailure_OnPath_meth, network_update_ref);
3584                 }
3585                 default: abort();
3586         }
3587 }
3588 static jclass LDKCOption_PathFailureZ_Some_class = NULL;
3589 static jmethodID LDKCOption_PathFailureZ_Some_meth = NULL;
3590 static jclass LDKCOption_PathFailureZ_None_class = NULL;
3591 static jmethodID LDKCOption_PathFailureZ_None_meth = NULL;
3592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1PathFailureZ_init (JNIEnv *env, jclass clz) {
3593         LDKCOption_PathFailureZ_Some_class =
3594                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_PathFailureZ$Some"));
3595         CHECK(LDKCOption_PathFailureZ_Some_class != NULL);
3596         LDKCOption_PathFailureZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_PathFailureZ_Some_class, "<init>", "(J)V");
3597         CHECK(LDKCOption_PathFailureZ_Some_meth != NULL);
3598         LDKCOption_PathFailureZ_None_class =
3599                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_PathFailureZ$None"));
3600         CHECK(LDKCOption_PathFailureZ_None_class != NULL);
3601         LDKCOption_PathFailureZ_None_meth = (*env)->GetMethodID(env, LDKCOption_PathFailureZ_None_class, "<init>", "()V");
3602         CHECK(LDKCOption_PathFailureZ_None_meth != NULL);
3603 }
3604 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1PathFailureZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3605         LDKCOption_PathFailureZ *obj = (LDKCOption_PathFailureZ*)untag_ptr(ptr);
3606         switch(obj->tag) {
3607                 case LDKCOption_PathFailureZ_Some: {
3608                         int64_t some_ref = tag_ptr(&obj->some, false);
3609                         return (*env)->NewObject(env, LDKCOption_PathFailureZ_Some_class, LDKCOption_PathFailureZ_Some_meth, some_ref);
3610                 }
3611                 case LDKCOption_PathFailureZ_None: {
3612                         return (*env)->NewObject(env, LDKCOption_PathFailureZ_None_class, LDKCOption_PathFailureZ_None_meth);
3613                 }
3614                 default: abort();
3615         }
3616 }
3617 static inline struct LDKCOption_PathFailureZ CResult_COption_PathFailureZDecodeErrorZ_get_ok(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR owner){
3618 CHECK(owner->result_ok);
3619         return COption_PathFailureZ_clone(&*owner->contents.result);
3620 }
3621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3622         LDKCResult_COption_PathFailureZDecodeErrorZ* owner_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(owner);
3623         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
3624         *ret_copy = CResult_COption_PathFailureZDecodeErrorZ_get_ok(owner_conv);
3625         int64_t ret_ref = tag_ptr(ret_copy, true);
3626         return ret_ref;
3627 }
3628
3629 static inline struct LDKDecodeError CResult_COption_PathFailureZDecodeErrorZ_get_err(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR owner){
3630 CHECK(!owner->result_ok);
3631         return DecodeError_clone(&*owner->contents.err);
3632 }
3633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3634         LDKCResult_COption_PathFailureZDecodeErrorZ* owner_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(owner);
3635         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3636         *ret_copy = CResult_COption_PathFailureZDecodeErrorZ_get_err(owner_conv);
3637         int64_t ret_ref = tag_ptr(ret_copy, true);
3638         return ret_ref;
3639 }
3640
3641 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
3642 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
3643 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
3644 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
3645 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
3646 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
3647 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
3648 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
3649 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
3650 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
3651 static jclass LDKClosureReason_ProcessingError_class = NULL;
3652 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
3653 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
3654 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
3655 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
3656 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
3657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
3658         LDKClosureReason_CounterpartyForceClosed_class =
3659                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
3660         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
3661         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(J)V");
3662         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
3663         LDKClosureReason_HolderForceClosed_class =
3664                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
3665         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
3666         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
3667         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
3668         LDKClosureReason_CooperativeClosure_class =
3669                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
3670         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
3671         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
3672         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
3673         LDKClosureReason_CommitmentTxConfirmed_class =
3674                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
3675         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
3676         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
3677         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
3678         LDKClosureReason_FundingTimedOut_class =
3679                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
3680         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
3681         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
3682         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
3683         LDKClosureReason_ProcessingError_class =
3684                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
3685         CHECK(LDKClosureReason_ProcessingError_class != NULL);
3686         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
3687         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
3688         LDKClosureReason_DisconnectedPeer_class =
3689                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
3690         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
3691         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
3692         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
3693         LDKClosureReason_OutdatedChannelManager_class =
3694                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
3695         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
3696         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
3697         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
3698 }
3699 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3700         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
3701         switch(obj->tag) {
3702                 case LDKClosureReason_CounterpartyForceClosed: {
3703                         LDKUntrustedString peer_msg_var = obj->counterparty_force_closed.peer_msg;
3704                         int64_t peer_msg_ref = 0;
3705                         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_msg_var);
3706                         peer_msg_ref = tag_ptr(peer_msg_var.inner, false);
3707                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_ref);
3708                 }
3709                 case LDKClosureReason_HolderForceClosed: {
3710                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
3711                 }
3712                 case LDKClosureReason_CooperativeClosure: {
3713                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
3714                 }
3715                 case LDKClosureReason_CommitmentTxConfirmed: {
3716                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
3717                 }
3718                 case LDKClosureReason_FundingTimedOut: {
3719                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
3720                 }
3721                 case LDKClosureReason_ProcessingError: {
3722                         LDKStr err_str = obj->processing_error.err;
3723                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3724                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
3725                 }
3726                 case LDKClosureReason_DisconnectedPeer: {
3727                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
3728                 }
3729                 case LDKClosureReason_OutdatedChannelManager: {
3730                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
3731                 }
3732                 default: abort();
3733         }
3734 }
3735 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
3736 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
3737 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
3738 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
3739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
3740         LDKCOption_ClosureReasonZ_Some_class =
3741                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
3742         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
3743         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
3744         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
3745         LDKCOption_ClosureReasonZ_None_class =
3746                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
3747         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
3748         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
3749         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
3750 }
3751 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3752         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
3753         switch(obj->tag) {
3754                 case LDKCOption_ClosureReasonZ_Some: {
3755                         int64_t some_ref = tag_ptr(&obj->some, false);
3756                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
3757                 }
3758                 case LDKCOption_ClosureReasonZ_None: {
3759                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
3760                 }
3761                 default: abort();
3762         }
3763 }
3764 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
3765 CHECK(owner->result_ok);
3766         return COption_ClosureReasonZ_clone(&*owner->contents.result);
3767 }
3768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3769         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
3770         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
3771         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
3772         int64_t ret_ref = tag_ptr(ret_copy, true);
3773         return ret_ref;
3774 }
3775
3776 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
3777 CHECK(!owner->result_ok);
3778         return DecodeError_clone(&*owner->contents.err);
3779 }
3780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3781         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
3782         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3783         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
3784         int64_t ret_ref = tag_ptr(ret_copy, true);
3785         return ret_ref;
3786 }
3787
3788 static jclass LDKHTLCDestination_NextHopChannel_class = NULL;
3789 static jmethodID LDKHTLCDestination_NextHopChannel_meth = NULL;
3790 static jclass LDKHTLCDestination_UnknownNextHop_class = NULL;
3791 static jmethodID LDKHTLCDestination_UnknownNextHop_meth = NULL;
3792 static jclass LDKHTLCDestination_InvalidForward_class = NULL;
3793 static jmethodID LDKHTLCDestination_InvalidForward_meth = NULL;
3794 static jclass LDKHTLCDestination_FailedPayment_class = NULL;
3795 static jmethodID LDKHTLCDestination_FailedPayment_meth = NULL;
3796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCDestination_init (JNIEnv *env, jclass clz) {
3797         LDKHTLCDestination_NextHopChannel_class =
3798                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$NextHopChannel"));
3799         CHECK(LDKHTLCDestination_NextHopChannel_class != NULL);
3800         LDKHTLCDestination_NextHopChannel_meth = (*env)->GetMethodID(env, LDKHTLCDestination_NextHopChannel_class, "<init>", "([B[B)V");
3801         CHECK(LDKHTLCDestination_NextHopChannel_meth != NULL);
3802         LDKHTLCDestination_UnknownNextHop_class =
3803                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$UnknownNextHop"));
3804         CHECK(LDKHTLCDestination_UnknownNextHop_class != NULL);
3805         LDKHTLCDestination_UnknownNextHop_meth = (*env)->GetMethodID(env, LDKHTLCDestination_UnknownNextHop_class, "<init>", "(J)V");
3806         CHECK(LDKHTLCDestination_UnknownNextHop_meth != NULL);
3807         LDKHTLCDestination_InvalidForward_class =
3808                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$InvalidForward"));
3809         CHECK(LDKHTLCDestination_InvalidForward_class != NULL);
3810         LDKHTLCDestination_InvalidForward_meth = (*env)->GetMethodID(env, LDKHTLCDestination_InvalidForward_class, "<init>", "(J)V");
3811         CHECK(LDKHTLCDestination_InvalidForward_meth != NULL);
3812         LDKHTLCDestination_FailedPayment_class =
3813                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$FailedPayment"));
3814         CHECK(LDKHTLCDestination_FailedPayment_class != NULL);
3815         LDKHTLCDestination_FailedPayment_meth = (*env)->GetMethodID(env, LDKHTLCDestination_FailedPayment_class, "<init>", "([B)V");
3816         CHECK(LDKHTLCDestination_FailedPayment_meth != NULL);
3817 }
3818 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3819         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
3820         switch(obj->tag) {
3821                 case LDKHTLCDestination_NextHopChannel: {
3822                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3823                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->next_hop_channel.node_id.compressed_form);
3824                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3825                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->next_hop_channel.channel_id.data);
3826                         return (*env)->NewObject(env, LDKHTLCDestination_NextHopChannel_class, LDKHTLCDestination_NextHopChannel_meth, node_id_arr, channel_id_arr);
3827                 }
3828                 case LDKHTLCDestination_UnknownNextHop: {
3829                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
3830                         return (*env)->NewObject(env, LDKHTLCDestination_UnknownNextHop_class, LDKHTLCDestination_UnknownNextHop_meth, requested_forward_scid_conv);
3831                 }
3832                 case LDKHTLCDestination_InvalidForward: {
3833                         int64_t requested_forward_scid_conv = obj->invalid_forward.requested_forward_scid;
3834                         return (*env)->NewObject(env, LDKHTLCDestination_InvalidForward_class, LDKHTLCDestination_InvalidForward_meth, requested_forward_scid_conv);
3835                 }
3836                 case LDKHTLCDestination_FailedPayment: {
3837                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3838                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->failed_payment.payment_hash.data);
3839                         return (*env)->NewObject(env, LDKHTLCDestination_FailedPayment_class, LDKHTLCDestination_FailedPayment_meth, payment_hash_arr);
3840                 }
3841                 default: abort();
3842         }
3843 }
3844 static jclass LDKCOption_HTLCDestinationZ_Some_class = NULL;
3845 static jmethodID LDKCOption_HTLCDestinationZ_Some_meth = NULL;
3846 static jclass LDKCOption_HTLCDestinationZ_None_class = NULL;
3847 static jmethodID LDKCOption_HTLCDestinationZ_None_meth = NULL;
3848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCDestinationZ_init (JNIEnv *env, jclass clz) {
3849         LDKCOption_HTLCDestinationZ_Some_class =
3850                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$Some"));
3851         CHECK(LDKCOption_HTLCDestinationZ_Some_class != NULL);
3852         LDKCOption_HTLCDestinationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_Some_class, "<init>", "(J)V");
3853         CHECK(LDKCOption_HTLCDestinationZ_Some_meth != NULL);
3854         LDKCOption_HTLCDestinationZ_None_class =
3855                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$None"));
3856         CHECK(LDKCOption_HTLCDestinationZ_None_class != NULL);
3857         LDKCOption_HTLCDestinationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_None_class, "<init>", "()V");
3858         CHECK(LDKCOption_HTLCDestinationZ_None_meth != NULL);
3859 }
3860 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCDestinationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3861         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
3862         switch(obj->tag) {
3863                 case LDKCOption_HTLCDestinationZ_Some: {
3864                         int64_t some_ref = tag_ptr(&obj->some, false);
3865                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_Some_class, LDKCOption_HTLCDestinationZ_Some_meth, some_ref);
3866                 }
3867                 case LDKCOption_HTLCDestinationZ_None: {
3868                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_None_class, LDKCOption_HTLCDestinationZ_None_meth);
3869                 }
3870                 default: abort();
3871         }
3872 }
3873 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
3874 CHECK(owner->result_ok);
3875         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
3876 }
3877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3878         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
3879         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
3880         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
3881         int64_t ret_ref = tag_ptr(ret_copy, true);
3882         return ret_ref;
3883 }
3884
3885 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
3886 CHECK(!owner->result_ok);
3887         return DecodeError_clone(&*owner->contents.err);
3888 }
3889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3890         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
3891         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3892         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
3893         int64_t ret_ref = tag_ptr(ret_copy, true);
3894         return ret_ref;
3895 }
3896
3897 static inline enum LDKPaymentFailureReason CResult_PaymentFailureReasonDecodeErrorZ_get_ok(LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR owner){
3898 CHECK(owner->result_ok);
3899         return PaymentFailureReason_clone(&*owner->contents.result);
3900 }
3901 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3902         LDKCResult_PaymentFailureReasonDecodeErrorZ* owner_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(owner);
3903         jclass ret_conv = LDKPaymentFailureReason_to_java(env, CResult_PaymentFailureReasonDecodeErrorZ_get_ok(owner_conv));
3904         return ret_conv;
3905 }
3906
3907 static inline struct LDKDecodeError CResult_PaymentFailureReasonDecodeErrorZ_get_err(LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR owner){
3908 CHECK(!owner->result_ok);
3909         return DecodeError_clone(&*owner->contents.err);
3910 }
3911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3912         LDKCResult_PaymentFailureReasonDecodeErrorZ* owner_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(owner);
3913         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3914         *ret_copy = CResult_PaymentFailureReasonDecodeErrorZ_get_err(owner_conv);
3915         int64_t ret_ref = tag_ptr(ret_copy, true);
3916         return ret_ref;
3917 }
3918
3919 static jclass LDKCOption_u128Z_Some_class = NULL;
3920 static jmethodID LDKCOption_u128Z_Some_meth = NULL;
3921 static jclass LDKCOption_u128Z_None_class = NULL;
3922 static jmethodID LDKCOption_u128Z_None_meth = NULL;
3923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u128Z_init (JNIEnv *env, jclass clz) {
3924         LDKCOption_u128Z_Some_class =
3925                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u128Z$Some"));
3926         CHECK(LDKCOption_u128Z_Some_class != NULL);
3927         LDKCOption_u128Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u128Z_Some_class, "<init>", "([B)V");
3928         CHECK(LDKCOption_u128Z_Some_meth != NULL);
3929         LDKCOption_u128Z_None_class =
3930                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u128Z$None"));
3931         CHECK(LDKCOption_u128Z_None_class != NULL);
3932         LDKCOption_u128Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u128Z_None_class, "<init>", "()V");
3933         CHECK(LDKCOption_u128Z_None_meth != NULL);
3934 }
3935 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u128Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3936         LDKCOption_u128Z *obj = (LDKCOption_u128Z*)untag_ptr(ptr);
3937         switch(obj->tag) {
3938                 case LDKCOption_u128Z_Some: {
3939                         int8_tArray some_arr = (*env)->NewByteArray(env, 16);
3940                         (*env)->SetByteArrayRegion(env, some_arr, 0, 16, obj->some.le_bytes);
3941                         return (*env)->NewObject(env, LDKCOption_u128Z_Some_class, LDKCOption_u128Z_Some_meth, some_arr);
3942                 }
3943                 case LDKCOption_u128Z_None: {
3944                         return (*env)->NewObject(env, LDKCOption_u128Z_None_class, LDKCOption_u128Z_None_meth);
3945                 }
3946                 default: abort();
3947         }
3948 }
3949 static jclass LDKCOption_PaymentFailureReasonZ_Some_class = NULL;
3950 static jmethodID LDKCOption_PaymentFailureReasonZ_Some_meth = NULL;
3951 static jclass LDKCOption_PaymentFailureReasonZ_None_class = NULL;
3952 static jmethodID LDKCOption_PaymentFailureReasonZ_None_meth = NULL;
3953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1PaymentFailureReasonZ_init (JNIEnv *env, jclass clz) {
3954         LDKCOption_PaymentFailureReasonZ_Some_class =
3955                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_PaymentFailureReasonZ$Some"));
3956         CHECK(LDKCOption_PaymentFailureReasonZ_Some_class != NULL);
3957         LDKCOption_PaymentFailureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_PaymentFailureReasonZ_Some_class, "<init>", "(Lorg/ldk/enums/PaymentFailureReason;)V");
3958         CHECK(LDKCOption_PaymentFailureReasonZ_Some_meth != NULL);
3959         LDKCOption_PaymentFailureReasonZ_None_class =
3960                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_PaymentFailureReasonZ$None"));
3961         CHECK(LDKCOption_PaymentFailureReasonZ_None_class != NULL);
3962         LDKCOption_PaymentFailureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_PaymentFailureReasonZ_None_class, "<init>", "()V");
3963         CHECK(LDKCOption_PaymentFailureReasonZ_None_meth != NULL);
3964 }
3965 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1PaymentFailureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3966         LDKCOption_PaymentFailureReasonZ *obj = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(ptr);
3967         switch(obj->tag) {
3968                 case LDKCOption_PaymentFailureReasonZ_Some: {
3969                         jclass some_conv = LDKPaymentFailureReason_to_java(env, obj->some);
3970                         return (*env)->NewObject(env, LDKCOption_PaymentFailureReasonZ_Some_class, LDKCOption_PaymentFailureReasonZ_Some_meth, some_conv);
3971                 }
3972                 case LDKCOption_PaymentFailureReasonZ_None: {
3973                         return (*env)->NewObject(env, LDKCOption_PaymentFailureReasonZ_None_class, LDKCOption_PaymentFailureReasonZ_None_meth);
3974                 }
3975                 default: abort();
3976         }
3977 }
3978 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
3979 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
3980 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
3981 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
3982 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
3983 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
3984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
3985         LDKSpendableOutputDescriptor_StaticOutput_class =
3986                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
3987         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
3988         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
3989         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
3990         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
3991                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
3992         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
3993         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
3994         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
3995         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
3996                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
3997         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
3998         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
3999         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
4000 }
4001 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4002         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
4003         switch(obj->tag) {
4004                 case LDKSpendableOutputDescriptor_StaticOutput: {
4005                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
4006                         int64_t outpoint_ref = 0;
4007                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
4008                         outpoint_ref = tag_ptr(outpoint_var.inner, false);
4009                         LDKTxOut* output_ref = &obj->static_output.output;
4010                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, tag_ptr(output_ref, false));
4011                 }
4012                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
4013                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
4014                         int64_t delayed_payment_output_ref = 0;
4015                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
4016                         delayed_payment_output_ref = tag_ptr(delayed_payment_output_var.inner, false);
4017                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
4018                 }
4019                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
4020                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
4021                         int64_t static_payment_output_ref = 0;
4022                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
4023                         static_payment_output_ref = tag_ptr(static_payment_output_var.inner, false);
4024                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
4025                 }
4026                 default: abort();
4027         }
4028 }
4029 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
4030         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
4031         for (size_t i = 0; i < ret.datalen; i++) {
4032                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
4033         }
4034         return ret;
4035 }
4036 static jclass LDKEvent_FundingGenerationReady_class = NULL;
4037 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
4038 static jclass LDKEvent_PaymentClaimable_class = NULL;
4039 static jmethodID LDKEvent_PaymentClaimable_meth = NULL;
4040 static jclass LDKEvent_PaymentClaimed_class = NULL;
4041 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
4042 static jclass LDKEvent_PaymentSent_class = NULL;
4043 static jmethodID LDKEvent_PaymentSent_meth = NULL;
4044 static jclass LDKEvent_PaymentFailed_class = NULL;
4045 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
4046 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
4047 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
4048 static jclass LDKEvent_PaymentPathFailed_class = NULL;
4049 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
4050 static jclass LDKEvent_ProbeSuccessful_class = NULL;
4051 static jmethodID LDKEvent_ProbeSuccessful_meth = NULL;
4052 static jclass LDKEvent_ProbeFailed_class = NULL;
4053 static jmethodID LDKEvent_ProbeFailed_meth = NULL;
4054 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
4055 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
4056 static jclass LDKEvent_HTLCIntercepted_class = NULL;
4057 static jmethodID LDKEvent_HTLCIntercepted_meth = NULL;
4058 static jclass LDKEvent_SpendableOutputs_class = NULL;
4059 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
4060 static jclass LDKEvent_PaymentForwarded_class = NULL;
4061 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
4062 static jclass LDKEvent_ChannelPending_class = NULL;
4063 static jmethodID LDKEvent_ChannelPending_meth = NULL;
4064 static jclass LDKEvent_ChannelReady_class = NULL;
4065 static jmethodID LDKEvent_ChannelReady_meth = NULL;
4066 static jclass LDKEvent_ChannelClosed_class = NULL;
4067 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
4068 static jclass LDKEvent_DiscardFunding_class = NULL;
4069 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
4070 static jclass LDKEvent_OpenChannelRequest_class = NULL;
4071 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
4072 static jclass LDKEvent_HTLCHandlingFailed_class = NULL;
4073 static jmethodID LDKEvent_HTLCHandlingFailed_meth = NULL;
4074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
4075         LDKEvent_FundingGenerationReady_class =
4076                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
4077         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
4078         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[B[B)V");
4079         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
4080         LDKEvent_PaymentClaimable_class =
4081                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimable"));
4082         CHECK(LDKEvent_PaymentClaimable_class != NULL);
4083         LDKEvent_PaymentClaimable_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimable_class, "<init>", "([B[BJJJ[BJJ)V");
4084         CHECK(LDKEvent_PaymentClaimable_meth != NULL);
4085         LDKEvent_PaymentClaimed_class =
4086                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
4087         CHECK(LDKEvent_PaymentClaimed_class != NULL);
4088         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([B[BJJ)V");
4089         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
4090         LDKEvent_PaymentSent_class =
4091                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
4092         CHECK(LDKEvent_PaymentSent_class != NULL);
4093         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
4094         CHECK(LDKEvent_PaymentSent_meth != NULL);
4095         LDKEvent_PaymentFailed_class =
4096                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
4097         CHECK(LDKEvent_PaymentFailed_class != NULL);
4098         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[BJ)V");
4099         CHECK(LDKEvent_PaymentFailed_meth != NULL);
4100         LDKEvent_PaymentPathSuccessful_class =
4101                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
4102         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
4103         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[BJ)V");
4104         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
4105         LDKEvent_PaymentPathFailed_class =
4106                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
4107         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
4108         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJJJ)V");
4109         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
4110         LDKEvent_ProbeSuccessful_class =
4111                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeSuccessful"));
4112         CHECK(LDKEvent_ProbeSuccessful_class != NULL);
4113         LDKEvent_ProbeSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_ProbeSuccessful_class, "<init>", "([B[BJ)V");
4114         CHECK(LDKEvent_ProbeSuccessful_meth != NULL);
4115         LDKEvent_ProbeFailed_class =
4116                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeFailed"));
4117         CHECK(LDKEvent_ProbeFailed_class != NULL);
4118         LDKEvent_ProbeFailed_meth = (*env)->GetMethodID(env, LDKEvent_ProbeFailed_class, "<init>", "([B[BJJ)V");
4119         CHECK(LDKEvent_ProbeFailed_meth != NULL);
4120         LDKEvent_PendingHTLCsForwardable_class =
4121                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
4122         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
4123         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
4124         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
4125         LDKEvent_HTLCIntercepted_class =
4126                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCIntercepted"));
4127         CHECK(LDKEvent_HTLCIntercepted_class != NULL);
4128         LDKEvent_HTLCIntercepted_meth = (*env)->GetMethodID(env, LDKEvent_HTLCIntercepted_class, "<init>", "([BJ[BJJ)V");
4129         CHECK(LDKEvent_HTLCIntercepted_meth != NULL);
4130         LDKEvent_SpendableOutputs_class =
4131                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
4132         CHECK(LDKEvent_SpendableOutputs_class != NULL);
4133         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
4134         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
4135         LDKEvent_PaymentForwarded_class =
4136                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
4137         CHECK(LDKEvent_PaymentForwarded_class != NULL);
4138         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZJ)V");
4139         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
4140         LDKEvent_ChannelPending_class =
4141                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelPending"));
4142         CHECK(LDKEvent_ChannelPending_class != NULL);
4143         LDKEvent_ChannelPending_meth = (*env)->GetMethodID(env, LDKEvent_ChannelPending_class, "<init>", "([B[B[B[BJ)V");
4144         CHECK(LDKEvent_ChannelPending_meth != NULL);
4145         LDKEvent_ChannelReady_class =
4146                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelReady"));
4147         CHECK(LDKEvent_ChannelReady_class != NULL);
4148         LDKEvent_ChannelReady_meth = (*env)->GetMethodID(env, LDKEvent_ChannelReady_class, "<init>", "([B[B[BJ)V");
4149         CHECK(LDKEvent_ChannelReady_meth != NULL);
4150         LDKEvent_ChannelClosed_class =
4151                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
4152         CHECK(LDKEvent_ChannelClosed_class != NULL);
4153         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([B[BJ)V");
4154         CHECK(LDKEvent_ChannelClosed_meth != NULL);
4155         LDKEvent_DiscardFunding_class =
4156                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
4157         CHECK(LDKEvent_DiscardFunding_class != NULL);
4158         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
4159         CHECK(LDKEvent_DiscardFunding_meth != NULL);
4160         LDKEvent_OpenChannelRequest_class =
4161                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
4162         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
4163         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
4164         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
4165         LDKEvent_HTLCHandlingFailed_class =
4166                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCHandlingFailed"));
4167         CHECK(LDKEvent_HTLCHandlingFailed_class != NULL);
4168         LDKEvent_HTLCHandlingFailed_meth = (*env)->GetMethodID(env, LDKEvent_HTLCHandlingFailed_class, "<init>", "([BJ)V");
4169         CHECK(LDKEvent_HTLCHandlingFailed_meth != NULL);
4170 }
4171 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4172         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
4173         switch(obj->tag) {
4174                 case LDKEvent_FundingGenerationReady: {
4175                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4176                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
4177                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
4178                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
4179                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
4180                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4181                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
4182                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
4183                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
4184                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->funding_generation_ready.user_channel_id.le_bytes);
4185                         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);
4186                 }
4187                 case LDKEvent_PaymentClaimable: {
4188                         int8_tArray receiver_node_id_arr = (*env)->NewByteArray(env, 33);
4189                         (*env)->SetByteArrayRegion(env, receiver_node_id_arr, 0, 33, obj->payment_claimable.receiver_node_id.compressed_form);
4190                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4191                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimable.payment_hash.data);
4192                         LDKRecipientOnionFields onion_fields_var = obj->payment_claimable.onion_fields;
4193                         int64_t onion_fields_ref = 0;
4194                         CHECK_INNER_FIELD_ACCESS_OR_NULL(onion_fields_var);
4195                         onion_fields_ref = tag_ptr(onion_fields_var.inner, false);
4196                         int64_t amount_msat_conv = obj->payment_claimable.amount_msat;
4197                         int64_t purpose_ref = tag_ptr(&obj->payment_claimable.purpose, false);
4198                         int8_tArray via_channel_id_arr = (*env)->NewByteArray(env, 32);
4199                         (*env)->SetByteArrayRegion(env, via_channel_id_arr, 0, 32, obj->payment_claimable.via_channel_id.data);
4200                         int64_t via_user_channel_id_ref = tag_ptr(&obj->payment_claimable.via_user_channel_id, false);
4201                         int64_t claim_deadline_ref = tag_ptr(&obj->payment_claimable.claim_deadline, false);
4202                         return (*env)->NewObject(env, LDKEvent_PaymentClaimable_class, LDKEvent_PaymentClaimable_meth, receiver_node_id_arr, payment_hash_arr, onion_fields_ref, amount_msat_conv, purpose_ref, via_channel_id_arr, via_user_channel_id_ref, claim_deadline_ref);
4203                 }
4204                 case LDKEvent_PaymentClaimed: {
4205                         int8_tArray receiver_node_id_arr = (*env)->NewByteArray(env, 33);
4206                         (*env)->SetByteArrayRegion(env, receiver_node_id_arr, 0, 33, obj->payment_claimed.receiver_node_id.compressed_form);
4207                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4208                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
4209                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
4210                         int64_t purpose_ref = tag_ptr(&obj->payment_claimed.purpose, false);
4211                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, receiver_node_id_arr, payment_hash_arr, amount_msat_conv, purpose_ref);
4212                 }
4213                 case LDKEvent_PaymentSent: {
4214                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4215                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
4216                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4217                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
4218                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4219                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
4220                         int64_t fee_paid_msat_ref = tag_ptr(&obj->payment_sent.fee_paid_msat, false);
4221                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
4222                 }
4223                 case LDKEvent_PaymentFailed: {
4224                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4225                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
4226                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4227                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
4228                         int64_t reason_ref = tag_ptr(&obj->payment_failed.reason, false);
4229                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr, reason_ref);
4230                 }
4231                 case LDKEvent_PaymentPathSuccessful: {
4232                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4233                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
4234                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4235                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
4236                         LDKPath path_var = obj->payment_path_successful.path;
4237                         int64_t path_ref = 0;
4238                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
4239                         path_ref = tag_ptr(path_var.inner, false);
4240                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_ref);
4241                 }
4242                 case LDKEvent_PaymentPathFailed: {
4243                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4244                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
4245                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4246                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
4247                         jboolean payment_failed_permanently_conv = obj->payment_path_failed.payment_failed_permanently;
4248                         int64_t failure_ref = tag_ptr(&obj->payment_path_failed.failure, false);
4249                         LDKPath path_var = obj->payment_path_failed.path;
4250                         int64_t path_ref = 0;
4251                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
4252                         path_ref = tag_ptr(path_var.inner, false);
4253                         int64_t short_channel_id_ref = tag_ptr(&obj->payment_path_failed.short_channel_id, false);
4254                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, payment_failed_permanently_conv, failure_ref, path_ref, short_channel_id_ref);
4255                 }
4256                 case LDKEvent_ProbeSuccessful: {
4257                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4258                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_successful.payment_id.data);
4259                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4260                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_successful.payment_hash.data);
4261                         LDKPath path_var = obj->probe_successful.path;
4262                         int64_t path_ref = 0;
4263                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
4264                         path_ref = tag_ptr(path_var.inner, false);
4265                         return (*env)->NewObject(env, LDKEvent_ProbeSuccessful_class, LDKEvent_ProbeSuccessful_meth, payment_id_arr, payment_hash_arr, path_ref);
4266                 }
4267                 case LDKEvent_ProbeFailed: {
4268                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4269                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_failed.payment_id.data);
4270                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4271                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_failed.payment_hash.data);
4272                         LDKPath path_var = obj->probe_failed.path;
4273                         int64_t path_ref = 0;
4274                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
4275                         path_ref = tag_ptr(path_var.inner, false);
4276                         int64_t short_channel_id_ref = tag_ptr(&obj->probe_failed.short_channel_id, false);
4277                         return (*env)->NewObject(env, LDKEvent_ProbeFailed_class, LDKEvent_ProbeFailed_meth, payment_id_arr, payment_hash_arr, path_ref, short_channel_id_ref);
4278                 }
4279                 case LDKEvent_PendingHTLCsForwardable: {
4280                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
4281                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
4282                 }
4283                 case LDKEvent_HTLCIntercepted: {
4284                         int8_tArray intercept_id_arr = (*env)->NewByteArray(env, 32);
4285                         (*env)->SetByteArrayRegion(env, intercept_id_arr, 0, 32, obj->htlc_intercepted.intercept_id.data);
4286                         int64_t requested_next_hop_scid_conv = obj->htlc_intercepted.requested_next_hop_scid;
4287                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4288                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->htlc_intercepted.payment_hash.data);
4289                         int64_t inbound_amount_msat_conv = obj->htlc_intercepted.inbound_amount_msat;
4290                         int64_t expected_outbound_amount_msat_conv = obj->htlc_intercepted.expected_outbound_amount_msat;
4291                         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);
4292                 }
4293                 case LDKEvent_SpendableOutputs: {
4294                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4295                         int64_tArray outputs_arr = NULL;
4296                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
4297                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
4298                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4299                                 int64_t outputs_conv_27_ref = tag_ptr(&outputs_var.data[b], false);
4300                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4301                         }
4302                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
4303                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
4304                 }
4305                 case LDKEvent_PaymentForwarded: {
4306                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
4307                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
4308                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
4309                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
4310                         int64_t fee_earned_msat_ref = tag_ptr(&obj->payment_forwarded.fee_earned_msat, false);
4311                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
4312                         int64_t outbound_amount_forwarded_msat_ref = tag_ptr(&obj->payment_forwarded.outbound_amount_forwarded_msat, false);
4313                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, prev_channel_id_arr, next_channel_id_arr, fee_earned_msat_ref, claim_from_onchain_tx_conv, outbound_amount_forwarded_msat_ref);
4314                 }
4315                 case LDKEvent_ChannelPending: {
4316                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
4317                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_pending.channel_id.data);
4318                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
4319                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->channel_pending.user_channel_id.le_bytes);
4320                         int8_tArray former_temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4321                         (*env)->SetByteArrayRegion(env, former_temporary_channel_id_arr, 0, 32, obj->channel_pending.former_temporary_channel_id.data);
4322                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
4323                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->channel_pending.counterparty_node_id.compressed_form);
4324                         LDKOutPoint funding_txo_var = obj->channel_pending.funding_txo;
4325                         int64_t funding_txo_ref = 0;
4326                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4327                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
4328                         return (*env)->NewObject(env, LDKEvent_ChannelPending_class, LDKEvent_ChannelPending_meth, channel_id_arr, user_channel_id_arr, former_temporary_channel_id_arr, counterparty_node_id_arr, funding_txo_ref);
4329                 }
4330                 case LDKEvent_ChannelReady: {
4331                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
4332                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_ready.channel_id.data);
4333                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
4334                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->channel_ready.user_channel_id.le_bytes);
4335                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
4336                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->channel_ready.counterparty_node_id.compressed_form);
4337                         LDKChannelTypeFeatures channel_type_var = obj->channel_ready.channel_type;
4338                         int64_t channel_type_ref = 0;
4339                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
4340                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
4341                         return (*env)->NewObject(env, LDKEvent_ChannelReady_class, LDKEvent_ChannelReady_meth, channel_id_arr, user_channel_id_arr, counterparty_node_id_arr, channel_type_ref);
4342                 }
4343                 case LDKEvent_ChannelClosed: {
4344                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
4345                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
4346                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
4347                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->channel_closed.user_channel_id.le_bytes);
4348                         int64_t reason_ref = tag_ptr(&obj->channel_closed.reason, false);
4349                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_arr, reason_ref);
4350                 }
4351                 case LDKEvent_DiscardFunding: {
4352                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
4353                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
4354                         LDKTransaction transaction_var = obj->discard_funding.transaction;
4355                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
4356                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
4357                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
4358                 }
4359                 case LDKEvent_OpenChannelRequest: {
4360                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4361                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
4362                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
4363                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
4364                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
4365                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
4366                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
4367                         int64_t channel_type_ref = 0;
4368                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
4369                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
4370                         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);
4371                 }
4372                 case LDKEvent_HTLCHandlingFailed: {
4373                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
4374                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->htlc_handling_failed.prev_channel_id.data);
4375                         int64_t failed_next_destination_ref = tag_ptr(&obj->htlc_handling_failed.failed_next_destination, false);
4376                         return (*env)->NewObject(env, LDKEvent_HTLCHandlingFailed_class, LDKEvent_HTLCHandlingFailed_meth, prev_channel_id_arr, failed_next_destination_ref);
4377                 }
4378                 default: abort();
4379         }
4380 }
4381 static jclass LDKCOption_EventZ_Some_class = NULL;
4382 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
4383 static jclass LDKCOption_EventZ_None_class = NULL;
4384 static jmethodID LDKCOption_EventZ_None_meth = NULL;
4385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
4386         LDKCOption_EventZ_Some_class =
4387                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
4388         CHECK(LDKCOption_EventZ_Some_class != NULL);
4389         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
4390         CHECK(LDKCOption_EventZ_Some_meth != NULL);
4391         LDKCOption_EventZ_None_class =
4392                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
4393         CHECK(LDKCOption_EventZ_None_class != NULL);
4394         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
4395         CHECK(LDKCOption_EventZ_None_meth != NULL);
4396 }
4397 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4398         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
4399         switch(obj->tag) {
4400                 case LDKCOption_EventZ_Some: {
4401                         int64_t some_ref = tag_ptr(&obj->some, false);
4402                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
4403                 }
4404                 case LDKCOption_EventZ_None: {
4405                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
4406                 }
4407                 default: abort();
4408         }
4409 }
4410 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
4411 CHECK(owner->result_ok);
4412         return COption_EventZ_clone(&*owner->contents.result);
4413 }
4414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4415         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
4416         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
4417         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
4418         int64_t ret_ref = tag_ptr(ret_copy, true);
4419         return ret_ref;
4420 }
4421
4422 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
4423 CHECK(!owner->result_ok);
4424         return DecodeError_clone(&*owner->contents.err);
4425 }
4426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4427         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
4428         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4429         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
4430         int64_t ret_ref = tag_ptr(ret_copy, true);
4431         return ret_ref;
4432 }
4433
4434 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
4435 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
4436 static jclass LDKErrorAction_IgnoreError_class = NULL;
4437 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
4438 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
4439 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
4440 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
4441 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
4442 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
4443 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
4444 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
4445 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
4446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
4447         LDKErrorAction_DisconnectPeer_class =
4448                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
4449         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
4450         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
4451         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
4452         LDKErrorAction_IgnoreError_class =
4453                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
4454         CHECK(LDKErrorAction_IgnoreError_class != NULL);
4455         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
4456         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
4457         LDKErrorAction_IgnoreAndLog_class =
4458                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
4459         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
4460         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
4461         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
4462         LDKErrorAction_IgnoreDuplicateGossip_class =
4463                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
4464         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
4465         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
4466         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
4467         LDKErrorAction_SendErrorMessage_class =
4468                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
4469         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
4470         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
4471         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
4472         LDKErrorAction_SendWarningMessage_class =
4473                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
4474         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
4475         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
4476         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
4477 }
4478 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4479         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4480         switch(obj->tag) {
4481                 case LDKErrorAction_DisconnectPeer: {
4482                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
4483                         int64_t msg_ref = 0;
4484                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4485                         msg_ref = tag_ptr(msg_var.inner, false);
4486                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
4487                 }
4488                 case LDKErrorAction_IgnoreError: {
4489                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
4490                 }
4491                 case LDKErrorAction_IgnoreAndLog: {
4492                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
4493                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
4494                 }
4495                 case LDKErrorAction_IgnoreDuplicateGossip: {
4496                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
4497                 }
4498                 case LDKErrorAction_SendErrorMessage: {
4499                         LDKErrorMessage msg_var = obj->send_error_message.msg;
4500                         int64_t msg_ref = 0;
4501                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4502                         msg_ref = tag_ptr(msg_var.inner, false);
4503                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
4504                 }
4505                 case LDKErrorAction_SendWarningMessage: {
4506                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
4507                         int64_t msg_ref = 0;
4508                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4509                         msg_ref = tag_ptr(msg_var.inner, false);
4510                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
4511                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
4512                 }
4513                 default: abort();
4514         }
4515 }
4516 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
4517 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
4518 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
4519 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
4520 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
4521 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
4522 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
4523 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
4524 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
4525 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
4526 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
4527 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
4528 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
4529 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
4530 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
4531 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
4532 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
4533 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
4534 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
4535 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
4536 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
4537 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
4538 static jclass LDKMessageSendEvent_SendChannelAnnouncement_class = NULL;
4539 static jmethodID LDKMessageSendEvent_SendChannelAnnouncement_meth = NULL;
4540 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
4541 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
4542 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
4543 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
4544 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
4545 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
4546 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
4547 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
4548 static jclass LDKMessageSendEvent_HandleError_class = NULL;
4549 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
4550 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
4551 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
4552 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
4553 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
4554 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
4555 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
4556 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
4557 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
4558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
4559         LDKMessageSendEvent_SendAcceptChannel_class =
4560                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
4561         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
4562         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
4563         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
4564         LDKMessageSendEvent_SendOpenChannel_class =
4565                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
4566         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
4567         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
4568         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
4569         LDKMessageSendEvent_SendFundingCreated_class =
4570                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
4571         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
4572         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
4573         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
4574         LDKMessageSendEvent_SendFundingSigned_class =
4575                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
4576         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
4577         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
4578         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
4579         LDKMessageSendEvent_SendChannelReady_class =
4580                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
4581         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
4582         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
4583         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
4584         LDKMessageSendEvent_SendAnnouncementSignatures_class =
4585                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
4586         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
4587         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
4588         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
4589         LDKMessageSendEvent_UpdateHTLCs_class =
4590                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
4591         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
4592         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
4593         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
4594         LDKMessageSendEvent_SendRevokeAndACK_class =
4595                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
4596         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
4597         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
4598         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
4599         LDKMessageSendEvent_SendClosingSigned_class =
4600                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
4601         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
4602         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
4603         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
4604         LDKMessageSendEvent_SendShutdown_class =
4605                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
4606         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
4607         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
4608         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
4609         LDKMessageSendEvent_SendChannelReestablish_class =
4610                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
4611         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
4612         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
4613         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
4614         LDKMessageSendEvent_SendChannelAnnouncement_class =
4615                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelAnnouncement"));
4616         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_class != NULL);
4617         LDKMessageSendEvent_SendChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelAnnouncement_class, "<init>", "([BJJ)V");
4618         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_meth != NULL);
4619         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
4620                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
4621         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
4622         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
4623         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
4624         LDKMessageSendEvent_BroadcastChannelUpdate_class =
4625                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
4626         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
4627         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
4628         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
4629         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
4630                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
4631         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
4632         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
4633         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
4634         LDKMessageSendEvent_SendChannelUpdate_class =
4635                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
4636         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
4637         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
4638         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
4639         LDKMessageSendEvent_HandleError_class =
4640                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
4641         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
4642         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
4643         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
4644         LDKMessageSendEvent_SendChannelRangeQuery_class =
4645                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
4646         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
4647         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
4648         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
4649         LDKMessageSendEvent_SendShortIdsQuery_class =
4650                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
4651         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
4652         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
4653         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
4654         LDKMessageSendEvent_SendReplyChannelRange_class =
4655                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
4656         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
4657         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
4658         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
4659         LDKMessageSendEvent_SendGossipTimestampFilter_class =
4660                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
4661         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
4662         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
4663         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
4664 }
4665 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4666         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4667         switch(obj->tag) {
4668                 case LDKMessageSendEvent_SendAcceptChannel: {
4669                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4670                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
4671                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
4672                         int64_t msg_ref = 0;
4673                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4674                         msg_ref = tag_ptr(msg_var.inner, false);
4675                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
4676                 }
4677                 case LDKMessageSendEvent_SendOpenChannel: {
4678                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4679                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
4680                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
4681                         int64_t msg_ref = 0;
4682                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4683                         msg_ref = tag_ptr(msg_var.inner, false);
4684                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
4685                 }
4686                 case LDKMessageSendEvent_SendFundingCreated: {
4687                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4688                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
4689                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
4690                         int64_t msg_ref = 0;
4691                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4692                         msg_ref = tag_ptr(msg_var.inner, false);
4693                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
4694                 }
4695                 case LDKMessageSendEvent_SendFundingSigned: {
4696                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4697                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
4698                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
4699                         int64_t msg_ref = 0;
4700                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4701                         msg_ref = tag_ptr(msg_var.inner, false);
4702                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
4703                 }
4704                 case LDKMessageSendEvent_SendChannelReady: {
4705                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4706                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
4707                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
4708                         int64_t msg_ref = 0;
4709                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4710                         msg_ref = tag_ptr(msg_var.inner, false);
4711                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
4712                 }
4713                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
4714                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4715                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
4716                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
4717                         int64_t msg_ref = 0;
4718                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4719                         msg_ref = tag_ptr(msg_var.inner, false);
4720                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
4721                 }
4722                 case LDKMessageSendEvent_UpdateHTLCs: {
4723                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4724                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
4725                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
4726                         int64_t updates_ref = 0;
4727                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
4728                         updates_ref = tag_ptr(updates_var.inner, false);
4729                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
4730                 }
4731                 case LDKMessageSendEvent_SendRevokeAndACK: {
4732                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4733                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
4734                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
4735                         int64_t msg_ref = 0;
4736                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4737                         msg_ref = tag_ptr(msg_var.inner, false);
4738                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
4739                 }
4740                 case LDKMessageSendEvent_SendClosingSigned: {
4741                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4742                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
4743                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
4744                         int64_t msg_ref = 0;
4745                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4746                         msg_ref = tag_ptr(msg_var.inner, false);
4747                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
4748                 }
4749                 case LDKMessageSendEvent_SendShutdown: {
4750                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4751                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
4752                         LDKShutdown msg_var = obj->send_shutdown.msg;
4753                         int64_t msg_ref = 0;
4754                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4755                         msg_ref = tag_ptr(msg_var.inner, false);
4756                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
4757                 }
4758                 case LDKMessageSendEvent_SendChannelReestablish: {
4759                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4760                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
4761                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
4762                         int64_t msg_ref = 0;
4763                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4764                         msg_ref = tag_ptr(msg_var.inner, false);
4765                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
4766                 }
4767                 case LDKMessageSendEvent_SendChannelAnnouncement: {
4768                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4769                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_announcement.node_id.compressed_form);
4770                         LDKChannelAnnouncement msg_var = obj->send_channel_announcement.msg;
4771                         int64_t msg_ref = 0;
4772                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4773                         msg_ref = tag_ptr(msg_var.inner, false);
4774                         LDKChannelUpdate update_msg_var = obj->send_channel_announcement.update_msg;
4775                         int64_t update_msg_ref = 0;
4776                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
4777                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
4778                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelAnnouncement_class, LDKMessageSendEvent_SendChannelAnnouncement_meth, node_id_arr, msg_ref, update_msg_ref);
4779                 }
4780                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
4781                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
4782                         int64_t msg_ref = 0;
4783                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4784                         msg_ref = tag_ptr(msg_var.inner, false);
4785                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
4786                         int64_t update_msg_ref = 0;
4787                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
4788                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
4789                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
4790                 }
4791                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
4792                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
4793                         int64_t msg_ref = 0;
4794                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4795                         msg_ref = tag_ptr(msg_var.inner, false);
4796                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
4797                 }
4798                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
4799                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
4800                         int64_t msg_ref = 0;
4801                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4802                         msg_ref = tag_ptr(msg_var.inner, false);
4803                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
4804                 }
4805                 case LDKMessageSendEvent_SendChannelUpdate: {
4806                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4807                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
4808                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
4809                         int64_t msg_ref = 0;
4810                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4811                         msg_ref = tag_ptr(msg_var.inner, false);
4812                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
4813                 }
4814                 case LDKMessageSendEvent_HandleError: {
4815                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4816                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
4817                         int64_t action_ref = tag_ptr(&obj->handle_error.action, false);
4818                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
4819                 }
4820                 case LDKMessageSendEvent_SendChannelRangeQuery: {
4821                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4822                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
4823                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
4824                         int64_t msg_ref = 0;
4825                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4826                         msg_ref = tag_ptr(msg_var.inner, false);
4827                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
4828                 }
4829                 case LDKMessageSendEvent_SendShortIdsQuery: {
4830                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4831                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
4832                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
4833                         int64_t msg_ref = 0;
4834                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4835                         msg_ref = tag_ptr(msg_var.inner, false);
4836                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
4837                 }
4838                 case LDKMessageSendEvent_SendReplyChannelRange: {
4839                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4840                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
4841                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
4842                         int64_t msg_ref = 0;
4843                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4844                         msg_ref = tag_ptr(msg_var.inner, false);
4845                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
4846                 }
4847                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
4848                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
4849                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
4850                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
4851                         int64_t msg_ref = 0;
4852                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4853                         msg_ref = tag_ptr(msg_var.inner, false);
4854                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
4855                 }
4856                 default: abort();
4857         }
4858 }
4859 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
4860         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
4861         for (size_t i = 0; i < ret.datalen; i++) {
4862                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
4863         }
4864         return ret;
4865 }
4866 static inline LDKCVec_ChainHashZ CVec_ChainHashZ_clone(const LDKCVec_ChainHashZ *orig) {
4867         LDKCVec_ChainHashZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ChainHashZ clone bytes"), .datalen = orig->datalen };
4868         for (size_t i = 0; i < ret.datalen; i++) {
4869                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4870         }
4871         return ret;
4872 }
4873 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
4874 CHECK(owner->result_ok);
4875         return *owner->contents.result;
4876 }
4877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4878         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
4879         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4880         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
4881         return ret_arr;
4882 }
4883
4884 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
4885 CHECK(!owner->result_ok);
4886         return *owner->contents.err;
4887 }
4888 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4889         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
4890         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
4891         return ret_conv;
4892 }
4893
4894 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4895         LDKNodeId ret = *owner->contents.result;
4896         ret.is_owned = false;
4897         return ret;
4898 }
4899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4900         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4901         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
4902         int64_t ret_ref = 0;
4903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4905         return ret_ref;
4906 }
4907
4908 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4909 CHECK(!owner->result_ok);
4910         return DecodeError_clone(&*owner->contents.err);
4911 }
4912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4913         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4914         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4915         *ret_copy = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
4916         int64_t ret_ref = tag_ptr(ret_copy, true);
4917         return ret_ref;
4918 }
4919
4920 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4921 CHECK(owner->result_ok);
4922         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
4923 }
4924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4925         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4926         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
4927         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
4928         int64_t ret_ref = tag_ptr(ret_copy, true);
4929         return ret_ref;
4930 }
4931
4932 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4933 CHECK(!owner->result_ok);
4934         return DecodeError_clone(&*owner->contents.err);
4935 }
4936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4937         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4938         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4939         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
4940         int64_t ret_ref = tag_ptr(ret_copy, true);
4941         return ret_ref;
4942 }
4943
4944 static inline struct LDKTxOut CResult_TxOutUtxoLookupErrorZ_get_ok(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR owner){
4945 CHECK(owner->result_ok);
4946         return TxOut_clone(&*owner->contents.result);
4947 }
4948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4949         LDKCResult_TxOutUtxoLookupErrorZ* owner_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(owner);
4950         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
4951         *ret_ref = CResult_TxOutUtxoLookupErrorZ_get_ok(owner_conv);
4952         return tag_ptr(ret_ref, true);
4953 }
4954
4955 static inline enum LDKUtxoLookupError CResult_TxOutUtxoLookupErrorZ_get_err(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR owner){
4956 CHECK(!owner->result_ok);
4957         return UtxoLookupError_clone(&*owner->contents.err);
4958 }
4959 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4960         LDKCResult_TxOutUtxoLookupErrorZ* owner_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(owner);
4961         jclass ret_conv = LDKUtxoLookupError_to_java(env, CResult_TxOutUtxoLookupErrorZ_get_err(owner_conv));
4962         return ret_conv;
4963 }
4964
4965 static jclass LDKUtxoResult_Sync_class = NULL;
4966 static jmethodID LDKUtxoResult_Sync_meth = NULL;
4967 static jclass LDKUtxoResult_Async_class = NULL;
4968 static jmethodID LDKUtxoResult_Async_meth = NULL;
4969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKUtxoResult_init (JNIEnv *env, jclass clz) {
4970         LDKUtxoResult_Sync_class =
4971                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUtxoResult$Sync"));
4972         CHECK(LDKUtxoResult_Sync_class != NULL);
4973         LDKUtxoResult_Sync_meth = (*env)->GetMethodID(env, LDKUtxoResult_Sync_class, "<init>", "(J)V");
4974         CHECK(LDKUtxoResult_Sync_meth != NULL);
4975         LDKUtxoResult_Async_class =
4976                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUtxoResult$Async"));
4977         CHECK(LDKUtxoResult_Async_class != NULL);
4978         LDKUtxoResult_Async_meth = (*env)->GetMethodID(env, LDKUtxoResult_Async_class, "<init>", "(J)V");
4979         CHECK(LDKUtxoResult_Async_meth != NULL);
4980 }
4981 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKUtxoResult_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4982         LDKUtxoResult *obj = (LDKUtxoResult*)untag_ptr(ptr);
4983         switch(obj->tag) {
4984                 case LDKUtxoResult_Sync: {
4985                         LDKCResult_TxOutUtxoLookupErrorZ* sync_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
4986                         *sync_conv = obj->sync;
4987                         *sync_conv = CResult_TxOutUtxoLookupErrorZ_clone(sync_conv);
4988                         return (*env)->NewObject(env, LDKUtxoResult_Sync_class, LDKUtxoResult_Sync_meth, tag_ptr(sync_conv, true));
4989                 }
4990                 case LDKUtxoResult_Async: {
4991                         LDKUtxoFuture async_var = obj->async;
4992                         int64_t async_ref = 0;
4993                         CHECK_INNER_FIELD_ACCESS_OR_NULL(async_var);
4994                         async_ref = tag_ptr(async_var.inner, false);
4995                         return (*env)->NewObject(env, LDKUtxoResult_Async_class, LDKUtxoResult_Async_meth, async_ref);
4996                 }
4997                 default: abort();
4998         }
4999 }
5000 typedef struct LDKUtxoLookup_JCalls {
5001         atomic_size_t refcnt;
5002         JavaVM *vm;
5003         jweak o;
5004         jmethodID get_utxo_meth;
5005 } LDKUtxoLookup_JCalls;
5006 static void LDKUtxoLookup_JCalls_free(void* this_arg) {
5007         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) this_arg;
5008         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5009                 JNIEnv *env;
5010                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5011                 if (get_jenv_res == JNI_EDETACHED) {
5012                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5013                 } else {
5014                         DO_ASSERT(get_jenv_res == JNI_OK);
5015                 }
5016                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5017                 if (get_jenv_res == JNI_EDETACHED) {
5018                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5019                 }
5020                 FREE(j_calls);
5021         }
5022 }
5023 LDKUtxoResult get_utxo_LDKUtxoLookup_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
5024         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) this_arg;
5025         JNIEnv *env;
5026         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5027         if (get_jenv_res == JNI_EDETACHED) {
5028                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5029         } else {
5030                 DO_ASSERT(get_jenv_res == JNI_OK);
5031         }
5032         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
5033         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
5034         int64_t short_channel_id_conv = short_channel_id;
5035         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5036         CHECK(obj != NULL);
5037         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
5038         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5039                 (*env)->ExceptionDescribe(env);
5040                 (*env)->FatalError(env, "A call to get_utxo in LDKUtxoLookup from rust threw an exception.");
5041         }
5042         void* ret_ptr = untag_ptr(ret);
5043         CHECK_ACCESS(ret_ptr);
5044         LDKUtxoResult ret_conv = *(LDKUtxoResult*)(ret_ptr);
5045         FREE(untag_ptr(ret));
5046         if (get_jenv_res == JNI_EDETACHED) {
5047                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5048         }
5049         return ret_conv;
5050 }
5051 static void LDKUtxoLookup_JCalls_cloned(LDKUtxoLookup* new_obj) {
5052         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) new_obj->this_arg;
5053         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5054 }
5055 static inline LDKUtxoLookup LDKUtxoLookup_init (JNIEnv *env, jclass clz, jobject o) {
5056         jclass c = (*env)->GetObjectClass(env, o);
5057         CHECK(c != NULL);
5058         LDKUtxoLookup_JCalls *calls = MALLOC(sizeof(LDKUtxoLookup_JCalls), "LDKUtxoLookup_JCalls");
5059         atomic_init(&calls->refcnt, 1);
5060         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5061         calls->o = (*env)->NewWeakGlobalRef(env, o);
5062         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
5063         CHECK(calls->get_utxo_meth != NULL);
5064
5065         LDKUtxoLookup ret = {
5066                 .this_arg = (void*) calls,
5067                 .get_utxo = get_utxo_LDKUtxoLookup_jcall,
5068                 .free = LDKUtxoLookup_JCalls_free,
5069         };
5070         return ret;
5071 }
5072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKUtxoLookup_1new(JNIEnv *env, jclass clz, jobject o) {
5073         LDKUtxoLookup *res_ptr = MALLOC(sizeof(LDKUtxoLookup), "LDKUtxoLookup");
5074         *res_ptr = LDKUtxoLookup_init(env, clz, o);
5075         return tag_ptr(res_ptr, true);
5076 }
5077 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) {
5078         void* this_arg_ptr = untag_ptr(this_arg);
5079         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5080         LDKUtxoLookup* this_arg_conv = (LDKUtxoLookup*)this_arg_ptr;
5081         uint8_t genesis_hash_arr[32];
5082         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
5083         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
5084         uint8_t (*genesis_hash_ref)[32] = &genesis_hash_arr;
5085         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
5086         *ret_copy = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
5087         int64_t ret_ref = tag_ptr(ret_copy, true);
5088         return ret_ref;
5089 }
5090
5091 static jclass LDKCOption_UtxoLookupZ_Some_class = NULL;
5092 static jmethodID LDKCOption_UtxoLookupZ_Some_meth = NULL;
5093 static jclass LDKCOption_UtxoLookupZ_None_class = NULL;
5094 static jmethodID LDKCOption_UtxoLookupZ_None_meth = NULL;
5095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1UtxoLookupZ_init (JNIEnv *env, jclass clz) {
5096         LDKCOption_UtxoLookupZ_Some_class =
5097                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_UtxoLookupZ$Some"));
5098         CHECK(LDKCOption_UtxoLookupZ_Some_class != NULL);
5099         LDKCOption_UtxoLookupZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_UtxoLookupZ_Some_class, "<init>", "(J)V");
5100         CHECK(LDKCOption_UtxoLookupZ_Some_meth != NULL);
5101         LDKCOption_UtxoLookupZ_None_class =
5102                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_UtxoLookupZ$None"));
5103         CHECK(LDKCOption_UtxoLookupZ_None_class != NULL);
5104         LDKCOption_UtxoLookupZ_None_meth = (*env)->GetMethodID(env, LDKCOption_UtxoLookupZ_None_class, "<init>", "()V");
5105         CHECK(LDKCOption_UtxoLookupZ_None_meth != NULL);
5106 }
5107 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1UtxoLookupZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5108         LDKCOption_UtxoLookupZ *obj = (LDKCOption_UtxoLookupZ*)untag_ptr(ptr);
5109         switch(obj->tag) {
5110                 case LDKCOption_UtxoLookupZ_Some: {
5111                         LDKUtxoLookup* some_ret = MALLOC(sizeof(LDKUtxoLookup), "LDKUtxoLookup");
5112                         *some_ret = obj->some;
5113                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
5114                         if ((*some_ret).free == LDKUtxoLookup_JCalls_free) {
5115                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5116                                 LDKUtxoLookup_JCalls_cloned(&(*some_ret));
5117                         }
5118                         return (*env)->NewObject(env, LDKCOption_UtxoLookupZ_Some_class, LDKCOption_UtxoLookupZ_Some_meth, tag_ptr(some_ret, true));
5119                 }
5120                 case LDKCOption_UtxoLookupZ_None: {
5121                         return (*env)->NewObject(env, LDKCOption_UtxoLookupZ_None_class, LDKCOption_UtxoLookupZ_None_meth);
5122                 }
5123                 default: abort();
5124         }
5125 }
5126 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5127 CHECK(owner->result_ok);
5128         return *owner->contents.result;
5129 }
5130 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5131         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
5132         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
5133         return ret_conv;
5134 }
5135
5136 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5137         LDKLightningError ret = *owner->contents.err;
5138         ret.is_owned = false;
5139         return ret;
5140 }
5141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5142         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
5143         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(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 LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5151         LDKChannelAnnouncement ret = owner->a;
5152         ret.is_owned = false;
5153         return ret;
5154 }
5155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5156         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
5157         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
5158         int64_t ret_ref = 0;
5159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5160         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5161         return ret_ref;
5162 }
5163
5164 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5165         LDKChannelUpdate ret = owner->b;
5166         ret.is_owned = false;
5167         return ret;
5168 }
5169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5170         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
5171         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
5172         int64_t ret_ref = 0;
5173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5174         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5175         return ret_ref;
5176 }
5177
5178 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
5179         LDKChannelUpdate ret = owner->c;
5180         ret.is_owned = false;
5181         return ret;
5182 }
5183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
5184         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
5185         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
5186         int64_t ret_ref = 0;
5187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5188         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5189         return ret_ref;
5190 }
5191
5192 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class = NULL;
5193 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = NULL;
5194 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class = NULL;
5195 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = NULL;
5196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_init (JNIEnv *env, jclass clz) {
5197         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class =
5198                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$Some"));
5199         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class != NULL);
5200         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, "<init>", "(J)V");
5201         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth != NULL);
5202         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class =
5203                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$None"));
5204         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class != NULL);
5205         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, "<init>", "()V");
5206         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth != NULL);
5207 }
5208 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5209         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
5210         switch(obj->tag) {
5211                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some: {
5212                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* some_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5213                         *some_conv = obj->some;
5214                         *some_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(some_conv);
5215                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth, tag_ptr(some_conv, true));
5216                 }
5217                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None: {
5218                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth);
5219                 }
5220                 default: abort();
5221         }
5222 }
5223 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5224 CHECK(owner->result_ok);
5225         return *owner->contents.result;
5226 }
5227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5228         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
5229         CResult_NoneLightningErrorZ_get_ok(owner_conv);
5230 }
5231
5232 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5233         LDKLightningError ret = *owner->contents.err;
5234         ret.is_owned = false;
5235         return ret;
5236 }
5237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5238         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
5239         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
5240         int64_t ret_ref = 0;
5241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5242         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5243         return ret_ref;
5244 }
5245
5246 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
5247         LDKChannelUpdateInfo ret = *owner->contents.result;
5248         ret.is_owned = false;
5249         return ret;
5250 }
5251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5252         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
5253         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
5254         int64_t ret_ref = 0;
5255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5256         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5257         return ret_ref;
5258 }
5259
5260 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
5261 CHECK(!owner->result_ok);
5262         return DecodeError_clone(&*owner->contents.err);
5263 }
5264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5265         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
5266         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5267         *ret_copy = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
5268         int64_t ret_ref = tag_ptr(ret_copy, true);
5269         return ret_ref;
5270 }
5271
5272 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
5273         LDKChannelInfo ret = *owner->contents.result;
5274         ret.is_owned = false;
5275         return ret;
5276 }
5277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5278         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
5279         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
5280         int64_t ret_ref = 0;
5281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5282         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5283         return ret_ref;
5284 }
5285
5286 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
5287 CHECK(!owner->result_ok);
5288         return DecodeError_clone(&*owner->contents.err);
5289 }
5290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5291         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
5292         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5293         *ret_copy = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
5294         int64_t ret_ref = tag_ptr(ret_copy, true);
5295         return ret_ref;
5296 }
5297
5298 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
5299         LDKRoutingFees ret = *owner->contents.result;
5300         ret.is_owned = false;
5301         return ret;
5302 }
5303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5304         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
5305         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
5306         int64_t ret_ref = 0;
5307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5308         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5309         return ret_ref;
5310 }
5311
5312 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
5313 CHECK(!owner->result_ok);
5314         return DecodeError_clone(&*owner->contents.err);
5315 }
5316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5317         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
5318         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5319         *ret_copy = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
5320         int64_t ret_ref = tag_ptr(ret_copy, true);
5321         return ret_ref;
5322 }
5323
5324 static jclass LDKNetAddress_IPv4_class = NULL;
5325 static jmethodID LDKNetAddress_IPv4_meth = NULL;
5326 static jclass LDKNetAddress_IPv6_class = NULL;
5327 static jmethodID LDKNetAddress_IPv6_meth = NULL;
5328 static jclass LDKNetAddress_OnionV2_class = NULL;
5329 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
5330 static jclass LDKNetAddress_OnionV3_class = NULL;
5331 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
5332 static jclass LDKNetAddress_Hostname_class = NULL;
5333 static jmethodID LDKNetAddress_Hostname_meth = NULL;
5334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
5335         LDKNetAddress_IPv4_class =
5336                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
5337         CHECK(LDKNetAddress_IPv4_class != NULL);
5338         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
5339         CHECK(LDKNetAddress_IPv4_meth != NULL);
5340         LDKNetAddress_IPv6_class =
5341                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
5342         CHECK(LDKNetAddress_IPv6_class != NULL);
5343         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
5344         CHECK(LDKNetAddress_IPv6_meth != NULL);
5345         LDKNetAddress_OnionV2_class =
5346                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
5347         CHECK(LDKNetAddress_OnionV2_class != NULL);
5348         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
5349         CHECK(LDKNetAddress_OnionV2_meth != NULL);
5350         LDKNetAddress_OnionV3_class =
5351                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
5352         CHECK(LDKNetAddress_OnionV3_class != NULL);
5353         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
5354         CHECK(LDKNetAddress_OnionV3_meth != NULL);
5355         LDKNetAddress_Hostname_class =
5356                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$Hostname"));
5357         CHECK(LDKNetAddress_Hostname_class != NULL);
5358         LDKNetAddress_Hostname_meth = (*env)->GetMethodID(env, LDKNetAddress_Hostname_class, "<init>", "(JS)V");
5359         CHECK(LDKNetAddress_Hostname_meth != NULL);
5360 }
5361 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5362         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
5363         switch(obj->tag) {
5364                 case LDKNetAddress_IPv4: {
5365                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
5366                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
5367                         int16_t port_conv = obj->i_pv4.port;
5368                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
5369                 }
5370                 case LDKNetAddress_IPv6: {
5371                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
5372                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
5373                         int16_t port_conv = obj->i_pv6.port;
5374                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
5375                 }
5376                 case LDKNetAddress_OnionV2: {
5377                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
5378                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
5379                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
5380                 }
5381                 case LDKNetAddress_OnionV3: {
5382                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
5383                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
5384                         int16_t checksum_conv = obj->onion_v3.checksum;
5385                         int8_t version_conv = obj->onion_v3.version;
5386                         int16_t port_conv = obj->onion_v3.port;
5387                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
5388                 }
5389                 case LDKNetAddress_Hostname: {
5390                         LDKHostname hostname_var = obj->hostname.hostname;
5391                         int64_t hostname_ref = 0;
5392                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
5393                         hostname_ref = tag_ptr(hostname_var.inner, false);
5394                         int16_t port_conv = obj->hostname.port;
5395                         return (*env)->NewObject(env, LDKNetAddress_Hostname_class, LDKNetAddress_Hostname_meth, hostname_ref, port_conv);
5396                 }
5397                 default: abort();
5398         }
5399 }
5400 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
5401         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
5402         for (size_t i = 0; i < ret.datalen; i++) {
5403                 ret.data[i] = NetAddress_clone(&orig->data[i]);
5404         }
5405         return ret;
5406 }
5407 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
5408         LDKNodeAnnouncementInfo ret = *owner->contents.result;
5409         ret.is_owned = false;
5410         return ret;
5411 }
5412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5413         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
5414         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
5415         int64_t ret_ref = 0;
5416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5417         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5418         return ret_ref;
5419 }
5420
5421 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
5422 CHECK(!owner->result_ok);
5423         return DecodeError_clone(&*owner->contents.err);
5424 }
5425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5426         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
5427         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5428         *ret_copy = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
5429         int64_t ret_ref = tag_ptr(ret_copy, true);
5430         return ret_ref;
5431 }
5432
5433 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
5434         LDKNodeAlias ret = *owner->contents.result;
5435         ret.is_owned = false;
5436         return ret;
5437 }
5438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5439         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
5440         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
5441         int64_t ret_ref = 0;
5442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5443         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5444         return ret_ref;
5445 }
5446
5447 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
5448 CHECK(!owner->result_ok);
5449         return DecodeError_clone(&*owner->contents.err);
5450 }
5451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5452         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
5453         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5454         *ret_copy = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
5455         int64_t ret_ref = tag_ptr(ret_copy, true);
5456         return ret_ref;
5457 }
5458
5459 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
5460         LDKNodeInfo ret = *owner->contents.result;
5461         ret.is_owned = false;
5462         return ret;
5463 }
5464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5465         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
5466         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
5467         int64_t ret_ref = 0;
5468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5469         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5470         return ret_ref;
5471 }
5472
5473 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
5474 CHECK(!owner->result_ok);
5475         return DecodeError_clone(&*owner->contents.err);
5476 }
5477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5478         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
5479         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5480         *ret_copy = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
5481         int64_t ret_ref = tag_ptr(ret_copy, true);
5482         return ret_ref;
5483 }
5484
5485 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
5486         LDKNetworkGraph ret = *owner->contents.result;
5487         ret.is_owned = false;
5488         return ret;
5489 }
5490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5491         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
5492         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
5493         int64_t ret_ref = 0;
5494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5495         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5496         return ret_ref;
5497 }
5498
5499 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
5500 CHECK(!owner->result_ok);
5501         return DecodeError_clone(&*owner->contents.err);
5502 }
5503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5504         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
5505         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5506         *ret_copy = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
5507         int64_t ret_ref = tag_ptr(ret_copy, true);
5508         return ret_ref;
5509 }
5510
5511 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
5512 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
5513 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
5514 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
5515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
5516         LDKCOption_CVec_NetAddressZZ_Some_class =
5517                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
5518         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
5519         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
5520         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
5521         LDKCOption_CVec_NetAddressZZ_None_class =
5522                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
5523         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
5524         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
5525         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
5526 }
5527 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5528         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(ptr);
5529         switch(obj->tag) {
5530                 case LDKCOption_CVec_NetAddressZZ_Some: {
5531                         LDKCVec_NetAddressZ some_var = obj->some;
5532                         int64_tArray some_arr = NULL;
5533                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
5534                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
5535                         for (size_t m = 0; m < some_var.datalen; m++) {
5536                                 int64_t some_conv_12_ref = tag_ptr(&some_var.data[m], false);
5537                                 some_arr_ptr[m] = some_conv_12_ref;
5538                         }
5539                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
5540                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
5541                 }
5542                 case LDKCOption_CVec_NetAddressZZ_None: {
5543                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
5544                 }
5545                 default: abort();
5546         }
5547 }
5548 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5549         LDKDelayedPaymentOutputDescriptor ret = *owner->contents.result;
5550         ret.is_owned = false;
5551         return ret;
5552 }
5553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5554         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5555         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5556         int64_t ret_ref = 0;
5557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5558         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5559         return ret_ref;
5560 }
5561
5562 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5563 CHECK(!owner->result_ok);
5564         return DecodeError_clone(&*owner->contents.err);
5565 }
5566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5567         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5568         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5569         *ret_copy = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5570         int64_t ret_ref = tag_ptr(ret_copy, true);
5571         return ret_ref;
5572 }
5573
5574 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5575         LDKStaticPaymentOutputDescriptor ret = *owner->contents.result;
5576         ret.is_owned = false;
5577         return ret;
5578 }
5579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5580         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5581         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5582         int64_t ret_ref = 0;
5583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5584         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5585         return ret_ref;
5586 }
5587
5588 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5589 CHECK(!owner->result_ok);
5590         return DecodeError_clone(&*owner->contents.err);
5591 }
5592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5593         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5594         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5595         *ret_copy = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5596         int64_t ret_ref = tag_ptr(ret_copy, true);
5597         return ret_ref;
5598 }
5599
5600 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5601 CHECK(owner->result_ok);
5602         return SpendableOutputDescriptor_clone(&*owner->contents.result);
5603 }
5604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5605         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5606         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
5607         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5608         int64_t ret_ref = tag_ptr(ret_copy, true);
5609         return ret_ref;
5610 }
5611
5612 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5613 CHECK(!owner->result_ok);
5614         return DecodeError_clone(&*owner->contents.err);
5615 }
5616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5617         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5618         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5619         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5620         int64_t ret_ref = tag_ptr(ret_copy, true);
5621         return ret_ref;
5622 }
5623
5624 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
5625         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
5626         for (size_t i = 0; i < ret.datalen; i++) {
5627                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
5628         }
5629         return ret;
5630 }
5631 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
5632         return owner->a;
5633 }
5634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5635         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
5636         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5637         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
5638         return ret_arr;
5639 }
5640
5641 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
5642         return owner->b;
5643 }
5644 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5645         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
5646         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
5647         jobjectArray ret_arr = NULL;
5648         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
5649         ;
5650         for (size_t i = 0; i < ret_var.datalen; i++) {
5651                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
5652                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
5653                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
5654         }
5655         
5656         return ret_arr;
5657 }
5658
5659 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5660 CHECK(owner->result_ok);
5661         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
5662 }
5663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5664         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5665         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
5666         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
5667         return tag_ptr(ret_conv, true);
5668 }
5669
5670 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5671 CHECK(!owner->result_ok);
5672         return *owner->contents.err;
5673 }
5674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5675         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5676         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
5677 }
5678
5679 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5680 CHECK(owner->result_ok);
5681         return *owner->contents.result;
5682 }
5683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5684         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5685         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5686         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
5687         return ret_arr;
5688 }
5689
5690 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5691 CHECK(!owner->result_ok);
5692         return *owner->contents.err;
5693 }
5694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5695         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5696         CResult_SignatureNoneZ_get_err(owner_conv);
5697 }
5698
5699 static inline struct LDKPublicKey CResult_PublicKeyNoneZ_get_ok(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5700 CHECK(owner->result_ok);
5701         return *owner->contents.result;
5702 }
5703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5704         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5705         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5706         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyNoneZ_get_ok(owner_conv).compressed_form);
5707         return ret_arr;
5708 }
5709
5710 static inline void CResult_PublicKeyNoneZ_get_err(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5711 CHECK(!owner->result_ok);
5712         return *owner->contents.err;
5713 }
5714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5715         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5716         CResult_PublicKeyNoneZ_get_err(owner_conv);
5717 }
5718
5719 static jclass LDKCOption_ScalarZ_Some_class = NULL;
5720 static jmethodID LDKCOption_ScalarZ_Some_meth = NULL;
5721 static jclass LDKCOption_ScalarZ_None_class = NULL;
5722 static jmethodID LDKCOption_ScalarZ_None_meth = NULL;
5723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ScalarZ_init (JNIEnv *env, jclass clz) {
5724         LDKCOption_ScalarZ_Some_class =
5725                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$Some"));
5726         CHECK(LDKCOption_ScalarZ_Some_class != NULL);
5727         LDKCOption_ScalarZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_Some_class, "<init>", "(J)V");
5728         CHECK(LDKCOption_ScalarZ_Some_meth != NULL);
5729         LDKCOption_ScalarZ_None_class =
5730                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$None"));
5731         CHECK(LDKCOption_ScalarZ_None_class != NULL);
5732         LDKCOption_ScalarZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_None_class, "<init>", "()V");
5733         CHECK(LDKCOption_ScalarZ_None_meth != NULL);
5734 }
5735 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ScalarZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5736         LDKCOption_ScalarZ *obj = (LDKCOption_ScalarZ*)untag_ptr(ptr);
5737         switch(obj->tag) {
5738                 case LDKCOption_ScalarZ_Some: {
5739                         LDKBigEndianScalar* some_ref = &obj->some;
5740                         return (*env)->NewObject(env, LDKCOption_ScalarZ_Some_class, LDKCOption_ScalarZ_Some_meth, tag_ptr(some_ref, false));
5741                 }
5742                 case LDKCOption_ScalarZ_None: {
5743                         return (*env)->NewObject(env, LDKCOption_ScalarZ_None_class, LDKCOption_ScalarZ_None_meth);
5744                 }
5745                 default: abort();
5746         }
5747 }
5748 static inline struct LDKThirtyTwoBytes CResult_SharedSecretNoneZ_get_ok(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5749 CHECK(owner->result_ok);
5750         return ThirtyTwoBytes_clone(&*owner->contents.result);
5751 }
5752 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5753         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5754         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5755         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SharedSecretNoneZ_get_ok(owner_conv).data);
5756         return ret_arr;
5757 }
5758
5759 static inline void CResult_SharedSecretNoneZ_get_err(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5760 CHECK(!owner->result_ok);
5761         return *owner->contents.err;
5762 }
5763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5764         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5765         CResult_SharedSecretNoneZ_get_err(owner_conv);
5766 }
5767
5768 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5769 CHECK(owner->result_ok);
5770         return *owner->contents.result;
5771 }
5772 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5773         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
5774         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
5775         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
5776         return ret_arr;
5777 }
5778
5779 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5780 CHECK(!owner->result_ok);
5781         return *owner->contents.err;
5782 }
5783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5784         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
5785         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
5786 }
5787
5788 typedef struct LDKChannelSigner_JCalls {
5789         atomic_size_t refcnt;
5790         JavaVM *vm;
5791         jweak o;
5792         jmethodID get_per_commitment_point_meth;
5793         jmethodID release_commitment_secret_meth;
5794         jmethodID validate_holder_commitment_meth;
5795         jmethodID channel_keys_id_meth;
5796         jmethodID provide_channel_parameters_meth;
5797 } LDKChannelSigner_JCalls;
5798 static void LDKChannelSigner_JCalls_free(void* this_arg) {
5799         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5800         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5801                 JNIEnv *env;
5802                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5803                 if (get_jenv_res == JNI_EDETACHED) {
5804                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5805                 } else {
5806                         DO_ASSERT(get_jenv_res == JNI_OK);
5807                 }
5808                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5809                 if (get_jenv_res == JNI_EDETACHED) {
5810                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5811                 }
5812                 FREE(j_calls);
5813         }
5814 }
5815 LDKPublicKey get_per_commitment_point_LDKChannelSigner_jcall(const void* this_arg, uint64_t idx) {
5816         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5817         JNIEnv *env;
5818         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5819         if (get_jenv_res == JNI_EDETACHED) {
5820                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5821         } else {
5822                 DO_ASSERT(get_jenv_res == JNI_OK);
5823         }
5824         int64_t idx_conv = idx;
5825         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5826         CHECK(obj != NULL);
5827         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
5828         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5829                 (*env)->ExceptionDescribe(env);
5830                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKChannelSigner from rust threw an exception.");
5831         }
5832         LDKPublicKey ret_ref;
5833         CHECK((*env)->GetArrayLength(env, ret) == 33);
5834         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
5835         if (get_jenv_res == JNI_EDETACHED) {
5836                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5837         }
5838         return ret_ref;
5839 }
5840 LDKThirtyTwoBytes release_commitment_secret_LDKChannelSigner_jcall(const void* this_arg, uint64_t idx) {
5841         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5842         JNIEnv *env;
5843         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5844         if (get_jenv_res == JNI_EDETACHED) {
5845                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5846         } else {
5847                 DO_ASSERT(get_jenv_res == JNI_OK);
5848         }
5849         int64_t idx_conv = idx;
5850         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5851         CHECK(obj != NULL);
5852         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
5853         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5854                 (*env)->ExceptionDescribe(env);
5855                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKChannelSigner from rust threw an exception.");
5856         }
5857         LDKThirtyTwoBytes ret_ref;
5858         CHECK((*env)->GetArrayLength(env, ret) == 32);
5859         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5860         if (get_jenv_res == JNI_EDETACHED) {
5861                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5862         }
5863         return ret_ref;
5864 }
5865 LDKCResult_NoneNoneZ validate_holder_commitment_LDKChannelSigner_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
5866         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5867         JNIEnv *env;
5868         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5869         if (get_jenv_res == JNI_EDETACHED) {
5870                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5871         } else {
5872                 DO_ASSERT(get_jenv_res == JNI_OK);
5873         }
5874         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
5875         int64_t holder_tx_ref = 0;
5876         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
5877         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
5878         holder_tx_ref = tag_ptr(holder_tx_var.inner, holder_tx_var.is_owned);
5879         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5880         jobjectArray preimages_arr = NULL;
5881         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5882         ;
5883         for (size_t i = 0; i < preimages_var.datalen; i++) {
5884                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5885                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5886                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5887         }
5888         
5889         FREE(preimages_var.data);
5890         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5891         CHECK(obj != NULL);
5892         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
5893         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5894                 (*env)->ExceptionDescribe(env);
5895                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKChannelSigner from rust threw an exception.");
5896         }
5897         void* ret_ptr = untag_ptr(ret);
5898         CHECK_ACCESS(ret_ptr);
5899         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
5900         FREE(untag_ptr(ret));
5901         if (get_jenv_res == JNI_EDETACHED) {
5902                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5903         }
5904         return ret_conv;
5905 }
5906 LDKThirtyTwoBytes channel_keys_id_LDKChannelSigner_jcall(const void* this_arg) {
5907         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5908         JNIEnv *env;
5909         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5910         if (get_jenv_res == JNI_EDETACHED) {
5911                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5912         } else {
5913                 DO_ASSERT(get_jenv_res == JNI_OK);
5914         }
5915         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5916         CHECK(obj != NULL);
5917         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
5918         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5919                 (*env)->ExceptionDescribe(env);
5920                 (*env)->FatalError(env, "A call to channel_keys_id in LDKChannelSigner from rust threw an exception.");
5921         }
5922         LDKThirtyTwoBytes ret_ref;
5923         CHECK((*env)->GetArrayLength(env, ret) == 32);
5924         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5925         if (get_jenv_res == JNI_EDETACHED) {
5926                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5927         }
5928         return ret_ref;
5929 }
5930 void provide_channel_parameters_LDKChannelSigner_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
5931         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
5932         JNIEnv *env;
5933         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5934         if (get_jenv_res == JNI_EDETACHED) {
5935                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5936         } else {
5937                 DO_ASSERT(get_jenv_res == JNI_OK);
5938         }
5939         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
5940         int64_t channel_parameters_ref = 0;
5941         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
5942         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
5943         channel_parameters_ref = tag_ptr(channel_parameters_var.inner, channel_parameters_var.is_owned);
5944         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5945         CHECK(obj != NULL);
5946         (*env)->CallVoidMethod(env, obj, j_calls->provide_channel_parameters_meth, channel_parameters_ref);
5947         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5948                 (*env)->ExceptionDescribe(env);
5949                 (*env)->FatalError(env, "A call to provide_channel_parameters in LDKChannelSigner from rust threw an exception.");
5950         }
5951         if (get_jenv_res == JNI_EDETACHED) {
5952                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5953         }
5954 }
5955 static inline LDKChannelSigner LDKChannelSigner_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5956         jclass c = (*env)->GetObjectClass(env, o);
5957         CHECK(c != NULL);
5958         LDKChannelSigner_JCalls *calls = MALLOC(sizeof(LDKChannelSigner_JCalls), "LDKChannelSigner_JCalls");
5959         atomic_init(&calls->refcnt, 1);
5960         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5961         calls->o = (*env)->NewWeakGlobalRef(env, o);
5962         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
5963         CHECK(calls->get_per_commitment_point_meth != NULL);
5964         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
5965         CHECK(calls->release_commitment_secret_meth != NULL);
5966         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
5967         CHECK(calls->validate_holder_commitment_meth != NULL);
5968         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
5969         CHECK(calls->channel_keys_id_meth != NULL);
5970         calls->provide_channel_parameters_meth = (*env)->GetMethodID(env, c, "provide_channel_parameters", "(J)V");
5971         CHECK(calls->provide_channel_parameters_meth != NULL);
5972
5973         LDKChannelPublicKeys pubkeys_conv;
5974         pubkeys_conv.inner = untag_ptr(pubkeys);
5975         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
5976         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5977
5978         LDKChannelSigner ret = {
5979                 .this_arg = (void*) calls,
5980                 .get_per_commitment_point = get_per_commitment_point_LDKChannelSigner_jcall,
5981                 .release_commitment_secret = release_commitment_secret_LDKChannelSigner_jcall,
5982                 .validate_holder_commitment = validate_holder_commitment_LDKChannelSigner_jcall,
5983                 .channel_keys_id = channel_keys_id_LDKChannelSigner_jcall,
5984                 .provide_channel_parameters = provide_channel_parameters_LDKChannelSigner_jcall,
5985                 .free = LDKChannelSigner_JCalls_free,
5986                 .pubkeys = pubkeys_conv,
5987                 .set_pubkeys = NULL,
5988         };
5989         return ret;
5990 }
5991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelSigner_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5992         LDKChannelSigner *res_ptr = MALLOC(sizeof(LDKChannelSigner), "LDKChannelSigner");
5993         *res_ptr = LDKChannelSigner_init(env, clz, o, pubkeys);
5994         return tag_ptr(res_ptr, true);
5995 }
5996 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) {
5997         void* this_arg_ptr = untag_ptr(this_arg);
5998         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5999         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
6000         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
6001         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
6002         return ret_arr;
6003 }
6004
6005 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
6006         void* this_arg_ptr = untag_ptr(this_arg);
6007         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6008         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
6009         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6010         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
6011         return ret_arr;
6012 }
6013
6014 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) {
6015         void* this_arg_ptr = untag_ptr(this_arg);
6016         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6017         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
6018         LDKHolderCommitmentTransaction holder_tx_conv;
6019         holder_tx_conv.inner = untag_ptr(holder_tx);
6020         holder_tx_conv.is_owned = ptr_is_owned(holder_tx);
6021         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
6022         holder_tx_conv.is_owned = false;
6023         LDKCVec_PaymentPreimageZ preimages_constr;
6024         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
6025         if (preimages_constr.datalen > 0)
6026                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
6027         else
6028                 preimages_constr.data = NULL;
6029         for (size_t i = 0; i < preimages_constr.datalen; i++) {
6030                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
6031                 LDKThirtyTwoBytes preimages_conv_8_ref;
6032                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
6033                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
6034                 preimages_constr.data[i] = preimages_conv_8_ref;
6035         }
6036         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
6037         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
6038         return tag_ptr(ret_conv, true);
6039 }
6040
6041 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
6042         void* this_arg_ptr = untag_ptr(this_arg);
6043         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6044         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
6045         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6046         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
6047         return ret_arr;
6048 }
6049
6050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1provide_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
6051         void* this_arg_ptr = untag_ptr(this_arg);
6052         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6053         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
6054         LDKChannelTransactionParameters channel_parameters_conv;
6055         channel_parameters_conv.inner = untag_ptr(channel_parameters);
6056         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
6057         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
6058         channel_parameters_conv.is_owned = false;
6059         (this_arg_conv->provide_channel_parameters)(this_arg_conv->this_arg, &channel_parameters_conv);
6060 }
6061
6062 LDKChannelPublicKeys LDKChannelSigner_set_get_pubkeys(LDKChannelSigner* this_arg) {
6063         if (this_arg->set_pubkeys != NULL)
6064                 this_arg->set_pubkeys(this_arg);
6065         return this_arg->pubkeys;
6066 }
6067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
6068         void* this_arg_ptr = untag_ptr(this_arg);
6069         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6070         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
6071         LDKChannelPublicKeys ret_var = LDKChannelSigner_set_get_pubkeys(this_arg_conv);
6072         int64_t ret_ref = 0;
6073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6074         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6075         return ret_ref;
6076 }
6077
6078 typedef struct LDKEcdsaChannelSigner_JCalls {
6079         atomic_size_t refcnt;
6080         JavaVM *vm;
6081         jweak o;
6082         LDKChannelSigner_JCalls* ChannelSigner;
6083         jmethodID sign_counterparty_commitment_meth;
6084         jmethodID validate_counterparty_revocation_meth;
6085         jmethodID sign_holder_commitment_and_htlcs_meth;
6086         jmethodID sign_justice_revoked_output_meth;
6087         jmethodID sign_justice_revoked_htlc_meth;
6088         jmethodID sign_counterparty_htlc_transaction_meth;
6089         jmethodID sign_closing_transaction_meth;
6090         jmethodID sign_holder_anchor_input_meth;
6091         jmethodID sign_channel_announcement_with_funding_key_meth;
6092 } LDKEcdsaChannelSigner_JCalls;
6093 static void LDKEcdsaChannelSigner_JCalls_free(void* this_arg) {
6094         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6095         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6096                 JNIEnv *env;
6097                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6098                 if (get_jenv_res == JNI_EDETACHED) {
6099                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6100                 } else {
6101                         DO_ASSERT(get_jenv_res == JNI_OK);
6102                 }
6103                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6104                 if (get_jenv_res == JNI_EDETACHED) {
6105                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6106                 }
6107                 FREE(j_calls);
6108         }
6109 }
6110 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
6111         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6112         JNIEnv *env;
6113         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6114         if (get_jenv_res == JNI_EDETACHED) {
6115                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6116         } else {
6117                 DO_ASSERT(get_jenv_res == JNI_OK);
6118         }
6119         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
6120         int64_t commitment_tx_ref = 0;
6121         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
6122         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
6123         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
6124         LDKCVec_PaymentPreimageZ preimages_var = preimages;
6125         jobjectArray preimages_arr = NULL;
6126         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
6127         ;
6128         for (size_t i = 0; i < preimages_var.datalen; i++) {
6129                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
6130                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
6131                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
6132         }
6133         
6134         FREE(preimages_var.data);
6135         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6136         CHECK(obj != NULL);
6137         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
6138         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6139                 (*env)->ExceptionDescribe(env);
6140                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKEcdsaChannelSigner from rust threw an exception.");
6141         }
6142         void* ret_ptr = untag_ptr(ret);
6143         CHECK_ACCESS(ret_ptr);
6144         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
6145         FREE(untag_ptr(ret));
6146         if (get_jenv_res == JNI_EDETACHED) {
6147                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6148         }
6149         return ret_conv;
6150 }
6151 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKEcdsaChannelSigner_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
6152         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6153         JNIEnv *env;
6154         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6155         if (get_jenv_res == JNI_EDETACHED) {
6156                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6157         } else {
6158                 DO_ASSERT(get_jenv_res == JNI_OK);
6159         }
6160         int64_t idx_conv = idx;
6161         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
6162         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
6163         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6164         CHECK(obj != NULL);
6165         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
6166         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6167                 (*env)->ExceptionDescribe(env);
6168                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKEcdsaChannelSigner from rust threw an exception.");
6169         }
6170         void* ret_ptr = untag_ptr(ret);
6171         CHECK_ACCESS(ret_ptr);
6172         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
6173         FREE(untag_ptr(ret));
6174         if (get_jenv_res == JNI_EDETACHED) {
6175                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6176         }
6177         return ret_conv;
6178 }
6179 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
6180         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6181         JNIEnv *env;
6182         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6183         if (get_jenv_res == JNI_EDETACHED) {
6184                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6185         } else {
6186                 DO_ASSERT(get_jenv_res == JNI_OK);
6187         }
6188         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
6189         int64_t commitment_tx_ref = 0;
6190         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
6191         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
6192         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
6193         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6194         CHECK(obj != NULL);
6195         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
6196         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6197                 (*env)->ExceptionDescribe(env);
6198                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKEcdsaChannelSigner from rust threw an exception.");
6199         }
6200         void* ret_ptr = untag_ptr(ret);
6201         CHECK_ACCESS(ret_ptr);
6202         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
6203         FREE(untag_ptr(ret));
6204         if (get_jenv_res == JNI_EDETACHED) {
6205                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6206         }
6207         return ret_conv;
6208 }
6209 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]) {
6210         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6211         JNIEnv *env;
6212         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6213         if (get_jenv_res == JNI_EDETACHED) {
6214                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6215         } else {
6216                 DO_ASSERT(get_jenv_res == JNI_OK);
6217         }
6218         LDKTransaction justice_tx_var = justice_tx;
6219         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
6220         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
6221         Transaction_free(justice_tx_var);
6222         int64_t input_conv = input;
6223         int64_t amount_conv = amount;
6224         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
6225         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
6226         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6227         CHECK(obj != NULL);
6228         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);
6229         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6230                 (*env)->ExceptionDescribe(env);
6231                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKEcdsaChannelSigner from rust threw an exception.");
6232         }
6233         void* ret_ptr = untag_ptr(ret);
6234         CHECK_ACCESS(ret_ptr);
6235         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6236         FREE(untag_ptr(ret));
6237         if (get_jenv_res == JNI_EDETACHED) {
6238                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6239         }
6240         return ret_conv;
6241 }
6242 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) {
6243         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6244         JNIEnv *env;
6245         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6246         if (get_jenv_res == JNI_EDETACHED) {
6247                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6248         } else {
6249                 DO_ASSERT(get_jenv_res == JNI_OK);
6250         }
6251         LDKTransaction justice_tx_var = justice_tx;
6252         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
6253         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
6254         Transaction_free(justice_tx_var);
6255         int64_t input_conv = input;
6256         int64_t amount_conv = amount;
6257         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
6258         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
6259         LDKHTLCOutputInCommitment htlc_var = *htlc;
6260         int64_t htlc_ref = 0;
6261         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
6262         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
6263         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
6264         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6265         CHECK(obj != NULL);
6266         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);
6267         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6268                 (*env)->ExceptionDescribe(env);
6269                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKEcdsaChannelSigner from rust threw an exception.");
6270         }
6271         void* ret_ptr = untag_ptr(ret);
6272         CHECK_ACCESS(ret_ptr);
6273         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6274         FREE(untag_ptr(ret));
6275         if (get_jenv_res == JNI_EDETACHED) {
6276                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6277         }
6278         return ret_conv;
6279 }
6280 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) {
6281         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6282         JNIEnv *env;
6283         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6284         if (get_jenv_res == JNI_EDETACHED) {
6285                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6286         } else {
6287                 DO_ASSERT(get_jenv_res == JNI_OK);
6288         }
6289         LDKTransaction htlc_tx_var = htlc_tx;
6290         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
6291         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
6292         Transaction_free(htlc_tx_var);
6293         int64_t input_conv = input;
6294         int64_t amount_conv = amount;
6295         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
6296         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
6297         LDKHTLCOutputInCommitment htlc_var = *htlc;
6298         int64_t htlc_ref = 0;
6299         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
6300         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
6301         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
6302         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6303         CHECK(obj != NULL);
6304         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);
6305         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6306                 (*env)->ExceptionDescribe(env);
6307                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKEcdsaChannelSigner from rust threw an exception.");
6308         }
6309         void* ret_ptr = untag_ptr(ret);
6310         CHECK_ACCESS(ret_ptr);
6311         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6312         FREE(untag_ptr(ret));
6313         if (get_jenv_res == JNI_EDETACHED) {
6314                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6315         }
6316         return ret_conv;
6317 }
6318 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
6319         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6320         JNIEnv *env;
6321         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6322         if (get_jenv_res == JNI_EDETACHED) {
6323                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6324         } else {
6325                 DO_ASSERT(get_jenv_res == JNI_OK);
6326         }
6327         LDKClosingTransaction closing_tx_var = *closing_tx;
6328         int64_t closing_tx_ref = 0;
6329         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
6330         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
6331         closing_tx_ref = tag_ptr(closing_tx_var.inner, closing_tx_var.is_owned);
6332         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6333         CHECK(obj != NULL);
6334         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
6335         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6336                 (*env)->ExceptionDescribe(env);
6337                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKEcdsaChannelSigner from rust threw an exception.");
6338         }
6339         void* ret_ptr = untag_ptr(ret);
6340         CHECK_ACCESS(ret_ptr);
6341         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6342         FREE(untag_ptr(ret));
6343         if (get_jenv_res == JNI_EDETACHED) {
6344                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6345         }
6346         return ret_conv;
6347 }
6348 LDKCResult_SignatureNoneZ sign_holder_anchor_input_LDKEcdsaChannelSigner_jcall(const void* this_arg, LDKTransaction anchor_tx, uintptr_t input) {
6349         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6350         JNIEnv *env;
6351         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6352         if (get_jenv_res == JNI_EDETACHED) {
6353                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6354         } else {
6355                 DO_ASSERT(get_jenv_res == JNI_OK);
6356         }
6357         LDKTransaction anchor_tx_var = anchor_tx;
6358         int8_tArray anchor_tx_arr = (*env)->NewByteArray(env, anchor_tx_var.datalen);
6359         (*env)->SetByteArrayRegion(env, anchor_tx_arr, 0, anchor_tx_var.datalen, anchor_tx_var.data);
6360         Transaction_free(anchor_tx_var);
6361         int64_t input_conv = input;
6362         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6363         CHECK(obj != NULL);
6364         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_anchor_input_meth, anchor_tx_arr, input_conv);
6365         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6366                 (*env)->ExceptionDescribe(env);
6367                 (*env)->FatalError(env, "A call to sign_holder_anchor_input in LDKEcdsaChannelSigner from rust threw an exception.");
6368         }
6369         void* ret_ptr = untag_ptr(ret);
6370         CHECK_ACCESS(ret_ptr);
6371         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6372         FREE(untag_ptr(ret));
6373         if (get_jenv_res == JNI_EDETACHED) {
6374                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6375         }
6376         return ret_conv;
6377 }
6378 LDKCResult_SignatureNoneZ sign_channel_announcement_with_funding_key_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
6379         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
6380         JNIEnv *env;
6381         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6382         if (get_jenv_res == JNI_EDETACHED) {
6383                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6384         } else {
6385                 DO_ASSERT(get_jenv_res == JNI_OK);
6386         }
6387         LDKUnsignedChannelAnnouncement msg_var = *msg;
6388         int64_t msg_ref = 0;
6389         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
6390         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6391         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
6392         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6393         CHECK(obj != NULL);
6394         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_with_funding_key_meth, msg_ref);
6395         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6396                 (*env)->ExceptionDescribe(env);
6397                 (*env)->FatalError(env, "A call to sign_channel_announcement_with_funding_key in LDKEcdsaChannelSigner from rust threw an exception.");
6398         }
6399         void* ret_ptr = untag_ptr(ret);
6400         CHECK_ACCESS(ret_ptr);
6401         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
6402         FREE(untag_ptr(ret));
6403         if (get_jenv_res == JNI_EDETACHED) {
6404                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6405         }
6406         return ret_conv;
6407 }
6408 static void LDKEcdsaChannelSigner_JCalls_cloned(LDKEcdsaChannelSigner* new_obj) {
6409         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) new_obj->this_arg;
6410         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6411         atomic_fetch_add_explicit(&j_calls->ChannelSigner->refcnt, 1, memory_order_release);
6412 }
6413 static inline LDKEcdsaChannelSigner LDKEcdsaChannelSigner_init (JNIEnv *env, jclass clz, jobject o, jobject ChannelSigner, int64_t pubkeys) {
6414         jclass c = (*env)->GetObjectClass(env, o);
6415         CHECK(c != NULL);
6416         LDKEcdsaChannelSigner_JCalls *calls = MALLOC(sizeof(LDKEcdsaChannelSigner_JCalls), "LDKEcdsaChannelSigner_JCalls");
6417         atomic_init(&calls->refcnt, 1);
6418         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6419         calls->o = (*env)->NewWeakGlobalRef(env, o);
6420         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
6421         CHECK(calls->sign_counterparty_commitment_meth != NULL);
6422         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
6423         CHECK(calls->validate_counterparty_revocation_meth != NULL);
6424         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
6425         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
6426         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
6427         CHECK(calls->sign_justice_revoked_output_meth != NULL);
6428         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
6429         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
6430         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
6431         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
6432         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
6433         CHECK(calls->sign_closing_transaction_meth != NULL);
6434         calls->sign_holder_anchor_input_meth = (*env)->GetMethodID(env, c, "sign_holder_anchor_input", "([BJ)J");
6435         CHECK(calls->sign_holder_anchor_input_meth != NULL);
6436         calls->sign_channel_announcement_with_funding_key_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement_with_funding_key", "(J)J");
6437         CHECK(calls->sign_channel_announcement_with_funding_key_meth != NULL);
6438
6439         LDKChannelPublicKeys pubkeys_conv;
6440         pubkeys_conv.inner = untag_ptr(pubkeys);
6441         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
6442         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
6443
6444         LDKEcdsaChannelSigner ret = {
6445                 .this_arg = (void*) calls,
6446                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKEcdsaChannelSigner_jcall,
6447                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKEcdsaChannelSigner_jcall,
6448                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKEcdsaChannelSigner_jcall,
6449                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKEcdsaChannelSigner_jcall,
6450                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKEcdsaChannelSigner_jcall,
6451                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKEcdsaChannelSigner_jcall,
6452                 .sign_closing_transaction = sign_closing_transaction_LDKEcdsaChannelSigner_jcall,
6453                 .sign_holder_anchor_input = sign_holder_anchor_input_LDKEcdsaChannelSigner_jcall,
6454                 .sign_channel_announcement_with_funding_key = sign_channel_announcement_with_funding_key_LDKEcdsaChannelSigner_jcall,
6455                 .free = LDKEcdsaChannelSigner_JCalls_free,
6456                 .ChannelSigner = LDKChannelSigner_init(env, clz, ChannelSigner, pubkeys),
6457         };
6458         calls->ChannelSigner = ret.ChannelSigner.this_arg;
6459         return ret;
6460 }
6461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEcdsaChannelSigner_1new(JNIEnv *env, jclass clz, jobject o, jobject ChannelSigner, int64_t pubkeys) {
6462         LDKEcdsaChannelSigner *res_ptr = MALLOC(sizeof(LDKEcdsaChannelSigner), "LDKEcdsaChannelSigner");
6463         *res_ptr = LDKEcdsaChannelSigner_init(env, clz, o, ChannelSigner, pubkeys);
6464         return tag_ptr(res_ptr, true);
6465 }
6466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEcdsaChannelSigner_1get_1ChannelSigner(JNIEnv *env, jclass clz, int64_t arg) {
6467         LDKEcdsaChannelSigner *inp = (LDKEcdsaChannelSigner *)untag_ptr(arg);
6468         return tag_ptr(&inp->ChannelSigner, false);
6469 }
6470 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) {
6471         void* this_arg_ptr = untag_ptr(this_arg);
6472         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6473         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6474         LDKCommitmentTransaction commitment_tx_conv;
6475         commitment_tx_conv.inner = untag_ptr(commitment_tx);
6476         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
6477         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
6478         commitment_tx_conv.is_owned = false;
6479         LDKCVec_PaymentPreimageZ preimages_constr;
6480         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
6481         if (preimages_constr.datalen > 0)
6482                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
6483         else
6484                 preimages_constr.data = NULL;
6485         for (size_t i = 0; i < preimages_constr.datalen; i++) {
6486                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
6487                 LDKThirtyTwoBytes preimages_conv_8_ref;
6488                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
6489                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
6490                 preimages_constr.data[i] = preimages_conv_8_ref;
6491         }
6492         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
6493         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
6494         return tag_ptr(ret_conv, true);
6495 }
6496
6497 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) {
6498         void* this_arg_ptr = untag_ptr(this_arg);
6499         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6500         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6501         uint8_t secret_arr[32];
6502         CHECK((*env)->GetArrayLength(env, secret) == 32);
6503         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
6504         uint8_t (*secret_ref)[32] = &secret_arr;
6505         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
6506         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
6507         return tag_ptr(ret_conv, true);
6508 }
6509
6510 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) {
6511         void* this_arg_ptr = untag_ptr(this_arg);
6512         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6513         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6514         LDKHolderCommitmentTransaction commitment_tx_conv;
6515         commitment_tx_conv.inner = untag_ptr(commitment_tx);
6516         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
6517         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
6518         commitment_tx_conv.is_owned = false;
6519         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
6520         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
6521         return tag_ptr(ret_conv, true);
6522 }
6523
6524 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) {
6525         void* this_arg_ptr = untag_ptr(this_arg);
6526         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6527         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6528         LDKTransaction justice_tx_ref;
6529         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
6530         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
6531         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
6532         justice_tx_ref.data_is_owned = true;
6533         uint8_t per_commitment_key_arr[32];
6534         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
6535         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
6536         uint8_t (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
6537         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6538         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
6539         return tag_ptr(ret_conv, true);
6540 }
6541
6542 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) {
6543         void* this_arg_ptr = untag_ptr(this_arg);
6544         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6545         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6546         LDKTransaction justice_tx_ref;
6547         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
6548         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
6549         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
6550         justice_tx_ref.data_is_owned = true;
6551         uint8_t per_commitment_key_arr[32];
6552         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
6553         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
6554         uint8_t (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
6555         LDKHTLCOutputInCommitment htlc_conv;
6556         htlc_conv.inner = untag_ptr(htlc);
6557         htlc_conv.is_owned = ptr_is_owned(htlc);
6558         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
6559         htlc_conv.is_owned = false;
6560         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6561         *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);
6562         return tag_ptr(ret_conv, true);
6563 }
6564
6565 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) {
6566         void* this_arg_ptr = untag_ptr(this_arg);
6567         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6568         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6569         LDKTransaction htlc_tx_ref;
6570         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
6571         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
6572         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
6573         htlc_tx_ref.data_is_owned = true;
6574         LDKPublicKey per_commitment_point_ref;
6575         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
6576         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
6577         LDKHTLCOutputInCommitment htlc_conv;
6578         htlc_conv.inner = untag_ptr(htlc);
6579         htlc_conv.is_owned = ptr_is_owned(htlc);
6580         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
6581         htlc_conv.is_owned = false;
6582         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6583         *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);
6584         return tag_ptr(ret_conv, true);
6585 }
6586
6587 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) {
6588         void* this_arg_ptr = untag_ptr(this_arg);
6589         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6590         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6591         LDKClosingTransaction closing_tx_conv;
6592         closing_tx_conv.inner = untag_ptr(closing_tx);
6593         closing_tx_conv.is_owned = ptr_is_owned(closing_tx);
6594         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
6595         closing_tx_conv.is_owned = false;
6596         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6597         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
6598         return tag_ptr(ret_conv, true);
6599 }
6600
6601 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) {
6602         void* this_arg_ptr = untag_ptr(this_arg);
6603         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6604         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6605         LDKTransaction anchor_tx_ref;
6606         anchor_tx_ref.datalen = (*env)->GetArrayLength(env, anchor_tx);
6607         anchor_tx_ref.data = MALLOC(anchor_tx_ref.datalen, "LDKTransaction Bytes");
6608         (*env)->GetByteArrayRegion(env, anchor_tx, 0, anchor_tx_ref.datalen, anchor_tx_ref.data);
6609         anchor_tx_ref.data_is_owned = true;
6610         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6611         *ret_conv = (this_arg_conv->sign_holder_anchor_input)(this_arg_conv->this_arg, anchor_tx_ref, input);
6612         return tag_ptr(ret_conv, true);
6613 }
6614
6615 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) {
6616         void* this_arg_ptr = untag_ptr(this_arg);
6617         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6618         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
6619         LDKUnsignedChannelAnnouncement msg_conv;
6620         msg_conv.inner = untag_ptr(msg);
6621         msg_conv.is_owned = ptr_is_owned(msg);
6622         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6623         msg_conv.is_owned = false;
6624         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6625         *ret_conv = (this_arg_conv->sign_channel_announcement_with_funding_key)(this_arg_conv->this_arg, &msg_conv);
6626         return tag_ptr(ret_conv, true);
6627 }
6628
6629 typedef struct LDKWriteableEcdsaChannelSigner_JCalls {
6630         atomic_size_t refcnt;
6631         JavaVM *vm;
6632         jweak o;
6633         LDKEcdsaChannelSigner_JCalls* EcdsaChannelSigner;
6634         LDKChannelSigner_JCalls* ChannelSigner;
6635         jmethodID write_meth;
6636 } LDKWriteableEcdsaChannelSigner_JCalls;
6637 static void LDKWriteableEcdsaChannelSigner_JCalls_free(void* this_arg) {
6638         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) this_arg;
6639         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6640                 JNIEnv *env;
6641                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6642                 if (get_jenv_res == JNI_EDETACHED) {
6643                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6644                 } else {
6645                         DO_ASSERT(get_jenv_res == JNI_OK);
6646                 }
6647                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6648                 if (get_jenv_res == JNI_EDETACHED) {
6649                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6650                 }
6651                 FREE(j_calls);
6652         }
6653 }
6654 LDKCVec_u8Z write_LDKWriteableEcdsaChannelSigner_jcall(const void* this_arg) {
6655         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) this_arg;
6656         JNIEnv *env;
6657         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6658         if (get_jenv_res == JNI_EDETACHED) {
6659                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6660         } else {
6661                 DO_ASSERT(get_jenv_res == JNI_OK);
6662         }
6663         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6664         CHECK(obj != NULL);
6665         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
6666         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6667                 (*env)->ExceptionDescribe(env);
6668                 (*env)->FatalError(env, "A call to write in LDKWriteableEcdsaChannelSigner from rust threw an exception.");
6669         }
6670         LDKCVec_u8Z ret_ref;
6671         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6672         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6673         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6674         if (get_jenv_res == JNI_EDETACHED) {
6675                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6676         }
6677         return ret_ref;
6678 }
6679 static void LDKWriteableEcdsaChannelSigner_JCalls_cloned(LDKWriteableEcdsaChannelSigner* new_obj) {
6680         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) new_obj->this_arg;
6681         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6682         atomic_fetch_add_explicit(&j_calls->EcdsaChannelSigner->refcnt, 1, memory_order_release);
6683         atomic_fetch_add_explicit(&j_calls->EcdsaChannelSigner->ChannelSigner->refcnt, 1, memory_order_release);
6684 }
6685 static inline LDKWriteableEcdsaChannelSigner LDKWriteableEcdsaChannelSigner_init (JNIEnv *env, jclass clz, jobject o, jobject EcdsaChannelSigner, jobject ChannelSigner, int64_t pubkeys) {
6686         jclass c = (*env)->GetObjectClass(env, o);
6687         CHECK(c != NULL);
6688         LDKWriteableEcdsaChannelSigner_JCalls *calls = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner_JCalls), "LDKWriteableEcdsaChannelSigner_JCalls");
6689         atomic_init(&calls->refcnt, 1);
6690         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6691         calls->o = (*env)->NewWeakGlobalRef(env, o);
6692         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6693         CHECK(calls->write_meth != NULL);
6694
6695         LDKChannelPublicKeys pubkeys_conv;
6696         pubkeys_conv.inner = untag_ptr(pubkeys);
6697         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
6698         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
6699
6700         LDKWriteableEcdsaChannelSigner ret = {
6701                 .this_arg = (void*) calls,
6702                 .write = write_LDKWriteableEcdsaChannelSigner_jcall,
6703                 .cloned = LDKWriteableEcdsaChannelSigner_JCalls_cloned,
6704                 .free = LDKWriteableEcdsaChannelSigner_JCalls_free,
6705                 .EcdsaChannelSigner = LDKEcdsaChannelSigner_init(env, clz, EcdsaChannelSigner, ChannelSigner, pubkeys),
6706         };
6707         calls->EcdsaChannelSigner = ret.EcdsaChannelSigner.this_arg;
6708         calls->ChannelSigner = ret.EcdsaChannelSigner.ChannelSigner.this_arg;
6709         return ret;
6710 }
6711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableEcdsaChannelSigner_1new(JNIEnv *env, jclass clz, jobject o, jobject EcdsaChannelSigner, jobject ChannelSigner, int64_t pubkeys) {
6712         LDKWriteableEcdsaChannelSigner *res_ptr = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
6713         *res_ptr = LDKWriteableEcdsaChannelSigner_init(env, clz, o, EcdsaChannelSigner, ChannelSigner, pubkeys);
6714         return tag_ptr(res_ptr, true);
6715 }
6716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableEcdsaChannelSigner_1get_1EcdsaChannelSigner(JNIEnv *env, jclass clz, int64_t arg) {
6717         LDKWriteableEcdsaChannelSigner *inp = (LDKWriteableEcdsaChannelSigner *)untag_ptr(arg);
6718         return tag_ptr(&inp->EcdsaChannelSigner, false);
6719 }
6720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableEcdsaChannelSigner_1get_1ChannelSigner(JNIEnv *env, jclass clz, int64_t arg) {
6721         LDKWriteableEcdsaChannelSigner *inp = (LDKWriteableEcdsaChannelSigner *)untag_ptr(arg);
6722         return tag_ptr(&inp->EcdsaChannelSigner.ChannelSigner, false);
6723 }
6724 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6725         void* this_arg_ptr = untag_ptr(this_arg);
6726         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6727         LDKWriteableEcdsaChannelSigner* this_arg_conv = (LDKWriteableEcdsaChannelSigner*)this_arg_ptr;
6728         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6729         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6730         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6731         CVec_u8Z_free(ret_var);
6732         return ret_arr;
6733 }
6734
6735 static inline struct LDKWriteableEcdsaChannelSigner CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_ok(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR owner){
6736 CHECK(owner->result_ok);
6737         return WriteableEcdsaChannelSigner_clone(&*owner->contents.result);
6738 }
6739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6740         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* owner_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(owner);
6741         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
6742         *ret_ret = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_ok(owner_conv);
6743         return tag_ptr(ret_ret, true);
6744 }
6745
6746 static inline struct LDKDecodeError CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_err(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR owner){
6747 CHECK(!owner->result_ok);
6748         return DecodeError_clone(&*owner->contents.err);
6749 }
6750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6751         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* owner_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(owner);
6752         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6753         *ret_copy = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_err(owner_conv);
6754         int64_t ret_ref = tag_ptr(ret_copy, true);
6755         return ret_ref;
6756 }
6757
6758 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
6759         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
6760         for (size_t i = 0; i < ret.datalen; i++) {
6761                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
6762         }
6763         return ret;
6764 }
6765 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6766 CHECK(owner->result_ok);
6767         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
6768 }
6769 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6770         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6771         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
6772         jobjectArray ret_arr = NULL;
6773         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6774         ;
6775         for (size_t i = 0; i < ret_var.datalen; i++) {
6776                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
6777                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
6778                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
6779                 CVec_u8Z_free(ret_conv_8_var);
6780                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6781         }
6782         
6783         FREE(ret_var.data);
6784         return ret_arr;
6785 }
6786
6787 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6788 CHECK(!owner->result_ok);
6789         return *owner->contents.err;
6790 }
6791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6792         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6793         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
6794 }
6795
6796 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6797         LDKInMemorySigner ret = *owner->contents.result;
6798         ret.is_owned = false;
6799         return ret;
6800 }
6801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6802         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6803         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
6804         int64_t ret_ref = 0;
6805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6806         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6807         return ret_ref;
6808 }
6809
6810 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6811 CHECK(!owner->result_ok);
6812         return DecodeError_clone(&*owner->contents.err);
6813 }
6814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6815         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6816         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6817         *ret_copy = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
6818         int64_t ret_ref = tag_ptr(ret_copy, true);
6819         return ret_ref;
6820 }
6821
6822 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
6823         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
6824         for (size_t i = 0; i < ret.datalen; i++) {
6825                 ret.data[i] = TxOut_clone(&orig->data[i]);
6826         }
6827         return ret;
6828 }
6829 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6830 CHECK(owner->result_ok);
6831         return *owner->contents.result;
6832 }
6833 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6834         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6835         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
6836         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6837         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6838         return ret_arr;
6839 }
6840
6841 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6842 CHECK(!owner->result_ok);
6843         return *owner->contents.err;
6844 }
6845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6846         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6847         CResult_TransactionNoneZ_get_err(owner_conv);
6848 }
6849
6850 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6851         return ThirtyTwoBytes_clone(&owner->a);
6852 }
6853 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6854         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6855         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6856         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
6857         return ret_arr;
6858 }
6859
6860 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6861         LDKChannelMonitor ret = owner->b;
6862         ret.is_owned = false;
6863         return ret;
6864 }
6865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6866         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6867         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6868         int64_t ret_ref = 0;
6869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6870         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6871         return ret_ref;
6872 }
6873
6874 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
6875         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
6876         for (size_t i = 0; i < ret.datalen; i++) {
6877                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
6878         }
6879         return ret;
6880 }
6881 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6882 CHECK(owner->result_ok);
6883         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
6884 }
6885 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6886         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6887         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
6888         int64_tArray ret_arr = NULL;
6889         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6890         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6891         for (size_t j = 0; j < ret_var.datalen; j++) {
6892                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6893                 *ret_conv_35_conv = ret_var.data[j];
6894                 ret_arr_ptr[j] = tag_ptr(ret_conv_35_conv, true);
6895         }
6896         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6897         FREE(ret_var.data);
6898         return ret_arr;
6899 }
6900
6901 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6902 CHECK(!owner->result_ok);
6903         return *owner->contents.err;
6904 }
6905 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6906         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6907         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
6908         return ret_conv;
6909 }
6910
6911 static jclass LDKCOption_u16Z_Some_class = NULL;
6912 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
6913 static jclass LDKCOption_u16Z_None_class = NULL;
6914 static jmethodID LDKCOption_u16Z_None_meth = NULL;
6915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
6916         LDKCOption_u16Z_Some_class =
6917                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
6918         CHECK(LDKCOption_u16Z_Some_class != NULL);
6919         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
6920         CHECK(LDKCOption_u16Z_Some_meth != NULL);
6921         LDKCOption_u16Z_None_class =
6922                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
6923         CHECK(LDKCOption_u16Z_None_class != NULL);
6924         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
6925         CHECK(LDKCOption_u16Z_None_meth != NULL);
6926 }
6927 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6928         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
6929         switch(obj->tag) {
6930                 case LDKCOption_u16Z_Some: {
6931                         int16_t some_conv = obj->some;
6932                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
6933                 }
6934                 case LDKCOption_u16Z_None: {
6935                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
6936                 }
6937                 default: abort();
6938         }
6939 }
6940 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6941 CHECK(owner->result_ok);
6942         return ThirtyTwoBytes_clone(&*owner->contents.result);
6943 }
6944 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6945         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6946         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6947         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
6948         return ret_arr;
6949 }
6950
6951 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6952 CHECK(!owner->result_ok);
6953         return APIError_clone(&*owner->contents.err);
6954 }
6955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6956         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6957         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6958         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
6959         int64_t ret_ref = tag_ptr(ret_copy, true);
6960         return ret_ref;
6961 }
6962
6963 static jclass LDKRecentPaymentDetails_Pending_class = NULL;
6964 static jmethodID LDKRecentPaymentDetails_Pending_meth = NULL;
6965 static jclass LDKRecentPaymentDetails_Fulfilled_class = NULL;
6966 static jmethodID LDKRecentPaymentDetails_Fulfilled_meth = NULL;
6967 static jclass LDKRecentPaymentDetails_Abandoned_class = NULL;
6968 static jmethodID LDKRecentPaymentDetails_Abandoned_meth = NULL;
6969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRecentPaymentDetails_init (JNIEnv *env, jclass clz) {
6970         LDKRecentPaymentDetails_Pending_class =
6971                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRecentPaymentDetails$Pending"));
6972         CHECK(LDKRecentPaymentDetails_Pending_class != NULL);
6973         LDKRecentPaymentDetails_Pending_meth = (*env)->GetMethodID(env, LDKRecentPaymentDetails_Pending_class, "<init>", "([BJ)V");
6974         CHECK(LDKRecentPaymentDetails_Pending_meth != NULL);
6975         LDKRecentPaymentDetails_Fulfilled_class =
6976                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRecentPaymentDetails$Fulfilled"));
6977         CHECK(LDKRecentPaymentDetails_Fulfilled_class != NULL);
6978         LDKRecentPaymentDetails_Fulfilled_meth = (*env)->GetMethodID(env, LDKRecentPaymentDetails_Fulfilled_class, "<init>", "([B)V");
6979         CHECK(LDKRecentPaymentDetails_Fulfilled_meth != NULL);
6980         LDKRecentPaymentDetails_Abandoned_class =
6981                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRecentPaymentDetails$Abandoned"));
6982         CHECK(LDKRecentPaymentDetails_Abandoned_class != NULL);
6983         LDKRecentPaymentDetails_Abandoned_meth = (*env)->GetMethodID(env, LDKRecentPaymentDetails_Abandoned_class, "<init>", "([B)V");
6984         CHECK(LDKRecentPaymentDetails_Abandoned_meth != NULL);
6985 }
6986 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRecentPaymentDetails_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6987         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
6988         switch(obj->tag) {
6989                 case LDKRecentPaymentDetails_Pending: {
6990                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
6991                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->pending.payment_hash.data);
6992                         int64_t total_msat_conv = obj->pending.total_msat;
6993                         return (*env)->NewObject(env, LDKRecentPaymentDetails_Pending_class, LDKRecentPaymentDetails_Pending_meth, payment_hash_arr, total_msat_conv);
6994                 }
6995                 case LDKRecentPaymentDetails_Fulfilled: {
6996                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
6997                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->fulfilled.payment_hash.data);
6998                         return (*env)->NewObject(env, LDKRecentPaymentDetails_Fulfilled_class, LDKRecentPaymentDetails_Fulfilled_meth, payment_hash_arr);
6999                 }
7000                 case LDKRecentPaymentDetails_Abandoned: {
7001                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
7002                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->abandoned.payment_hash.data);
7003                         return (*env)->NewObject(env, LDKRecentPaymentDetails_Abandoned_class, LDKRecentPaymentDetails_Abandoned_meth, payment_hash_arr);
7004                 }
7005                 default: abort();
7006         }
7007 }
7008 static inline LDKCVec_RecentPaymentDetailsZ CVec_RecentPaymentDetailsZ_clone(const LDKCVec_RecentPaymentDetailsZ *orig) {
7009         LDKCVec_RecentPaymentDetailsZ ret = { .data = MALLOC(sizeof(LDKRecentPaymentDetails) * orig->datalen, "LDKCVec_RecentPaymentDetailsZ clone bytes"), .datalen = orig->datalen };
7010         for (size_t i = 0; i < ret.datalen; i++) {
7011                 ret.data[i] = RecentPaymentDetails_clone(&orig->data[i]);
7012         }
7013         return ret;
7014 }
7015 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
7016 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
7017 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
7018 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
7019 static jclass LDKPaymentSendFailure_AllFailedResendSafe_class = NULL;
7020 static jmethodID LDKPaymentSendFailure_AllFailedResendSafe_meth = NULL;
7021 static jclass LDKPaymentSendFailure_DuplicatePayment_class = NULL;
7022 static jmethodID LDKPaymentSendFailure_DuplicatePayment_meth = NULL;
7023 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
7024 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
7025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
7026         LDKPaymentSendFailure_ParameterError_class =
7027                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
7028         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
7029         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
7030         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
7031         LDKPaymentSendFailure_PathParameterError_class =
7032                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
7033         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
7034         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
7035         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
7036         LDKPaymentSendFailure_AllFailedResendSafe_class =
7037                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedResendSafe"));
7038         CHECK(LDKPaymentSendFailure_AllFailedResendSafe_class != NULL);
7039         LDKPaymentSendFailure_AllFailedResendSafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedResendSafe_class, "<init>", "([J)V");
7040         CHECK(LDKPaymentSendFailure_AllFailedResendSafe_meth != NULL);
7041         LDKPaymentSendFailure_DuplicatePayment_class =
7042                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$DuplicatePayment"));
7043         CHECK(LDKPaymentSendFailure_DuplicatePayment_class != NULL);
7044         LDKPaymentSendFailure_DuplicatePayment_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_DuplicatePayment_class, "<init>", "()V");
7045         CHECK(LDKPaymentSendFailure_DuplicatePayment_meth != NULL);
7046         LDKPaymentSendFailure_PartialFailure_class =
7047                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
7048         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
7049         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
7050         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
7051 }
7052 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7053         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
7054         switch(obj->tag) {
7055                 case LDKPaymentSendFailure_ParameterError: {
7056                         int64_t parameter_error_ref = tag_ptr(&obj->parameter_error, false);
7057                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
7058                 }
7059                 case LDKPaymentSendFailure_PathParameterError: {
7060                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
7061                         int64_tArray path_parameter_error_arr = NULL;
7062                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
7063                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
7064                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
7065                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7066                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
7067                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
7068                                 path_parameter_error_arr_ptr[w] = tag_ptr(path_parameter_error_conv_22_conv, true);
7069                         }
7070                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
7071                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
7072                 }
7073                 case LDKPaymentSendFailure_AllFailedResendSafe: {
7074                         LDKCVec_APIErrorZ all_failed_resend_safe_var = obj->all_failed_resend_safe;
7075                         int64_tArray all_failed_resend_safe_arr = NULL;
7076                         all_failed_resend_safe_arr = (*env)->NewLongArray(env, all_failed_resend_safe_var.datalen);
7077                         int64_t *all_failed_resend_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_resend_safe_arr, NULL);
7078                         for (size_t k = 0; k < all_failed_resend_safe_var.datalen; k++) {
7079                                 int64_t all_failed_resend_safe_conv_10_ref = tag_ptr(&all_failed_resend_safe_var.data[k], false);
7080                                 all_failed_resend_safe_arr_ptr[k] = all_failed_resend_safe_conv_10_ref;
7081                         }
7082                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_resend_safe_arr, all_failed_resend_safe_arr_ptr, 0);
7083                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedResendSafe_class, LDKPaymentSendFailure_AllFailedResendSafe_meth, all_failed_resend_safe_arr);
7084                 }
7085                 case LDKPaymentSendFailure_DuplicatePayment: {
7086                         return (*env)->NewObject(env, LDKPaymentSendFailure_DuplicatePayment_class, LDKPaymentSendFailure_DuplicatePayment_meth);
7087                 }
7088                 case LDKPaymentSendFailure_PartialFailure: {
7089                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
7090                         int64_tArray results_arr = NULL;
7091                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
7092                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
7093                         for (size_t w = 0; w < results_var.datalen; w++) {
7094                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7095                                 *results_conv_22_conv = results_var.data[w];
7096                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
7097                                 results_arr_ptr[w] = tag_ptr(results_conv_22_conv, true);
7098                         }
7099                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
7100                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
7101                         int64_t failed_paths_retry_ref = 0;
7102                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
7103                         failed_paths_retry_ref = tag_ptr(failed_paths_retry_var.inner, false);
7104                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
7105                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
7106                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
7107                 }
7108                 default: abort();
7109         }
7110 }
7111 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
7112 CHECK(owner->result_ok);
7113         return *owner->contents.result;
7114 }
7115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7116         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
7117         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
7118 }
7119
7120 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
7121 CHECK(!owner->result_ok);
7122         return PaymentSendFailure_clone(&*owner->contents.err);
7123 }
7124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7125         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
7126         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
7127         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
7128         int64_t ret_ref = tag_ptr(ret_copy, true);
7129         return ret_ref;
7130 }
7131
7132 static inline void CResult_NoneRetryableSendFailureZ_get_ok(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR owner){
7133 CHECK(owner->result_ok);
7134         return *owner->contents.result;
7135 }
7136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7137         LDKCResult_NoneRetryableSendFailureZ* owner_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(owner);
7138         CResult_NoneRetryableSendFailureZ_get_ok(owner_conv);
7139 }
7140
7141 static inline enum LDKRetryableSendFailure CResult_NoneRetryableSendFailureZ_get_err(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR owner){
7142 CHECK(!owner->result_ok);
7143         return RetryableSendFailure_clone(&*owner->contents.err);
7144 }
7145 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7146         LDKCResult_NoneRetryableSendFailureZ* owner_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(owner);
7147         jclass ret_conv = LDKRetryableSendFailure_to_java(env, CResult_NoneRetryableSendFailureZ_get_err(owner_conv));
7148         return ret_conv;
7149 }
7150
7151 static inline struct LDKThirtyTwoBytes CResult_PaymentHashPaymentSendFailureZ_get_ok(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR owner){
7152 CHECK(owner->result_ok);
7153         return ThirtyTwoBytes_clone(&*owner->contents.result);
7154 }
7155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7156         LDKCResult_PaymentHashPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(owner);
7157         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7158         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentHashPaymentSendFailureZ_get_ok(owner_conv).data);
7159         return ret_arr;
7160 }
7161
7162 static inline struct LDKPaymentSendFailure CResult_PaymentHashPaymentSendFailureZ_get_err(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR owner){
7163 CHECK(!owner->result_ok);
7164         return PaymentSendFailure_clone(&*owner->contents.err);
7165 }
7166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7167         LDKCResult_PaymentHashPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(owner);
7168         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
7169         *ret_copy = CResult_PaymentHashPaymentSendFailureZ_get_err(owner_conv);
7170         int64_t ret_ref = tag_ptr(ret_copy, true);
7171         return ret_ref;
7172 }
7173
7174 static inline struct LDKThirtyTwoBytes CResult_PaymentHashRetryableSendFailureZ_get_ok(LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR owner){
7175 CHECK(owner->result_ok);
7176         return ThirtyTwoBytes_clone(&*owner->contents.result);
7177 }
7178 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7179         LDKCResult_PaymentHashRetryableSendFailureZ* owner_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(owner);
7180         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7181         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentHashRetryableSendFailureZ_get_ok(owner_conv).data);
7182         return ret_arr;
7183 }
7184
7185 static inline enum LDKRetryableSendFailure CResult_PaymentHashRetryableSendFailureZ_get_err(LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR owner){
7186 CHECK(!owner->result_ok);
7187         return RetryableSendFailure_clone(&*owner->contents.err);
7188 }
7189 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7190         LDKCResult_PaymentHashRetryableSendFailureZ* owner_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(owner);
7191         jclass ret_conv = LDKRetryableSendFailure_to_java(env, CResult_PaymentHashRetryableSendFailureZ_get_err(owner_conv));
7192         return ret_conv;
7193 }
7194
7195 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
7196         return ThirtyTwoBytes_clone(&owner->a);
7197 }
7198 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7199         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
7200         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7201         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
7202         return ret_arr;
7203 }
7204
7205 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
7206         return ThirtyTwoBytes_clone(&owner->b);
7207 }
7208 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7209         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
7210         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7211         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
7212         return ret_arr;
7213 }
7214
7215 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
7216 CHECK(owner->result_ok);
7217         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
7218 }
7219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7220         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
7221         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
7222         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
7223         return tag_ptr(ret_conv, true);
7224 }
7225
7226 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
7227 CHECK(!owner->result_ok);
7228         return PaymentSendFailure_clone(&*owner->contents.err);
7229 }
7230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7231         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
7232         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
7233         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
7234         int64_t ret_ref = tag_ptr(ret_copy, true);
7235         return ret_ref;
7236 }
7237
7238 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
7239         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
7240         for (size_t i = 0; i < ret.datalen; i++) {
7241                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
7242         }
7243         return ret;
7244 }
7245 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
7246         return ThirtyTwoBytes_clone(&owner->a);
7247 }
7248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7249         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
7250         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7251         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
7252         return ret_arr;
7253 }
7254
7255 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
7256         return ThirtyTwoBytes_clone(&owner->b);
7257 }
7258 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7259         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
7260         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7261         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
7262         return ret_arr;
7263 }
7264
7265 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
7266 CHECK(owner->result_ok);
7267         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
7268 }
7269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7270         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
7271         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
7272         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
7273         return tag_ptr(ret_conv, true);
7274 }
7275
7276 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
7277 CHECK(!owner->result_ok);
7278         return *owner->contents.err;
7279 }
7280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7281         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
7282         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
7283 }
7284
7285 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
7286 CHECK(owner->result_ok);
7287         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
7288 }
7289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7290         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
7291         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
7292         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
7293         return tag_ptr(ret_conv, true);
7294 }
7295
7296 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
7297 CHECK(!owner->result_ok);
7298         return APIError_clone(&*owner->contents.err);
7299 }
7300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7301         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
7302         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
7303         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
7304         int64_t ret_ref = tag_ptr(ret_copy, true);
7305         return ret_ref;
7306 }
7307
7308 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
7309 CHECK(owner->result_ok);
7310         return ThirtyTwoBytes_clone(&*owner->contents.result);
7311 }
7312 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7313         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
7314         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7315         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
7316         return ret_arr;
7317 }
7318
7319 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
7320 CHECK(!owner->result_ok);
7321         return *owner->contents.err;
7322 }
7323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7324         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
7325         CResult_PaymentSecretNoneZ_get_err(owner_conv);
7326 }
7327
7328 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
7329 CHECK(owner->result_ok);
7330         return ThirtyTwoBytes_clone(&*owner->contents.result);
7331 }
7332 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7333         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
7334         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7335         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
7336         return ret_arr;
7337 }
7338
7339 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
7340 CHECK(!owner->result_ok);
7341         return APIError_clone(&*owner->contents.err);
7342 }
7343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7344         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
7345         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
7346         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
7347         int64_t ret_ref = tag_ptr(ret_copy, true);
7348         return ret_ref;
7349 }
7350
7351 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
7352 CHECK(owner->result_ok);
7353         return ThirtyTwoBytes_clone(&*owner->contents.result);
7354 }
7355 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7356         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
7357         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7358         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
7359         return ret_arr;
7360 }
7361
7362 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
7363 CHECK(!owner->result_ok);
7364         return APIError_clone(&*owner->contents.err);
7365 }
7366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7367         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
7368         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
7369         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
7370         int64_t ret_ref = tag_ptr(ret_copy, true);
7371         return ret_ref;
7372 }
7373
7374 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
7375         LDKCounterpartyForwardingInfo ret = *owner->contents.result;
7376         ret.is_owned = false;
7377         return ret;
7378 }
7379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7380         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
7381         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
7382         int64_t ret_ref = 0;
7383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7384         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7385         return ret_ref;
7386 }
7387
7388 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
7389 CHECK(!owner->result_ok);
7390         return DecodeError_clone(&*owner->contents.err);
7391 }
7392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7393         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
7394         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7395         *ret_copy = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
7396         int64_t ret_ref = tag_ptr(ret_copy, true);
7397         return ret_ref;
7398 }
7399
7400 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
7401         LDKChannelCounterparty ret = *owner->contents.result;
7402         ret.is_owned = false;
7403         return ret;
7404 }
7405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7406         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
7407         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
7408         int64_t ret_ref = 0;
7409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7410         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7411         return ret_ref;
7412 }
7413
7414 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
7415 CHECK(!owner->result_ok);
7416         return DecodeError_clone(&*owner->contents.err);
7417 }
7418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7419         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
7420         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7421         *ret_copy = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
7422         int64_t ret_ref = tag_ptr(ret_copy, true);
7423         return ret_ref;
7424 }
7425
7426 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
7427         LDKChannelDetails ret = *owner->contents.result;
7428         ret.is_owned = false;
7429         return ret;
7430 }
7431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7432         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
7433         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
7434         int64_t ret_ref = 0;
7435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7436         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7437         return ret_ref;
7438 }
7439
7440 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
7441 CHECK(!owner->result_ok);
7442         return DecodeError_clone(&*owner->contents.err);
7443 }
7444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7445         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
7446         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7447         *ret_copy = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
7448         int64_t ret_ref = tag_ptr(ret_copy, true);
7449         return ret_ref;
7450 }
7451
7452 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
7453         LDKPhantomRouteHints ret = *owner->contents.result;
7454         ret.is_owned = false;
7455         return ret;
7456 }
7457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7458         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
7459         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
7460         int64_t ret_ref = 0;
7461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7462         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7463         return ret_ref;
7464 }
7465
7466 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
7467 CHECK(!owner->result_ok);
7468         return DecodeError_clone(&*owner->contents.err);
7469 }
7470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7471         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
7472         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7473         *ret_copy = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
7474         int64_t ret_ref = tag_ptr(ret_copy, true);
7475         return ret_ref;
7476 }
7477
7478 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
7479         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
7480         for (size_t i = 0; i < ret.datalen; i++) {
7481                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
7482         }
7483         return ret;
7484 }
7485 typedef struct LDKWatch_JCalls {
7486         atomic_size_t refcnt;
7487         JavaVM *vm;
7488         jweak o;
7489         jmethodID watch_channel_meth;
7490         jmethodID update_channel_meth;
7491         jmethodID release_pending_monitor_events_meth;
7492 } LDKWatch_JCalls;
7493 static void LDKWatch_JCalls_free(void* this_arg) {
7494         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7495         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7496                 JNIEnv *env;
7497                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7498                 if (get_jenv_res == JNI_EDETACHED) {
7499                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7500                 } else {
7501                         DO_ASSERT(get_jenv_res == JNI_OK);
7502                 }
7503                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7504                 if (get_jenv_res == JNI_EDETACHED) {
7505                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7506                 }
7507                 FREE(j_calls);
7508         }
7509 }
7510 LDKChannelMonitorUpdateStatus watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
7511         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7512         JNIEnv *env;
7513         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7514         if (get_jenv_res == JNI_EDETACHED) {
7515                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7516         } else {
7517                 DO_ASSERT(get_jenv_res == JNI_OK);
7518         }
7519         LDKOutPoint funding_txo_var = funding_txo;
7520         int64_t funding_txo_ref = 0;
7521         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
7522         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
7523         LDKChannelMonitor monitor_var = monitor;
7524         int64_t monitor_ref = 0;
7525         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
7526         monitor_ref = tag_ptr(monitor_var.inner, monitor_var.is_owned);
7527         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7528         CHECK(obj != NULL);
7529         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
7530         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7531                 (*env)->ExceptionDescribe(env);
7532                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
7533         }
7534         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
7535         if (get_jenv_res == JNI_EDETACHED) {
7536                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7537         }
7538         return ret_conv;
7539 }
7540 LDKChannelMonitorUpdateStatus update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, const LDKChannelMonitorUpdate * update) {
7541         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7542         JNIEnv *env;
7543         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7544         if (get_jenv_res == JNI_EDETACHED) {
7545                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7546         } else {
7547                 DO_ASSERT(get_jenv_res == JNI_OK);
7548         }
7549         LDKOutPoint funding_txo_var = funding_txo;
7550         int64_t funding_txo_ref = 0;
7551         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
7552         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
7553         LDKChannelMonitorUpdate update_var = *update;
7554         int64_t update_ref = 0;
7555         update_var = ChannelMonitorUpdate_clone(&update_var);
7556         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
7557         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
7558         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7559         CHECK(obj != NULL);
7560         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
7561         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7562                 (*env)->ExceptionDescribe(env);
7563                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
7564         }
7565         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
7566         if (get_jenv_res == JNI_EDETACHED) {
7567                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7568         }
7569         return ret_conv;
7570 }
7571 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
7572         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7573         JNIEnv *env;
7574         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7575         if (get_jenv_res == JNI_EDETACHED) {
7576                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7577         } else {
7578                 DO_ASSERT(get_jenv_res == JNI_OK);
7579         }
7580         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7581         CHECK(obj != NULL);
7582         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
7583         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7584                 (*env)->ExceptionDescribe(env);
7585                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
7586         }
7587         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
7588         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7589         if (ret_constr.datalen > 0)
7590                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
7591         else
7592                 ret_constr.data = NULL;
7593         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7594         for (size_t x = 0; x < ret_constr.datalen; x++) {
7595                 int64_t ret_conv_49 = ret_vals[x];
7596                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
7597                 CHECK_ACCESS(ret_conv_49_ptr);
7598                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
7599                 FREE(untag_ptr(ret_conv_49));
7600                 ret_constr.data[x] = ret_conv_49_conv;
7601         }
7602         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7603         if (get_jenv_res == JNI_EDETACHED) {
7604                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7605         }
7606         return ret_constr;
7607 }
7608 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
7609         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
7610         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7611 }
7612 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
7613         jclass c = (*env)->GetObjectClass(env, o);
7614         CHECK(c != NULL);
7615         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
7616         atomic_init(&calls->refcnt, 1);
7617         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7618         calls->o = (*env)->NewWeakGlobalRef(env, o);
7619         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
7620         CHECK(calls->watch_channel_meth != NULL);
7621         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
7622         CHECK(calls->update_channel_meth != NULL);
7623         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
7624         CHECK(calls->release_pending_monitor_events_meth != NULL);
7625
7626         LDKWatch ret = {
7627                 .this_arg = (void*) calls,
7628                 .watch_channel = watch_channel_LDKWatch_jcall,
7629                 .update_channel = update_channel_LDKWatch_jcall,
7630                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
7631                 .free = LDKWatch_JCalls_free,
7632         };
7633         return ret;
7634 }
7635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
7636         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
7637         *res_ptr = LDKWatch_init(env, clz, o);
7638         return tag_ptr(res_ptr, true);
7639 }
7640 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) {
7641         void* this_arg_ptr = untag_ptr(this_arg);
7642         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7643         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7644         LDKOutPoint funding_txo_conv;
7645         funding_txo_conv.inner = untag_ptr(funding_txo);
7646         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
7647         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
7648         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
7649         LDKChannelMonitor monitor_conv;
7650         monitor_conv.inner = untag_ptr(monitor);
7651         monitor_conv.is_owned = ptr_is_owned(monitor);
7652         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
7653         monitor_conv = ChannelMonitor_clone(&monitor_conv);
7654         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv));
7655         return ret_conv;
7656 }
7657
7658 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) {
7659         void* this_arg_ptr = untag_ptr(this_arg);
7660         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7661         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7662         LDKOutPoint funding_txo_conv;
7663         funding_txo_conv.inner = untag_ptr(funding_txo);
7664         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
7665         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
7666         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
7667         LDKChannelMonitorUpdate update_conv;
7668         update_conv.inner = untag_ptr(update);
7669         update_conv.is_owned = ptr_is_owned(update);
7670         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
7671         update_conv.is_owned = false;
7672         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, &update_conv));
7673         return ret_conv;
7674 }
7675
7676 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7677         void* this_arg_ptr = untag_ptr(this_arg);
7678         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7679         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7680         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
7681         int64_tArray ret_arr = NULL;
7682         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7683         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7684         for (size_t x = 0; x < ret_var.datalen; x++) {
7685                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
7686                 *ret_conv_49_conv = ret_var.data[x];
7687                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
7688         }
7689         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7690         FREE(ret_var.data);
7691         return ret_arr;
7692 }
7693
7694 typedef struct LDKBroadcasterInterface_JCalls {
7695         atomic_size_t refcnt;
7696         JavaVM *vm;
7697         jweak o;
7698         jmethodID broadcast_transaction_meth;
7699 } LDKBroadcasterInterface_JCalls;
7700 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
7701         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7702         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7703                 JNIEnv *env;
7704                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7705                 if (get_jenv_res == JNI_EDETACHED) {
7706                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7707                 } else {
7708                         DO_ASSERT(get_jenv_res == JNI_OK);
7709                 }
7710                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7711                 if (get_jenv_res == JNI_EDETACHED) {
7712                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7713                 }
7714                 FREE(j_calls);
7715         }
7716 }
7717 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
7718         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7719         JNIEnv *env;
7720         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7721         if (get_jenv_res == JNI_EDETACHED) {
7722                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7723         } else {
7724                 DO_ASSERT(get_jenv_res == JNI_OK);
7725         }
7726         LDKTransaction tx_var = tx;
7727         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
7728         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
7729         Transaction_free(tx_var);
7730         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7731         CHECK(obj != NULL);
7732         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
7733         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7734                 (*env)->ExceptionDescribe(env);
7735                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
7736         }
7737         if (get_jenv_res == JNI_EDETACHED) {
7738                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7739         }
7740 }
7741 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
7742         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
7743         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7744 }
7745 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
7746         jclass c = (*env)->GetObjectClass(env, o);
7747         CHECK(c != NULL);
7748         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
7749         atomic_init(&calls->refcnt, 1);
7750         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7751         calls->o = (*env)->NewWeakGlobalRef(env, o);
7752         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
7753         CHECK(calls->broadcast_transaction_meth != NULL);
7754
7755         LDKBroadcasterInterface ret = {
7756                 .this_arg = (void*) calls,
7757                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
7758                 .free = LDKBroadcasterInterface_JCalls_free,
7759         };
7760         return ret;
7761 }
7762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7763         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
7764         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
7765         return tag_ptr(res_ptr, true);
7766 }
7767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
7768         void* this_arg_ptr = untag_ptr(this_arg);
7769         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7770         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
7771         LDKTransaction tx_ref;
7772         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
7773         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
7774         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
7775         tx_ref.data_is_owned = true;
7776         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
7777 }
7778
7779 typedef struct LDKEntropySource_JCalls {
7780         atomic_size_t refcnt;
7781         JavaVM *vm;
7782         jweak o;
7783         jmethodID get_secure_random_bytes_meth;
7784 } LDKEntropySource_JCalls;
7785 static void LDKEntropySource_JCalls_free(void* this_arg) {
7786         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) this_arg;
7787         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7788                 JNIEnv *env;
7789                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7790                 if (get_jenv_res == JNI_EDETACHED) {
7791                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7792                 } else {
7793                         DO_ASSERT(get_jenv_res == JNI_OK);
7794                 }
7795                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7796                 if (get_jenv_res == JNI_EDETACHED) {
7797                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7798                 }
7799                 FREE(j_calls);
7800         }
7801 }
7802 LDKThirtyTwoBytes get_secure_random_bytes_LDKEntropySource_jcall(const void* this_arg) {
7803         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) this_arg;
7804         JNIEnv *env;
7805         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7806         if (get_jenv_res == JNI_EDETACHED) {
7807                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7808         } else {
7809                 DO_ASSERT(get_jenv_res == JNI_OK);
7810         }
7811         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7812         CHECK(obj != NULL);
7813         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
7814         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7815                 (*env)->ExceptionDescribe(env);
7816                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKEntropySource from rust threw an exception.");
7817         }
7818         LDKThirtyTwoBytes ret_ref;
7819         CHECK((*env)->GetArrayLength(env, ret) == 32);
7820         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7821         if (get_jenv_res == JNI_EDETACHED) {
7822                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7823         }
7824         return ret_ref;
7825 }
7826 static void LDKEntropySource_JCalls_cloned(LDKEntropySource* new_obj) {
7827         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) new_obj->this_arg;
7828         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7829 }
7830 static inline LDKEntropySource LDKEntropySource_init (JNIEnv *env, jclass clz, jobject o) {
7831         jclass c = (*env)->GetObjectClass(env, o);
7832         CHECK(c != NULL);
7833         LDKEntropySource_JCalls *calls = MALLOC(sizeof(LDKEntropySource_JCalls), "LDKEntropySource_JCalls");
7834         atomic_init(&calls->refcnt, 1);
7835         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7836         calls->o = (*env)->NewWeakGlobalRef(env, o);
7837         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
7838         CHECK(calls->get_secure_random_bytes_meth != NULL);
7839
7840         LDKEntropySource ret = {
7841                 .this_arg = (void*) calls,
7842                 .get_secure_random_bytes = get_secure_random_bytes_LDKEntropySource_jcall,
7843                 .free = LDKEntropySource_JCalls_free,
7844         };
7845         return ret;
7846 }
7847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEntropySource_1new(JNIEnv *env, jclass clz, jobject o) {
7848         LDKEntropySource *res_ptr = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
7849         *res_ptr = LDKEntropySource_init(env, clz, o);
7850         return tag_ptr(res_ptr, true);
7851 }
7852 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_EntropySource_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
7853         void* this_arg_ptr = untag_ptr(this_arg);
7854         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7855         LDKEntropySource* this_arg_conv = (LDKEntropySource*)this_arg_ptr;
7856         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7857         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
7858         return ret_arr;
7859 }
7860
7861 static jclass LDKUnsignedGossipMessage_ChannelAnnouncement_class = NULL;
7862 static jmethodID LDKUnsignedGossipMessage_ChannelAnnouncement_meth = NULL;
7863 static jclass LDKUnsignedGossipMessage_ChannelUpdate_class = NULL;
7864 static jmethodID LDKUnsignedGossipMessage_ChannelUpdate_meth = NULL;
7865 static jclass LDKUnsignedGossipMessage_NodeAnnouncement_class = NULL;
7866 static jmethodID LDKUnsignedGossipMessage_NodeAnnouncement_meth = NULL;
7867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKUnsignedGossipMessage_init (JNIEnv *env, jclass clz) {
7868         LDKUnsignedGossipMessage_ChannelAnnouncement_class =
7869                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUnsignedGossipMessage$ChannelAnnouncement"));
7870         CHECK(LDKUnsignedGossipMessage_ChannelAnnouncement_class != NULL);
7871         LDKUnsignedGossipMessage_ChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKUnsignedGossipMessage_ChannelAnnouncement_class, "<init>", "(J)V");
7872         CHECK(LDKUnsignedGossipMessage_ChannelAnnouncement_meth != NULL);
7873         LDKUnsignedGossipMessage_ChannelUpdate_class =
7874                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUnsignedGossipMessage$ChannelUpdate"));
7875         CHECK(LDKUnsignedGossipMessage_ChannelUpdate_class != NULL);
7876         LDKUnsignedGossipMessage_ChannelUpdate_meth = (*env)->GetMethodID(env, LDKUnsignedGossipMessage_ChannelUpdate_class, "<init>", "(J)V");
7877         CHECK(LDKUnsignedGossipMessage_ChannelUpdate_meth != NULL);
7878         LDKUnsignedGossipMessage_NodeAnnouncement_class =
7879                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKUnsignedGossipMessage$NodeAnnouncement"));
7880         CHECK(LDKUnsignedGossipMessage_NodeAnnouncement_class != NULL);
7881         LDKUnsignedGossipMessage_NodeAnnouncement_meth = (*env)->GetMethodID(env, LDKUnsignedGossipMessage_NodeAnnouncement_class, "<init>", "(J)V");
7882         CHECK(LDKUnsignedGossipMessage_NodeAnnouncement_meth != NULL);
7883 }
7884 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKUnsignedGossipMessage_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7885         LDKUnsignedGossipMessage *obj = (LDKUnsignedGossipMessage*)untag_ptr(ptr);
7886         switch(obj->tag) {
7887                 case LDKUnsignedGossipMessage_ChannelAnnouncement: {
7888                         LDKUnsignedChannelAnnouncement channel_announcement_var = obj->channel_announcement;
7889                         int64_t channel_announcement_ref = 0;
7890                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_announcement_var);
7891                         channel_announcement_ref = tag_ptr(channel_announcement_var.inner, false);
7892                         return (*env)->NewObject(env, LDKUnsignedGossipMessage_ChannelAnnouncement_class, LDKUnsignedGossipMessage_ChannelAnnouncement_meth, channel_announcement_ref);
7893                 }
7894                 case LDKUnsignedGossipMessage_ChannelUpdate: {
7895                         LDKUnsignedChannelUpdate channel_update_var = obj->channel_update;
7896                         int64_t channel_update_ref = 0;
7897                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_update_var);
7898                         channel_update_ref = tag_ptr(channel_update_var.inner, false);
7899                         return (*env)->NewObject(env, LDKUnsignedGossipMessage_ChannelUpdate_class, LDKUnsignedGossipMessage_ChannelUpdate_meth, channel_update_ref);
7900                 }
7901                 case LDKUnsignedGossipMessage_NodeAnnouncement: {
7902                         LDKUnsignedNodeAnnouncement node_announcement_var = obj->node_announcement;
7903                         int64_t node_announcement_ref = 0;
7904                         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_announcement_var);
7905                         node_announcement_ref = tag_ptr(node_announcement_var.inner, false);
7906                         return (*env)->NewObject(env, LDKUnsignedGossipMessage_NodeAnnouncement_class, LDKUnsignedGossipMessage_NodeAnnouncement_meth, node_announcement_ref);
7907                 }
7908                 default: abort();
7909         }
7910 }
7911 typedef struct LDKNodeSigner_JCalls {
7912         atomic_size_t refcnt;
7913         JavaVM *vm;
7914         jweak o;
7915         jmethodID get_inbound_payment_key_material_meth;
7916         jmethodID get_node_id_meth;
7917         jmethodID ecdh_meth;
7918         jmethodID sign_invoice_meth;
7919         jmethodID sign_gossip_message_meth;
7920 } LDKNodeSigner_JCalls;
7921 static void LDKNodeSigner_JCalls_free(void* this_arg) {
7922         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
7923         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7924                 JNIEnv *env;
7925                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7926                 if (get_jenv_res == JNI_EDETACHED) {
7927                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7928                 } else {
7929                         DO_ASSERT(get_jenv_res == JNI_OK);
7930                 }
7931                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7932                 if (get_jenv_res == JNI_EDETACHED) {
7933                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7934                 }
7935                 FREE(j_calls);
7936         }
7937 }
7938 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKNodeSigner_jcall(const void* this_arg) {
7939         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
7940         JNIEnv *env;
7941         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7942         if (get_jenv_res == JNI_EDETACHED) {
7943                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7944         } else {
7945                 DO_ASSERT(get_jenv_res == JNI_OK);
7946         }
7947         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7948         CHECK(obj != NULL);
7949         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
7950         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7951                 (*env)->ExceptionDescribe(env);
7952                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKNodeSigner from rust threw an exception.");
7953         }
7954         LDKThirtyTwoBytes ret_ref;
7955         CHECK((*env)->GetArrayLength(env, ret) == 32);
7956         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7957         if (get_jenv_res == JNI_EDETACHED) {
7958                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7959         }
7960         return ret_ref;
7961 }
7962 LDKCResult_PublicKeyNoneZ get_node_id_LDKNodeSigner_jcall(const void* this_arg, LDKRecipient recipient) {
7963         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
7964         JNIEnv *env;
7965         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7966         if (get_jenv_res == JNI_EDETACHED) {
7967                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7968         } else {
7969                 DO_ASSERT(get_jenv_res == JNI_OK);
7970         }
7971         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7972         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7973         CHECK(obj != NULL);
7974         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_id_meth, recipient_conv);
7975         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7976                 (*env)->ExceptionDescribe(env);
7977                 (*env)->FatalError(env, "A call to get_node_id in LDKNodeSigner from rust threw an exception.");
7978         }
7979         void* ret_ptr = untag_ptr(ret);
7980         CHECK_ACCESS(ret_ptr);
7981         LDKCResult_PublicKeyNoneZ ret_conv = *(LDKCResult_PublicKeyNoneZ*)(ret_ptr);
7982         FREE(untag_ptr(ret));
7983         if (get_jenv_res == JNI_EDETACHED) {
7984                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7985         }
7986         return ret_conv;
7987 }
7988 LDKCResult_SharedSecretNoneZ ecdh_LDKNodeSigner_jcall(const void* this_arg, LDKRecipient recipient, LDKPublicKey other_key, LDKCOption_ScalarZ tweak) {
7989         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
7990         JNIEnv *env;
7991         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7992         if (get_jenv_res == JNI_EDETACHED) {
7993                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7994         } else {
7995                 DO_ASSERT(get_jenv_res == JNI_OK);
7996         }
7997         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7998         int8_tArray other_key_arr = (*env)->NewByteArray(env, 33);
7999         (*env)->SetByteArrayRegion(env, other_key_arr, 0, 33, other_key.compressed_form);
8000         LDKCOption_ScalarZ *tweak_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
8001         *tweak_copy = tweak;
8002         int64_t tweak_ref = tag_ptr(tweak_copy, true);
8003         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8004         CHECK(obj != NULL);
8005         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->ecdh_meth, recipient_conv, other_key_arr, tweak_ref);
8006         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8007                 (*env)->ExceptionDescribe(env);
8008                 (*env)->FatalError(env, "A call to ecdh in LDKNodeSigner from rust threw an exception.");
8009         }
8010         void* ret_ptr = untag_ptr(ret);
8011         CHECK_ACCESS(ret_ptr);
8012         LDKCResult_SharedSecretNoneZ ret_conv = *(LDKCResult_SharedSecretNoneZ*)(ret_ptr);
8013         FREE(untag_ptr(ret));
8014         if (get_jenv_res == JNI_EDETACHED) {
8015                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8016         }
8017         return ret_conv;
8018 }
8019 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKNodeSigner_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_U5Z invoice_data, LDKRecipient recipient) {
8020         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
8021         JNIEnv *env;
8022         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8023         if (get_jenv_res == JNI_EDETACHED) {
8024                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8025         } else {
8026                 DO_ASSERT(get_jenv_res == JNI_OK);
8027         }
8028         LDKu8slice hrp_bytes_var = hrp_bytes;
8029         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
8030         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
8031         LDKCVec_U5Z invoice_data_var = invoice_data;
8032         jobjectArray invoice_data_arr = NULL;
8033         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
8034         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
8035         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
8036                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
8037                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
8038         }
8039         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
8040         FREE(invoice_data_var.data);
8041         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
8042         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8043         CHECK(obj != NULL);
8044         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, recipient_conv);
8045         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8046                 (*env)->ExceptionDescribe(env);
8047                 (*env)->FatalError(env, "A call to sign_invoice in LDKNodeSigner from rust threw an exception.");
8048         }
8049         void* ret_ptr = untag_ptr(ret);
8050         CHECK_ACCESS(ret_ptr);
8051         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
8052         FREE(untag_ptr(ret));
8053         if (get_jenv_res == JNI_EDETACHED) {
8054                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8055         }
8056         return ret_conv;
8057 }
8058 LDKCResult_SignatureNoneZ sign_gossip_message_LDKNodeSigner_jcall(const void* this_arg, LDKUnsignedGossipMessage msg) {
8059         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
8060         JNIEnv *env;
8061         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8062         if (get_jenv_res == JNI_EDETACHED) {
8063                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8064         } else {
8065                 DO_ASSERT(get_jenv_res == JNI_OK);
8066         }
8067         LDKUnsignedGossipMessage *msg_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
8068         *msg_copy = msg;
8069         int64_t msg_ref = tag_ptr(msg_copy, true);
8070         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8071         CHECK(obj != NULL);
8072         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_gossip_message_meth, msg_ref);
8073         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8074                 (*env)->ExceptionDescribe(env);
8075                 (*env)->FatalError(env, "A call to sign_gossip_message in LDKNodeSigner from rust threw an exception.");
8076         }
8077         void* ret_ptr = untag_ptr(ret);
8078         CHECK_ACCESS(ret_ptr);
8079         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
8080         FREE(untag_ptr(ret));
8081         if (get_jenv_res == JNI_EDETACHED) {
8082                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8083         }
8084         return ret_conv;
8085 }
8086 static void LDKNodeSigner_JCalls_cloned(LDKNodeSigner* new_obj) {
8087         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) new_obj->this_arg;
8088         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8089 }
8090 static inline LDKNodeSigner LDKNodeSigner_init (JNIEnv *env, jclass clz, jobject o) {
8091         jclass c = (*env)->GetObjectClass(env, o);
8092         CHECK(c != NULL);
8093         LDKNodeSigner_JCalls *calls = MALLOC(sizeof(LDKNodeSigner_JCalls), "LDKNodeSigner_JCalls");
8094         atomic_init(&calls->refcnt, 1);
8095         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8096         calls->o = (*env)->NewWeakGlobalRef(env, o);
8097         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
8098         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
8099         calls->get_node_id_meth = (*env)->GetMethodID(env, c, "get_node_id", "(Lorg/ldk/enums/Recipient;)J");
8100         CHECK(calls->get_node_id_meth != NULL);
8101         calls->ecdh_meth = (*env)->GetMethodID(env, c, "ecdh", "(Lorg/ldk/enums/Recipient;[BJ)J");
8102         CHECK(calls->ecdh_meth != NULL);
8103         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
8104         CHECK(calls->sign_invoice_meth != NULL);
8105         calls->sign_gossip_message_meth = (*env)->GetMethodID(env, c, "sign_gossip_message", "(J)J");
8106         CHECK(calls->sign_gossip_message_meth != NULL);
8107
8108         LDKNodeSigner ret = {
8109                 .this_arg = (void*) calls,
8110                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKNodeSigner_jcall,
8111                 .get_node_id = get_node_id_LDKNodeSigner_jcall,
8112                 .ecdh = ecdh_LDKNodeSigner_jcall,
8113                 .sign_invoice = sign_invoice_LDKNodeSigner_jcall,
8114                 .sign_gossip_message = sign_gossip_message_LDKNodeSigner_jcall,
8115                 .free = LDKNodeSigner_JCalls_free,
8116         };
8117         return ret;
8118 }
8119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKNodeSigner_1new(JNIEnv *env, jclass clz, jobject o) {
8120         LDKNodeSigner *res_ptr = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
8121         *res_ptr = LDKNodeSigner_init(env, clz, o);
8122         return tag_ptr(res_ptr, true);
8123 }
8124 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeSigner_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
8125         void* this_arg_ptr = untag_ptr(this_arg);
8126         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8127         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
8128         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8129         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
8130         return ret_arr;
8131 }
8132
8133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeSigner_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
8134         void* this_arg_ptr = untag_ptr(this_arg);
8135         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8136         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
8137         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
8138         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
8139         *ret_conv = (this_arg_conv->get_node_id)(this_arg_conv->this_arg, recipient_conv);
8140         return tag_ptr(ret_conv, true);
8141 }
8142
8143 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) {
8144         void* this_arg_ptr = untag_ptr(this_arg);
8145         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8146         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
8147         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
8148         LDKPublicKey other_key_ref;
8149         CHECK((*env)->GetArrayLength(env, other_key) == 33);
8150         (*env)->GetByteArrayRegion(env, other_key, 0, 33, other_key_ref.compressed_form);
8151         void* tweak_ptr = untag_ptr(tweak);
8152         CHECK_ACCESS(tweak_ptr);
8153         LDKCOption_ScalarZ tweak_conv = *(LDKCOption_ScalarZ*)(tweak_ptr);
8154         tweak_conv = COption_ScalarZ_clone((LDKCOption_ScalarZ*)untag_ptr(tweak));
8155         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
8156         *ret_conv = (this_arg_conv->ecdh)(this_arg_conv->this_arg, recipient_conv, other_key_ref, tweak_conv);
8157         return tag_ptr(ret_conv, true);
8158 }
8159
8160 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) {
8161         void* this_arg_ptr = untag_ptr(this_arg);
8162         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8163         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
8164         LDKu8slice hrp_bytes_ref;
8165         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
8166         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
8167         LDKCVec_U5Z invoice_data_constr;
8168         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
8169         if (invoice_data_constr.datalen > 0)
8170                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
8171         else
8172                 invoice_data_constr.data = NULL;
8173         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
8174         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
8175                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
8176                 
8177                 invoice_data_constr.data[h] = (LDKU5){ ._0 = invoice_data_conv_7 };
8178         }
8179         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
8180         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
8181         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
8182         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, recipient_conv);
8183         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
8184         return tag_ptr(ret_conv, true);
8185 }
8186
8187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeSigner_1sign_1gossip_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8188         void* this_arg_ptr = untag_ptr(this_arg);
8189         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8190         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
8191         void* msg_ptr = untag_ptr(msg);
8192         CHECK_ACCESS(msg_ptr);
8193         LDKUnsignedGossipMessage msg_conv = *(LDKUnsignedGossipMessage*)(msg_ptr);
8194         msg_conv = UnsignedGossipMessage_clone((LDKUnsignedGossipMessage*)untag_ptr(msg));
8195         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8196         *ret_conv = (this_arg_conv->sign_gossip_message)(this_arg_conv->this_arg, msg_conv);
8197         return tag_ptr(ret_conv, true);
8198 }
8199
8200 typedef struct LDKSignerProvider_JCalls {
8201         atomic_size_t refcnt;
8202         JavaVM *vm;
8203         jweak o;
8204         jmethodID generate_channel_keys_id_meth;
8205         jmethodID derive_channel_signer_meth;
8206         jmethodID read_chan_signer_meth;
8207         jmethodID get_destination_script_meth;
8208         jmethodID get_shutdown_scriptpubkey_meth;
8209 } LDKSignerProvider_JCalls;
8210 static void LDKSignerProvider_JCalls_free(void* this_arg) {
8211         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8212         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8213                 JNIEnv *env;
8214                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8215                 if (get_jenv_res == JNI_EDETACHED) {
8216                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8217                 } else {
8218                         DO_ASSERT(get_jenv_res == JNI_OK);
8219                 }
8220                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8221                 if (get_jenv_res == JNI_EDETACHED) {
8222                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8223                 }
8224                 FREE(j_calls);
8225         }
8226 }
8227 LDKThirtyTwoBytes generate_channel_keys_id_LDKSignerProvider_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis, LDKU128 user_channel_id) {
8228         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8229         JNIEnv *env;
8230         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8231         if (get_jenv_res == JNI_EDETACHED) {
8232                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8233         } else {
8234                 DO_ASSERT(get_jenv_res == JNI_OK);
8235         }
8236         jboolean inbound_conv = inbound;
8237         int64_t channel_value_satoshis_conv = channel_value_satoshis;
8238         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
8239         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, user_channel_id.le_bytes);
8240         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8241         CHECK(obj != NULL);
8242         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->generate_channel_keys_id_meth, inbound_conv, channel_value_satoshis_conv, user_channel_id_arr);
8243         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8244                 (*env)->ExceptionDescribe(env);
8245                 (*env)->FatalError(env, "A call to generate_channel_keys_id in LDKSignerProvider from rust threw an exception.");
8246         }
8247         LDKThirtyTwoBytes ret_ref;
8248         CHECK((*env)->GetArrayLength(env, ret) == 32);
8249         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
8250         if (get_jenv_res == JNI_EDETACHED) {
8251                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8252         }
8253         return ret_ref;
8254 }
8255 LDKWriteableEcdsaChannelSigner derive_channel_signer_LDKSignerProvider_jcall(const void* this_arg, uint64_t channel_value_satoshis, LDKThirtyTwoBytes channel_keys_id) {
8256         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8257         JNIEnv *env;
8258         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8259         if (get_jenv_res == JNI_EDETACHED) {
8260                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8261         } else {
8262                 DO_ASSERT(get_jenv_res == JNI_OK);
8263         }
8264         int64_t channel_value_satoshis_conv = channel_value_satoshis;
8265         int8_tArray channel_keys_id_arr = (*env)->NewByteArray(env, 32);
8266         (*env)->SetByteArrayRegion(env, channel_keys_id_arr, 0, 32, channel_keys_id.data);
8267         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8268         CHECK(obj != NULL);
8269         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->derive_channel_signer_meth, channel_value_satoshis_conv, channel_keys_id_arr);
8270         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8271                 (*env)->ExceptionDescribe(env);
8272                 (*env)->FatalError(env, "A call to derive_channel_signer in LDKSignerProvider from rust threw an exception.");
8273         }
8274         void* ret_ptr = untag_ptr(ret);
8275         CHECK_ACCESS(ret_ptr);
8276         LDKWriteableEcdsaChannelSigner ret_conv = *(LDKWriteableEcdsaChannelSigner*)(ret_ptr);
8277         FREE(untag_ptr(ret));
8278         if (get_jenv_res == JNI_EDETACHED) {
8279                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8280         }
8281         return ret_conv;
8282 }
8283 LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ read_chan_signer_LDKSignerProvider_jcall(const void* this_arg, LDKu8slice reader) {
8284         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8285         JNIEnv *env;
8286         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8287         if (get_jenv_res == JNI_EDETACHED) {
8288                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8289         } else {
8290                 DO_ASSERT(get_jenv_res == JNI_OK);
8291         }
8292         LDKu8slice reader_var = reader;
8293         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
8294         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
8295         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8296         CHECK(obj != NULL);
8297         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
8298         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8299                 (*env)->ExceptionDescribe(env);
8300                 (*env)->FatalError(env, "A call to read_chan_signer in LDKSignerProvider from rust threw an exception.");
8301         }
8302         void* ret_ptr = untag_ptr(ret);
8303         CHECK_ACCESS(ret_ptr);
8304         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ ret_conv = *(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)(ret_ptr);
8305         FREE(untag_ptr(ret));
8306         if (get_jenv_res == JNI_EDETACHED) {
8307                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8308         }
8309         return ret_conv;
8310 }
8311 LDKCVec_u8Z get_destination_script_LDKSignerProvider_jcall(const void* this_arg) {
8312         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8313         JNIEnv *env;
8314         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8315         if (get_jenv_res == JNI_EDETACHED) {
8316                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8317         } else {
8318                 DO_ASSERT(get_jenv_res == JNI_OK);
8319         }
8320         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8321         CHECK(obj != NULL);
8322         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
8323         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8324                 (*env)->ExceptionDescribe(env);
8325                 (*env)->FatalError(env, "A call to get_destination_script in LDKSignerProvider from rust threw an exception.");
8326         }
8327         LDKCVec_u8Z ret_ref;
8328         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
8329         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8330         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
8331         if (get_jenv_res == JNI_EDETACHED) {
8332                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8333         }
8334         return ret_ref;
8335 }
8336 LDKShutdownScript get_shutdown_scriptpubkey_LDKSignerProvider_jcall(const void* this_arg) {
8337         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
8338         JNIEnv *env;
8339         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8340         if (get_jenv_res == JNI_EDETACHED) {
8341                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8342         } else {
8343                 DO_ASSERT(get_jenv_res == JNI_OK);
8344         }
8345         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8346         CHECK(obj != NULL);
8347         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
8348         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8349                 (*env)->ExceptionDescribe(env);
8350                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKSignerProvider from rust threw an exception.");
8351         }
8352         LDKShutdownScript ret_conv;
8353         ret_conv.inner = untag_ptr(ret);
8354         ret_conv.is_owned = ptr_is_owned(ret);
8355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
8356         if (get_jenv_res == JNI_EDETACHED) {
8357                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8358         }
8359         return ret_conv;
8360 }
8361 static void LDKSignerProvider_JCalls_cloned(LDKSignerProvider* new_obj) {
8362         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) new_obj->this_arg;
8363         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8364 }
8365 static inline LDKSignerProvider LDKSignerProvider_init (JNIEnv *env, jclass clz, jobject o) {
8366         jclass c = (*env)->GetObjectClass(env, o);
8367         CHECK(c != NULL);
8368         LDKSignerProvider_JCalls *calls = MALLOC(sizeof(LDKSignerProvider_JCalls), "LDKSignerProvider_JCalls");
8369         atomic_init(&calls->refcnt, 1);
8370         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8371         calls->o = (*env)->NewWeakGlobalRef(env, o);
8372         calls->generate_channel_keys_id_meth = (*env)->GetMethodID(env, c, "generate_channel_keys_id", "(ZJ[B)[B");
8373         CHECK(calls->generate_channel_keys_id_meth != NULL);
8374         calls->derive_channel_signer_meth = (*env)->GetMethodID(env, c, "derive_channel_signer", "(J[B)J");
8375         CHECK(calls->derive_channel_signer_meth != NULL);
8376         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
8377         CHECK(calls->read_chan_signer_meth != NULL);
8378         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
8379         CHECK(calls->get_destination_script_meth != NULL);
8380         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
8381         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
8382
8383         LDKSignerProvider ret = {
8384                 .this_arg = (void*) calls,
8385                 .generate_channel_keys_id = generate_channel_keys_id_LDKSignerProvider_jcall,
8386                 .derive_channel_signer = derive_channel_signer_LDKSignerProvider_jcall,
8387                 .read_chan_signer = read_chan_signer_LDKSignerProvider_jcall,
8388                 .get_destination_script = get_destination_script_LDKSignerProvider_jcall,
8389                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKSignerProvider_jcall,
8390                 .free = LDKSignerProvider_JCalls_free,
8391         };
8392         return ret;
8393 }
8394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSignerProvider_1new(JNIEnv *env, jclass clz, jobject o) {
8395         LDKSignerProvider *res_ptr = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
8396         *res_ptr = LDKSignerProvider_init(env, clz, o);
8397         return tag_ptr(res_ptr, true);
8398 }
8399 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) {
8400         void* this_arg_ptr = untag_ptr(this_arg);
8401         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8402         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8403         LDKU128 user_channel_id_ref;
8404         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
8405         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
8406         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8407         (*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);
8408         return ret_arr;
8409 }
8410
8411 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) {
8412         void* this_arg_ptr = untag_ptr(this_arg);
8413         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8414         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8415         LDKThirtyTwoBytes channel_keys_id_ref;
8416         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
8417         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
8418         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
8419         *ret_ret = (this_arg_conv->derive_channel_signer)(this_arg_conv->this_arg, channel_value_satoshis, channel_keys_id_ref);
8420         return tag_ptr(ret_ret, true);
8421 }
8422
8423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignerProvider_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
8424         void* this_arg_ptr = untag_ptr(this_arg);
8425         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8426         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8427         LDKu8slice reader_ref;
8428         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
8429         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
8430         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
8431         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
8432         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
8433         return tag_ptr(ret_conv, true);
8434 }
8435
8436 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignerProvider_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
8437         void* this_arg_ptr = untag_ptr(this_arg);
8438         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8439         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8440         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
8441         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8442         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8443         CVec_u8Z_free(ret_var);
8444         return ret_arr;
8445 }
8446
8447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignerProvider_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
8448         void* this_arg_ptr = untag_ptr(this_arg);
8449         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8450         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
8451         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
8452         int64_t ret_ref = 0;
8453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8454         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8455         return ret_ref;
8456 }
8457
8458 typedef struct LDKFeeEstimator_JCalls {
8459         atomic_size_t refcnt;
8460         JavaVM *vm;
8461         jweak o;
8462         jmethodID get_est_sat_per_1000_weight_meth;
8463 } LDKFeeEstimator_JCalls;
8464 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
8465         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
8466         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8467                 JNIEnv *env;
8468                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8469                 if (get_jenv_res == JNI_EDETACHED) {
8470                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8471                 } else {
8472                         DO_ASSERT(get_jenv_res == JNI_OK);
8473                 }
8474                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8475                 if (get_jenv_res == JNI_EDETACHED) {
8476                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8477                 }
8478                 FREE(j_calls);
8479         }
8480 }
8481 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
8482         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
8483         JNIEnv *env;
8484         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8485         if (get_jenv_res == JNI_EDETACHED) {
8486                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8487         } else {
8488                 DO_ASSERT(get_jenv_res == JNI_OK);
8489         }
8490         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
8491         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8492         CHECK(obj != NULL);
8493         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
8494         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8495                 (*env)->ExceptionDescribe(env);
8496                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
8497         }
8498         if (get_jenv_res == JNI_EDETACHED) {
8499                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8500         }
8501         return ret;
8502 }
8503 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
8504         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
8505         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8506 }
8507 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
8508         jclass c = (*env)->GetObjectClass(env, o);
8509         CHECK(c != NULL);
8510         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
8511         atomic_init(&calls->refcnt, 1);
8512         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8513         calls->o = (*env)->NewWeakGlobalRef(env, o);
8514         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
8515         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
8516
8517         LDKFeeEstimator ret = {
8518                 .this_arg = (void*) calls,
8519                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
8520                 .free = LDKFeeEstimator_JCalls_free,
8521         };
8522         return ret;
8523 }
8524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
8525         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
8526         *res_ptr = LDKFeeEstimator_init(env, clz, o);
8527         return tag_ptr(res_ptr, true);
8528 }
8529 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) {
8530         void* this_arg_ptr = untag_ptr(this_arg);
8531         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8532         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
8533         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
8534         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
8535         return ret_conv;
8536 }
8537
8538 typedef struct LDKRouter_JCalls {
8539         atomic_size_t refcnt;
8540         JavaVM *vm;
8541         jweak o;
8542         jmethodID find_route_meth;
8543         jmethodID find_route_with_id_meth;
8544 } LDKRouter_JCalls;
8545 static void LDKRouter_JCalls_free(void* this_arg) {
8546         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
8547         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8548                 JNIEnv *env;
8549                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8550                 if (get_jenv_res == JNI_EDETACHED) {
8551                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8552                 } else {
8553                         DO_ASSERT(get_jenv_res == JNI_OK);
8554                 }
8555                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8556                 if (get_jenv_res == JNI_EDETACHED) {
8557                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8558                 }
8559                 FREE(j_calls);
8560         }
8561 }
8562 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, LDKCVec_ChannelDetailsZ * first_hops, const LDKInFlightHtlcs * inflight_htlcs) {
8563         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
8564         JNIEnv *env;
8565         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8566         if (get_jenv_res == JNI_EDETACHED) {
8567                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8568         } else {
8569                 DO_ASSERT(get_jenv_res == JNI_OK);
8570         }
8571         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
8572         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
8573         LDKRouteParameters route_params_var = *route_params;
8574         int64_t route_params_ref = 0;
8575         route_params_var = RouteParameters_clone(&route_params_var);
8576         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
8577         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
8578         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
8579         int64_tArray first_hops_arr = NULL;
8580         if (first_hops != NULL) {
8581                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
8582                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
8583                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
8584                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
8585                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
8586                         int64_t first_hops_conv_16_ref = 0;
8587                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
8588                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
8589                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
8590                 }
8591                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
8592         }
8593         LDKInFlightHtlcs inflight_htlcs_var = *inflight_htlcs;
8594         int64_t inflight_htlcs_ref = 0;
8595         inflight_htlcs_var = InFlightHtlcs_clone(&inflight_htlcs_var);
8596         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
8597         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
8598         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8599         CHECK(obj != NULL);
8600         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, route_params_ref, first_hops_arr, inflight_htlcs_ref);
8601         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8602                 (*env)->ExceptionDescribe(env);
8603                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
8604         }
8605         void* ret_ptr = untag_ptr(ret);
8606         CHECK_ACCESS(ret_ptr);
8607         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
8608         FREE(untag_ptr(ret));
8609         if (get_jenv_res == JNI_EDETACHED) {
8610                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8611         }
8612         return ret_conv;
8613 }
8614 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) {
8615         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
8616         JNIEnv *env;
8617         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8618         if (get_jenv_res == JNI_EDETACHED) {
8619                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8620         } else {
8621                 DO_ASSERT(get_jenv_res == JNI_OK);
8622         }
8623         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
8624         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
8625         LDKRouteParameters route_params_var = *route_params;
8626         int64_t route_params_ref = 0;
8627         route_params_var = RouteParameters_clone(&route_params_var);
8628         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
8629         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
8630         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
8631         int64_tArray first_hops_arr = NULL;
8632         if (first_hops != NULL) {
8633                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
8634                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
8635                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
8636                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
8637                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
8638                         int64_t first_hops_conv_16_ref = 0;
8639                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
8640                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
8641                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
8642                 }
8643                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
8644         }
8645         LDKInFlightHtlcs inflight_htlcs_var = *inflight_htlcs;
8646         int64_t inflight_htlcs_ref = 0;
8647         inflight_htlcs_var = InFlightHtlcs_clone(&inflight_htlcs_var);
8648         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
8649         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
8650         int8_tArray _payment_hash_arr = (*env)->NewByteArray(env, 32);
8651         (*env)->SetByteArrayRegion(env, _payment_hash_arr, 0, 32, _payment_hash.data);
8652         int8_tArray _payment_id_arr = (*env)->NewByteArray(env, 32);
8653         (*env)->SetByteArrayRegion(env, _payment_id_arr, 0, 32, _payment_id.data);
8654         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8655         CHECK(obj != NULL);
8656         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);
8657         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8658                 (*env)->ExceptionDescribe(env);
8659                 (*env)->FatalError(env, "A call to find_route_with_id in LDKRouter from rust threw an exception.");
8660         }
8661         void* ret_ptr = untag_ptr(ret);
8662         CHECK_ACCESS(ret_ptr);
8663         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
8664         FREE(untag_ptr(ret));
8665         if (get_jenv_res == JNI_EDETACHED) {
8666                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8667         }
8668         return ret_conv;
8669 }
8670 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
8671         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
8672         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8673 }
8674 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
8675         jclass c = (*env)->GetObjectClass(env, o);
8676         CHECK(c != NULL);
8677         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
8678         atomic_init(&calls->refcnt, 1);
8679         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8680         calls->o = (*env)->NewWeakGlobalRef(env, o);
8681         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[JJ)J");
8682         CHECK(calls->find_route_meth != NULL);
8683         calls->find_route_with_id_meth = (*env)->GetMethodID(env, c, "find_route_with_id", "([BJ[JJ[B[B)J");
8684         CHECK(calls->find_route_with_id_meth != NULL);
8685
8686         LDKRouter ret = {
8687                 .this_arg = (void*) calls,
8688                 .find_route = find_route_LDKRouter_jcall,
8689                 .find_route_with_id = find_route_with_id_LDKRouter_jcall,
8690                 .free = LDKRouter_JCalls_free,
8691         };
8692         return ret;
8693 }
8694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
8695         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
8696         *res_ptr = LDKRouter_init(env, clz, o);
8697         return tag_ptr(res_ptr, true);
8698 }
8699 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) {
8700         void* this_arg_ptr = untag_ptr(this_arg);
8701         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8702         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
8703         LDKPublicKey payer_ref;
8704         CHECK((*env)->GetArrayLength(env, payer) == 33);
8705         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
8706         LDKRouteParameters route_params_conv;
8707         route_params_conv.inner = untag_ptr(route_params);
8708         route_params_conv.is_owned = ptr_is_owned(route_params);
8709         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
8710         route_params_conv.is_owned = false;
8711         LDKCVec_ChannelDetailsZ first_hops_constr;
8712         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
8713         if (first_hops != NULL) {
8714                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
8715                 if (first_hops_constr.datalen > 0)
8716                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
8717                 else
8718                         first_hops_constr.data = NULL;
8719                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
8720                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
8721                         int64_t first_hops_conv_16 = first_hops_vals[q];
8722                         LDKChannelDetails first_hops_conv_16_conv;
8723                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
8724                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
8725                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
8726                         first_hops_conv_16_conv.is_owned = false;
8727                         first_hops_constr.data[q] = first_hops_conv_16_conv;
8728                 }
8729                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
8730                 first_hops_ptr = &first_hops_constr;
8731         }
8732         LDKInFlightHtlcs inflight_htlcs_conv;
8733         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
8734         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
8735         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
8736         inflight_htlcs_conv.is_owned = false;
8737         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8738         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, first_hops_ptr, &inflight_htlcs_conv);
8739         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
8740         return tag_ptr(ret_conv, true);
8741 }
8742
8743 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) {
8744         void* this_arg_ptr = untag_ptr(this_arg);
8745         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8746         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
8747         LDKPublicKey payer_ref;
8748         CHECK((*env)->GetArrayLength(env, payer) == 33);
8749         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
8750         LDKRouteParameters route_params_conv;
8751         route_params_conv.inner = untag_ptr(route_params);
8752         route_params_conv.is_owned = ptr_is_owned(route_params);
8753         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
8754         route_params_conv.is_owned = false;
8755         LDKCVec_ChannelDetailsZ first_hops_constr;
8756         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
8757         if (first_hops != NULL) {
8758                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
8759                 if (first_hops_constr.datalen > 0)
8760                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
8761                 else
8762                         first_hops_constr.data = NULL;
8763                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
8764                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
8765                         int64_t first_hops_conv_16 = first_hops_vals[q];
8766                         LDKChannelDetails first_hops_conv_16_conv;
8767                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
8768                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
8769                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
8770                         first_hops_conv_16_conv.is_owned = false;
8771                         first_hops_constr.data[q] = first_hops_conv_16_conv;
8772                 }
8773                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
8774                 first_hops_ptr = &first_hops_constr;
8775         }
8776         LDKInFlightHtlcs inflight_htlcs_conv;
8777         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
8778         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
8779         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
8780         inflight_htlcs_conv.is_owned = false;
8781         LDKThirtyTwoBytes _payment_hash_ref;
8782         CHECK((*env)->GetArrayLength(env, _payment_hash) == 32);
8783         (*env)->GetByteArrayRegion(env, _payment_hash, 0, 32, _payment_hash_ref.data);
8784         LDKThirtyTwoBytes _payment_id_ref;
8785         CHECK((*env)->GetArrayLength(env, _payment_id) == 32);
8786         (*env)->GetByteArrayRegion(env, _payment_id, 0, 32, _payment_id_ref.data);
8787         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8788         *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);
8789         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
8790         return tag_ptr(ret_conv, true);
8791 }
8792
8793 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
8794         return ThirtyTwoBytes_clone(&owner->a);
8795 }
8796 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8797         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
8798         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
8800         return ret_arr;
8801 }
8802
8803 static inline struct LDKChannelManager C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
8804         LDKChannelManager ret = owner->b;
8805         ret.is_owned = false;
8806         return ret;
8807 }
8808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8809         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
8810         LDKChannelManager ret_var = C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
8811         int64_t ret_ref = 0;
8812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8813         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8814         return ret_ref;
8815 }
8816
8817 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
8818 CHECK(owner->result_ok);
8819         return &*owner->contents.result;
8820 }
8821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8822         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
8823         int64_t ret_ret = tag_ptr(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv), false);
8824         return ret_ret;
8825 }
8826
8827 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
8828 CHECK(!owner->result_ok);
8829         return DecodeError_clone(&*owner->contents.err);
8830 }
8831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8832         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
8833         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8834         *ret_copy = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
8835         int64_t ret_ref = tag_ptr(ret_copy, true);
8836         return ret_ref;
8837 }
8838
8839 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
8840         LDKChannelConfig ret = *owner->contents.result;
8841         ret.is_owned = false;
8842         return ret;
8843 }
8844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8845         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
8846         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
8847         int64_t ret_ref = 0;
8848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8849         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8850         return ret_ref;
8851 }
8852
8853 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
8854 CHECK(!owner->result_ok);
8855         return DecodeError_clone(&*owner->contents.err);
8856 }
8857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8858         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
8859         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8860         *ret_copy = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
8861         int64_t ret_ref = tag_ptr(ret_copy, true);
8862         return ret_ref;
8863 }
8864
8865 static jclass LDKCOption_APIErrorZ_Some_class = NULL;
8866 static jmethodID LDKCOption_APIErrorZ_Some_meth = NULL;
8867 static jclass LDKCOption_APIErrorZ_None_class = NULL;
8868 static jmethodID LDKCOption_APIErrorZ_None_meth = NULL;
8869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1APIErrorZ_init (JNIEnv *env, jclass clz) {
8870         LDKCOption_APIErrorZ_Some_class =
8871                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_APIErrorZ$Some"));
8872         CHECK(LDKCOption_APIErrorZ_Some_class != NULL);
8873         LDKCOption_APIErrorZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_APIErrorZ_Some_class, "<init>", "(J)V");
8874         CHECK(LDKCOption_APIErrorZ_Some_meth != NULL);
8875         LDKCOption_APIErrorZ_None_class =
8876                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_APIErrorZ$None"));
8877         CHECK(LDKCOption_APIErrorZ_None_class != NULL);
8878         LDKCOption_APIErrorZ_None_meth = (*env)->GetMethodID(env, LDKCOption_APIErrorZ_None_class, "<init>", "()V");
8879         CHECK(LDKCOption_APIErrorZ_None_meth != NULL);
8880 }
8881 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1APIErrorZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8882         LDKCOption_APIErrorZ *obj = (LDKCOption_APIErrorZ*)untag_ptr(ptr);
8883         switch(obj->tag) {
8884                 case LDKCOption_APIErrorZ_Some: {
8885                         int64_t some_ref = tag_ptr(&obj->some, false);
8886                         return (*env)->NewObject(env, LDKCOption_APIErrorZ_Some_class, LDKCOption_APIErrorZ_Some_meth, some_ref);
8887                 }
8888                 case LDKCOption_APIErrorZ_None: {
8889                         return (*env)->NewObject(env, LDKCOption_APIErrorZ_None_class, LDKCOption_APIErrorZ_None_meth);
8890                 }
8891                 default: abort();
8892         }
8893 }
8894 static inline struct LDKCOption_APIErrorZ CResult_COption_APIErrorZDecodeErrorZ_get_ok(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR owner){
8895 CHECK(owner->result_ok);
8896         return COption_APIErrorZ_clone(&*owner->contents.result);
8897 }
8898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8899         LDKCResult_COption_APIErrorZDecodeErrorZ* owner_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(owner);
8900         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
8901         *ret_copy = CResult_COption_APIErrorZDecodeErrorZ_get_ok(owner_conv);
8902         int64_t ret_ref = tag_ptr(ret_copy, true);
8903         return ret_ref;
8904 }
8905
8906 static inline struct LDKDecodeError CResult_COption_APIErrorZDecodeErrorZ_get_err(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR owner){
8907 CHECK(!owner->result_ok);
8908         return DecodeError_clone(&*owner->contents.err);
8909 }
8910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8911         LDKCResult_COption_APIErrorZDecodeErrorZ* owner_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(owner);
8912         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8913         *ret_copy = CResult_COption_APIErrorZDecodeErrorZ_get_err(owner_conv);
8914         int64_t ret_ref = tag_ptr(ret_copy, true);
8915         return ret_ref;
8916 }
8917
8918 static inline struct LDKUntrustedString CResult_UntrustedStringDecodeErrorZ_get_ok(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR owner){
8919         LDKUntrustedString ret = *owner->contents.result;
8920         ret.is_owned = false;
8921         return ret;
8922 }
8923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8924         LDKCResult_UntrustedStringDecodeErrorZ* owner_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(owner);
8925         LDKUntrustedString ret_var = CResult_UntrustedStringDecodeErrorZ_get_ok(owner_conv);
8926         int64_t ret_ref = 0;
8927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8928         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8929         return ret_ref;
8930 }
8931
8932 static inline struct LDKDecodeError CResult_UntrustedStringDecodeErrorZ_get_err(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR owner){
8933 CHECK(!owner->result_ok);
8934         return DecodeError_clone(&*owner->contents.err);
8935 }
8936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8937         LDKCResult_UntrustedStringDecodeErrorZ* owner_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(owner);
8938         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8939         *ret_copy = CResult_UntrustedStringDecodeErrorZ_get_err(owner_conv);
8940         int64_t ret_ref = tag_ptr(ret_copy, true);
8941         return ret_ref;
8942 }
8943
8944 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
8945         LDKOutPoint ret = *owner->contents.result;
8946         ret.is_owned = false;
8947         return ret;
8948 }
8949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8950         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
8951         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
8952         int64_t ret_ref = 0;
8953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8954         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8955         return ret_ref;
8956 }
8957
8958 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
8959 CHECK(!owner->result_ok);
8960         return DecodeError_clone(&*owner->contents.err);
8961 }
8962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8963         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
8964         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8965         *ret_copy = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
8966         int64_t ret_ref = tag_ptr(ret_copy, true);
8967         return ret_ref;
8968 }
8969
8970 typedef struct LDKType_JCalls {
8971         atomic_size_t refcnt;
8972         JavaVM *vm;
8973         jweak o;
8974         jmethodID type_id_meth;
8975         jmethodID debug_str_meth;
8976         jmethodID write_meth;
8977 } LDKType_JCalls;
8978 static void LDKType_JCalls_free(void* this_arg) {
8979         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
8980         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8981                 JNIEnv *env;
8982                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8983                 if (get_jenv_res == JNI_EDETACHED) {
8984                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8985                 } else {
8986                         DO_ASSERT(get_jenv_res == JNI_OK);
8987                 }
8988                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8989                 if (get_jenv_res == JNI_EDETACHED) {
8990                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8991                 }
8992                 FREE(j_calls);
8993         }
8994 }
8995 uint16_t type_id_LDKType_jcall(const void* this_arg) {
8996         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
8997         JNIEnv *env;
8998         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8999         if (get_jenv_res == JNI_EDETACHED) {
9000                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9001         } else {
9002                 DO_ASSERT(get_jenv_res == JNI_OK);
9003         }
9004         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9005         CHECK(obj != NULL);
9006         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
9007         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9008                 (*env)->ExceptionDescribe(env);
9009                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
9010         }
9011         if (get_jenv_res == JNI_EDETACHED) {
9012                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9013         }
9014         return ret;
9015 }
9016 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
9017         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
9018         JNIEnv *env;
9019         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9020         if (get_jenv_res == JNI_EDETACHED) {
9021                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9022         } else {
9023                 DO_ASSERT(get_jenv_res == JNI_OK);
9024         }
9025         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9026         CHECK(obj != NULL);
9027         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
9028         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9029                 (*env)->ExceptionDescribe(env);
9030                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
9031         }
9032         LDKStr ret_conv = java_to_owned_str(env, ret);
9033         if (get_jenv_res == JNI_EDETACHED) {
9034                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9035         }
9036         return ret_conv;
9037 }
9038 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
9039         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
9040         JNIEnv *env;
9041         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9042         if (get_jenv_res == JNI_EDETACHED) {
9043                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9044         } else {
9045                 DO_ASSERT(get_jenv_res == JNI_OK);
9046         }
9047         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9048         CHECK(obj != NULL);
9049         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
9050         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9051                 (*env)->ExceptionDescribe(env);
9052                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
9053         }
9054         LDKCVec_u8Z ret_ref;
9055         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
9056         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
9057         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
9058         if (get_jenv_res == JNI_EDETACHED) {
9059                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9060         }
9061         return ret_ref;
9062 }
9063 static void LDKType_JCalls_cloned(LDKType* new_obj) {
9064         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
9065         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9066 }
9067 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
9068         jclass c = (*env)->GetObjectClass(env, o);
9069         CHECK(c != NULL);
9070         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
9071         atomic_init(&calls->refcnt, 1);
9072         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9073         calls->o = (*env)->NewWeakGlobalRef(env, o);
9074         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
9075         CHECK(calls->type_id_meth != NULL);
9076         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
9077         CHECK(calls->debug_str_meth != NULL);
9078         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
9079         CHECK(calls->write_meth != NULL);
9080
9081         LDKType ret = {
9082                 .this_arg = (void*) calls,
9083                 .type_id = type_id_LDKType_jcall,
9084                 .debug_str = debug_str_LDKType_jcall,
9085                 .write = write_LDKType_jcall,
9086                 .cloned = LDKType_JCalls_cloned,
9087                 .free = LDKType_JCalls_free,
9088         };
9089         return ret;
9090 }
9091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
9092         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
9093         *res_ptr = LDKType_init(env, clz, o);
9094         return tag_ptr(res_ptr, true);
9095 }
9096 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
9097         void* this_arg_ptr = untag_ptr(this_arg);
9098         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9099         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
9100         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
9101         return ret_conv;
9102 }
9103
9104 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
9105         void* this_arg_ptr = untag_ptr(this_arg);
9106         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9107         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
9108         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
9109         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
9110         Str_free(ret_str);
9111         return ret_conv;
9112 }
9113
9114 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
9115         void* this_arg_ptr = untag_ptr(this_arg);
9116         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9117         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
9118         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
9119         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9120         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9121         CVec_u8Z_free(ret_var);
9122         return ret_arr;
9123 }
9124
9125 static jclass LDKCOption_TypeZ_Some_class = NULL;
9126 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
9127 static jclass LDKCOption_TypeZ_None_class = NULL;
9128 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
9129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
9130         LDKCOption_TypeZ_Some_class =
9131                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
9132         CHECK(LDKCOption_TypeZ_Some_class != NULL);
9133         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
9134         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
9135         LDKCOption_TypeZ_None_class =
9136                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
9137         CHECK(LDKCOption_TypeZ_None_class != NULL);
9138         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
9139         CHECK(LDKCOption_TypeZ_None_meth != NULL);
9140 }
9141 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9142         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
9143         switch(obj->tag) {
9144                 case LDKCOption_TypeZ_Some: {
9145                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
9146                         *some_ret = Type_clone(&obj->some);
9147                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, tag_ptr(some_ret, true));
9148                 }
9149                 case LDKCOption_TypeZ_None: {
9150                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
9151                 }
9152                 default: abort();
9153         }
9154 }
9155 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
9156 CHECK(owner->result_ok);
9157         return COption_TypeZ_clone(&*owner->contents.result);
9158 }
9159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9160         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
9161         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9162         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
9163         int64_t ret_ref = tag_ptr(ret_copy, true);
9164         return ret_ref;
9165 }
9166
9167 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
9168 CHECK(!owner->result_ok);
9169         return DecodeError_clone(&*owner->contents.err);
9170 }
9171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9172         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
9173         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9174         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
9175         int64_t ret_ref = tag_ptr(ret_copy, true);
9176         return ret_ref;
9177 }
9178
9179 static jclass LDKPaymentError_Invoice_class = NULL;
9180 static jmethodID LDKPaymentError_Invoice_meth = NULL;
9181 static jclass LDKPaymentError_Sending_class = NULL;
9182 static jmethodID LDKPaymentError_Sending_meth = NULL;
9183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
9184         LDKPaymentError_Invoice_class =
9185                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
9186         CHECK(LDKPaymentError_Invoice_class != NULL);
9187         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
9188         CHECK(LDKPaymentError_Invoice_meth != NULL);
9189         LDKPaymentError_Sending_class =
9190                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
9191         CHECK(LDKPaymentError_Sending_class != NULL);
9192         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(Lorg/ldk/enums/RetryableSendFailure;)V");
9193         CHECK(LDKPaymentError_Sending_meth != NULL);
9194 }
9195 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9196         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
9197         switch(obj->tag) {
9198                 case LDKPaymentError_Invoice: {
9199                         LDKStr invoice_str = obj->invoice;
9200                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
9201                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
9202                 }
9203                 case LDKPaymentError_Sending: {
9204                         jclass sending_conv = LDKRetryableSendFailure_to_java(env, obj->sending);
9205                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_conv);
9206                 }
9207                 default: abort();
9208         }
9209 }
9210 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
9211 CHECK(owner->result_ok);
9212         return ThirtyTwoBytes_clone(&*owner->contents.result);
9213 }
9214 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9215         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
9216         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
9217         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
9218         return ret_arr;
9219 }
9220
9221 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
9222 CHECK(!owner->result_ok);
9223         return PaymentError_clone(&*owner->contents.err);
9224 }
9225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9226         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
9227         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
9228         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
9229         int64_t ret_ref = tag_ptr(ret_copy, true);
9230         return ret_ref;
9231 }
9232
9233 static inline void CResult_NonePaymentErrorZ_get_ok(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
9234 CHECK(owner->result_ok);
9235         return *owner->contents.result;
9236 }
9237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9238         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
9239         CResult_NonePaymentErrorZ_get_ok(owner_conv);
9240 }
9241
9242 static inline struct LDKPaymentError CResult_NonePaymentErrorZ_get_err(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
9243 CHECK(!owner->result_ok);
9244         return PaymentError_clone(&*owner->contents.err);
9245 }
9246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9247         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
9248         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
9249         *ret_copy = CResult_NonePaymentErrorZ_get_err(owner_conv);
9250         int64_t ret_ref = tag_ptr(ret_copy, true);
9251         return ret_ref;
9252 }
9253
9254 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
9255 CHECK(owner->result_ok);
9256         return *owner->contents.result;
9257 }
9258 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9259         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
9260         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
9261         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
9262         return ret_conv;
9263 }
9264
9265 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
9266 CHECK(!owner->result_ok);
9267         return *owner->contents.err;
9268 }
9269 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9270         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
9271         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
9272         return ret_conv;
9273 }
9274
9275 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
9276         LDKChannelMonitorUpdate ret = *owner->contents.result;
9277         ret.is_owned = false;
9278         return ret;
9279 }
9280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9281         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
9282         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
9283         int64_t ret_ref = 0;
9284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9285         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9286         return ret_ref;
9287 }
9288
9289 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
9290 CHECK(!owner->result_ok);
9291         return DecodeError_clone(&*owner->contents.err);
9292 }
9293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9294         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
9295         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9296         *ret_copy = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
9297         int64_t ret_ref = tag_ptr(ret_copy, true);
9298         return ret_ref;
9299 }
9300
9301 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
9302 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
9303 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
9304 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
9305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
9306         LDKCOption_MonitorEventZ_Some_class =
9307                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
9308         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
9309         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
9310         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
9311         LDKCOption_MonitorEventZ_None_class =
9312                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
9313         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
9314         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
9315         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
9316 }
9317 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9318         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
9319         switch(obj->tag) {
9320                 case LDKCOption_MonitorEventZ_Some: {
9321                         int64_t some_ref = tag_ptr(&obj->some, false);
9322                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
9323                 }
9324                 case LDKCOption_MonitorEventZ_None: {
9325                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
9326                 }
9327                 default: abort();
9328         }
9329 }
9330 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
9331 CHECK(owner->result_ok);
9332         return COption_MonitorEventZ_clone(&*owner->contents.result);
9333 }
9334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9335         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
9336         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
9337         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
9338         int64_t ret_ref = tag_ptr(ret_copy, true);
9339         return ret_ref;
9340 }
9341
9342 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
9343 CHECK(!owner->result_ok);
9344         return DecodeError_clone(&*owner->contents.err);
9345 }
9346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9347         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
9348         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9349         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
9350         int64_t ret_ref = tag_ptr(ret_copy, true);
9351         return ret_ref;
9352 }
9353
9354 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
9355         LDKHTLCUpdate ret = *owner->contents.result;
9356         ret.is_owned = false;
9357         return ret;
9358 }
9359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9360         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
9361         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
9362         int64_t ret_ref = 0;
9363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9364         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9365         return ret_ref;
9366 }
9367
9368 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
9369 CHECK(!owner->result_ok);
9370         return DecodeError_clone(&*owner->contents.err);
9371 }
9372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9373         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
9374         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9375         *ret_copy = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
9376         int64_t ret_ref = tag_ptr(ret_copy, true);
9377         return ret_ref;
9378 }
9379
9380 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
9381         LDKOutPoint ret = owner->a;
9382         ret.is_owned = false;
9383         return ret;
9384 }
9385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9386         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
9387         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
9388         int64_t ret_ref = 0;
9389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9390         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9391         return ret_ref;
9392 }
9393
9394 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
9395         return CVec_u8Z_clone(&owner->b);
9396 }
9397 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9398         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
9399         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
9400         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9401         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9402         CVec_u8Z_free(ret_var);
9403         return ret_arr;
9404 }
9405
9406 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
9407         return owner->a;
9408 }
9409 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9410         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
9411         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
9412         return ret_conv;
9413 }
9414
9415 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
9416         return CVec_u8Z_clone(&owner->b);
9417 }
9418 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9419         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
9420         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
9421         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9422         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9423         CVec_u8Z_free(ret_var);
9424         return ret_arr;
9425 }
9426
9427 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
9428         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
9429         for (size_t i = 0; i < ret.datalen; i++) {
9430                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
9431         }
9432         return ret;
9433 }
9434 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
9435         return ThirtyTwoBytes_clone(&owner->a);
9436 }
9437 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9438         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
9439         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
9440         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
9441         return ret_arr;
9442 }
9443
9444 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
9445         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
9446 }
9447 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9448         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
9449         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
9450         int64_tArray ret_arr = NULL;
9451         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9452         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9453         for (size_t v = 0; v < ret_var.datalen; v++) {
9454                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
9455                 *ret_conv_21_conv = ret_var.data[v];
9456                 ret_arr_ptr[v] = tag_ptr(ret_conv_21_conv, true);
9457         }
9458         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9459         FREE(ret_var.data);
9460         return ret_arr;
9461 }
9462
9463 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
9464         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 };
9465         for (size_t i = 0; i < ret.datalen; i++) {
9466                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
9467         }
9468         return ret;
9469 }
9470 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
9471         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
9472         for (size_t i = 0; i < ret.datalen; i++) {
9473                 ret.data[i] = Event_clone(&orig->data[i]);
9474         }
9475         return ret;
9476 }
9477 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
9478         return owner->a;
9479 }
9480 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9481         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
9482         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
9483         return ret_conv;
9484 }
9485
9486 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
9487         return TxOut_clone(&owner->b);
9488 }
9489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9490         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
9491         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
9492         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
9493         return tag_ptr(ret_ref, true);
9494 }
9495
9496 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
9497         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
9498         for (size_t i = 0; i < ret.datalen; i++) {
9499                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
9500         }
9501         return ret;
9502 }
9503 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
9504         return ThirtyTwoBytes_clone(&owner->a);
9505 }
9506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9507         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
9508         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
9509         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
9510         return ret_arr;
9511 }
9512
9513 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
9514         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
9515 }
9516 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9517         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
9518         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
9519         int64_tArray ret_arr = NULL;
9520         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9521         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9522         for (size_t u = 0; u < ret_var.datalen; u++) {
9523                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
9524                 *ret_conv_20_conv = ret_var.data[u];
9525                 ret_arr_ptr[u] = tag_ptr(ret_conv_20_conv, true);
9526         }
9527         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9528         FREE(ret_var.data);
9529         return ret_arr;
9530 }
9531
9532 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
9533         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 };
9534         for (size_t i = 0; i < ret.datalen; i++) {
9535                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
9536         }
9537         return ret;
9538 }
9539 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
9540 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
9541 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
9542 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
9543 static jclass LDKBalance_ContentiousClaimable_class = NULL;
9544 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
9545 static jclass LDKBalance_MaybeTimeoutClaimableHTLC_class = NULL;
9546 static jmethodID LDKBalance_MaybeTimeoutClaimableHTLC_meth = NULL;
9547 static jclass LDKBalance_MaybePreimageClaimableHTLC_class = NULL;
9548 static jmethodID LDKBalance_MaybePreimageClaimableHTLC_meth = NULL;
9549 static jclass LDKBalance_CounterpartyRevokedOutputClaimable_class = NULL;
9550 static jmethodID LDKBalance_CounterpartyRevokedOutputClaimable_meth = NULL;
9551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
9552         LDKBalance_ClaimableOnChannelClose_class =
9553                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
9554         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
9555         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
9556         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
9557         LDKBalance_ClaimableAwaitingConfirmations_class =
9558                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
9559         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
9560         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
9561         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
9562         LDKBalance_ContentiousClaimable_class =
9563                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
9564         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
9565         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
9566         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
9567         LDKBalance_MaybeTimeoutClaimableHTLC_class =
9568                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeTimeoutClaimableHTLC"));
9569         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_class != NULL);
9570         LDKBalance_MaybeTimeoutClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, "<init>", "(JI)V");
9571         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_meth != NULL);
9572         LDKBalance_MaybePreimageClaimableHTLC_class =
9573                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybePreimageClaimableHTLC"));
9574         CHECK(LDKBalance_MaybePreimageClaimableHTLC_class != NULL);
9575         LDKBalance_MaybePreimageClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybePreimageClaimableHTLC_class, "<init>", "(JI)V");
9576         CHECK(LDKBalance_MaybePreimageClaimableHTLC_meth != NULL);
9577         LDKBalance_CounterpartyRevokedOutputClaimable_class =
9578                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$CounterpartyRevokedOutputClaimable"));
9579         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_class != NULL);
9580         LDKBalance_CounterpartyRevokedOutputClaimable_meth = (*env)->GetMethodID(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, "<init>", "(J)V");
9581         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_meth != NULL);
9582 }
9583 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9584         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
9585         switch(obj->tag) {
9586                 case LDKBalance_ClaimableOnChannelClose: {
9587                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
9588                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
9589                 }
9590                 case LDKBalance_ClaimableAwaitingConfirmations: {
9591                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
9592                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
9593                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
9594                 }
9595                 case LDKBalance_ContentiousClaimable: {
9596                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
9597                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
9598                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
9599                 }
9600                 case LDKBalance_MaybeTimeoutClaimableHTLC: {
9601                         int64_t claimable_amount_satoshis_conv = obj->maybe_timeout_claimable_htlc.claimable_amount_satoshis;
9602                         int32_t claimable_height_conv = obj->maybe_timeout_claimable_htlc.claimable_height;
9603                         return (*env)->NewObject(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, LDKBalance_MaybeTimeoutClaimableHTLC_meth, claimable_amount_satoshis_conv, claimable_height_conv);
9604                 }
9605                 case LDKBalance_MaybePreimageClaimableHTLC: {
9606                         int64_t claimable_amount_satoshis_conv = obj->maybe_preimage_claimable_htlc.claimable_amount_satoshis;
9607                         int32_t expiry_height_conv = obj->maybe_preimage_claimable_htlc.expiry_height;
9608                         return (*env)->NewObject(env, LDKBalance_MaybePreimageClaimableHTLC_class, LDKBalance_MaybePreimageClaimableHTLC_meth, claimable_amount_satoshis_conv, expiry_height_conv);
9609                 }
9610                 case LDKBalance_CounterpartyRevokedOutputClaimable: {
9611                         int64_t claimable_amount_satoshis_conv = obj->counterparty_revoked_output_claimable.claimable_amount_satoshis;
9612                         return (*env)->NewObject(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, LDKBalance_CounterpartyRevokedOutputClaimable_meth, claimable_amount_satoshis_conv);
9613                 }
9614                 default: abort();
9615         }
9616 }
9617 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
9618         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
9619         for (size_t i = 0; i < ret.datalen; i++) {
9620                 ret.data[i] = Balance_clone(&orig->data[i]);
9621         }
9622         return ret;
9623 }
9624 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
9625 CHECK(owner->result_ok);
9626         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
9627 }
9628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9629         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
9630         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
9631         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
9632         return tag_ptr(ret_conv, true);
9633 }
9634
9635 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
9636 CHECK(!owner->result_ok);
9637         return DecodeError_clone(&*owner->contents.err);
9638 }
9639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9640         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
9641         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9642         *ret_copy = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
9643         int64_t ret_ref = tag_ptr(ret_copy, true);
9644         return ret_ref;
9645 }
9646
9647 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
9648         return owner->a;
9649 }
9650 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9651         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
9652         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
9653         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
9654         return ret_arr;
9655 }
9656
9657 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
9658         return Type_clone(&owner->b);
9659 }
9660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9661         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
9662         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
9663         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
9664         return tag_ptr(ret_ret, true);
9665 }
9666
9667 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
9668         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
9669         for (size_t i = 0; i < ret.datalen; i++) {
9670                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
9671         }
9672         return ret;
9673 }
9674 typedef struct LDKCustomOnionMessageContents_JCalls {
9675         atomic_size_t refcnt;
9676         JavaVM *vm;
9677         jweak o;
9678         jmethodID tlv_type_meth;
9679         jmethodID write_meth;
9680 } LDKCustomOnionMessageContents_JCalls;
9681 static void LDKCustomOnionMessageContents_JCalls_free(void* this_arg) {
9682         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
9683         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9684                 JNIEnv *env;
9685                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9686                 if (get_jenv_res == JNI_EDETACHED) {
9687                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9688                 } else {
9689                         DO_ASSERT(get_jenv_res == JNI_OK);
9690                 }
9691                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9692                 if (get_jenv_res == JNI_EDETACHED) {
9693                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9694                 }
9695                 FREE(j_calls);
9696         }
9697 }
9698 uint64_t tlv_type_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
9699         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
9700         JNIEnv *env;
9701         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9702         if (get_jenv_res == JNI_EDETACHED) {
9703                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9704         } else {
9705                 DO_ASSERT(get_jenv_res == JNI_OK);
9706         }
9707         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9708         CHECK(obj != NULL);
9709         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->tlv_type_meth);
9710         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9711                 (*env)->ExceptionDescribe(env);
9712                 (*env)->FatalError(env, "A call to tlv_type in LDKCustomOnionMessageContents from rust threw an exception.");
9713         }
9714         if (get_jenv_res == JNI_EDETACHED) {
9715                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9716         }
9717         return ret;
9718 }
9719 LDKCVec_u8Z write_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
9720         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
9721         JNIEnv *env;
9722         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9723         if (get_jenv_res == JNI_EDETACHED) {
9724                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9725         } else {
9726                 DO_ASSERT(get_jenv_res == JNI_OK);
9727         }
9728         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9729         CHECK(obj != NULL);
9730         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
9731         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9732                 (*env)->ExceptionDescribe(env);
9733                 (*env)->FatalError(env, "A call to write in LDKCustomOnionMessageContents from rust threw an exception.");
9734         }
9735         LDKCVec_u8Z ret_ref;
9736         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
9737         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
9738         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
9739         if (get_jenv_res == JNI_EDETACHED) {
9740                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9741         }
9742         return ret_ref;
9743 }
9744 static void LDKCustomOnionMessageContents_JCalls_cloned(LDKCustomOnionMessageContents* new_obj) {
9745         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) new_obj->this_arg;
9746         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9747 }
9748 static inline LDKCustomOnionMessageContents LDKCustomOnionMessageContents_init (JNIEnv *env, jclass clz, jobject o) {
9749         jclass c = (*env)->GetObjectClass(env, o);
9750         CHECK(c != NULL);
9751         LDKCustomOnionMessageContents_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageContents_JCalls), "LDKCustomOnionMessageContents_JCalls");
9752         atomic_init(&calls->refcnt, 1);
9753         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9754         calls->o = (*env)->NewWeakGlobalRef(env, o);
9755         calls->tlv_type_meth = (*env)->GetMethodID(env, c, "tlv_type", "()J");
9756         CHECK(calls->tlv_type_meth != NULL);
9757         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
9758         CHECK(calls->write_meth != NULL);
9759
9760         LDKCustomOnionMessageContents ret = {
9761                 .this_arg = (void*) calls,
9762                 .tlv_type = tlv_type_LDKCustomOnionMessageContents_jcall,
9763                 .write = write_LDKCustomOnionMessageContents_jcall,
9764                 .cloned = LDKCustomOnionMessageContents_JCalls_cloned,
9765                 .free = LDKCustomOnionMessageContents_JCalls_free,
9766         };
9767         return ret;
9768 }
9769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageContents_1new(JNIEnv *env, jclass clz, jobject o) {
9770         LDKCustomOnionMessageContents *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
9771         *res_ptr = LDKCustomOnionMessageContents_init(env, clz, o);
9772         return tag_ptr(res_ptr, true);
9773 }
9774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1tlv_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
9775         void* this_arg_ptr = untag_ptr(this_arg);
9776         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9777         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
9778         int64_t ret_conv = (this_arg_conv->tlv_type)(this_arg_conv->this_arg);
9779         return ret_conv;
9780 }
9781
9782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
9783         void* this_arg_ptr = untag_ptr(this_arg);
9784         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
9785         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
9786         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
9787         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9788         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9789         CVec_u8Z_free(ret_var);
9790         return ret_arr;
9791 }
9792
9793 static jclass LDKCOption_CustomOnionMessageContentsZ_Some_class = NULL;
9794 static jmethodID LDKCOption_CustomOnionMessageContentsZ_Some_meth = NULL;
9795 static jclass LDKCOption_CustomOnionMessageContentsZ_None_class = NULL;
9796 static jmethodID LDKCOption_CustomOnionMessageContentsZ_None_meth = NULL;
9797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CustomOnionMessageContentsZ_init (JNIEnv *env, jclass clz) {
9798         LDKCOption_CustomOnionMessageContentsZ_Some_class =
9799                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$Some"));
9800         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_class != NULL);
9801         LDKCOption_CustomOnionMessageContentsZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, "<init>", "(J)V");
9802         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_meth != NULL);
9803         LDKCOption_CustomOnionMessageContentsZ_None_class =
9804                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$None"));
9805         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_class != NULL);
9806         LDKCOption_CustomOnionMessageContentsZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_None_class, "<init>", "()V");
9807         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_meth != NULL);
9808 }
9809 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CustomOnionMessageContentsZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9810         LDKCOption_CustomOnionMessageContentsZ *obj = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(ptr);
9811         switch(obj->tag) {
9812                 case LDKCOption_CustomOnionMessageContentsZ_Some: {
9813                         LDKCustomOnionMessageContents* some_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
9814                         *some_ret = CustomOnionMessageContents_clone(&obj->some);
9815                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, LDKCOption_CustomOnionMessageContentsZ_Some_meth, tag_ptr(some_ret, true));
9816                 }
9817                 case LDKCOption_CustomOnionMessageContentsZ_None: {
9818                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_None_class, LDKCOption_CustomOnionMessageContentsZ_None_meth);
9819                 }
9820                 default: abort();
9821         }
9822 }
9823 static inline struct LDKCOption_CustomOnionMessageContentsZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
9824 CHECK(owner->result_ok);
9825         return COption_CustomOnionMessageContentsZ_clone(&*owner->contents.result);
9826 }
9827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9828         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
9829         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
9830         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(owner_conv);
9831         int64_t ret_ref = tag_ptr(ret_copy, true);
9832         return ret_ref;
9833 }
9834
9835 static inline struct LDKDecodeError CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
9836 CHECK(!owner->result_ok);
9837         return DecodeError_clone(&*owner->contents.err);
9838 }
9839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9840         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
9841         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9842         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(owner_conv);
9843         int64_t ret_ref = tag_ptr(ret_copy, true);
9844         return ret_ref;
9845 }
9846
9847 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
9848 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
9849 static jclass LDKCOption_NetAddressZ_None_class = NULL;
9850 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
9851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
9852         LDKCOption_NetAddressZ_Some_class =
9853                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
9854         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
9855         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
9856         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
9857         LDKCOption_NetAddressZ_None_class =
9858                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
9859         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
9860         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
9861         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
9862 }
9863 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9864         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)untag_ptr(ptr);
9865         switch(obj->tag) {
9866                 case LDKCOption_NetAddressZ_Some: {
9867                         int64_t some_ref = tag_ptr(&obj->some, false);
9868                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
9869                 }
9870                 case LDKCOption_NetAddressZ_None: {
9871                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
9872                 }
9873                 default: abort();
9874         }
9875 }
9876 static inline struct LDKPublicKey C2Tuple_PublicKeyCOption_NetAddressZZ_get_a(LDKC2Tuple_PublicKeyCOption_NetAddressZZ *NONNULL_PTR owner){
9877         return owner->a;
9878 }
9879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9880         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* owner_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(owner);
9881         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
9882         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyCOption_NetAddressZZ_get_a(owner_conv).compressed_form);
9883         return ret_arr;
9884 }
9885
9886 static inline struct LDKCOption_NetAddressZ C2Tuple_PublicKeyCOption_NetAddressZZ_get_b(LDKC2Tuple_PublicKeyCOption_NetAddressZZ *NONNULL_PTR owner){
9887         return COption_NetAddressZ_clone(&owner->b);
9888 }
9889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9890         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* owner_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(owner);
9891         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
9892         *ret_copy = C2Tuple_PublicKeyCOption_NetAddressZZ_get_b(owner_conv);
9893         int64_t ret_ref = tag_ptr(ret_copy, true);
9894         return ret_ref;
9895 }
9896
9897 static inline LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_clone(const LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ *orig) {
9898         LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ clone bytes"), .datalen = orig->datalen };
9899         for (size_t i = 0; i < ret.datalen; i++) {
9900                 ret.data[i] = C2Tuple_PublicKeyCOption_NetAddressZZ_clone(&orig->data[i]);
9901         }
9902         return ret;
9903 }
9904 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
9905 CHECK(owner->result_ok);
9906         return CVec_u8Z_clone(&*owner->contents.result);
9907 }
9908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9909         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
9910         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
9911         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
9912         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
9913         CVec_u8Z_free(ret_var);
9914         return ret_arr;
9915 }
9916
9917 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
9918         LDKPeerHandleError ret = *owner->contents.err;
9919         ret.is_owned = false;
9920         return ret;
9921 }
9922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9923         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
9924         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
9925         int64_t ret_ref = 0;
9926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9927         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9928         return ret_ref;
9929 }
9930
9931 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
9932 CHECK(owner->result_ok);
9933         return *owner->contents.result;
9934 }
9935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9936         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
9937         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
9938 }
9939
9940 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
9941         LDKPeerHandleError ret = *owner->contents.err;
9942         ret.is_owned = false;
9943         return ret;
9944 }
9945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9946         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
9947         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
9948         int64_t ret_ref = 0;
9949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9950         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9951         return ret_ref;
9952 }
9953
9954 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
9955 CHECK(owner->result_ok);
9956         return *owner->contents.result;
9957 }
9958 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9959         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
9960         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
9961         return ret_conv;
9962 }
9963
9964 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
9965         LDKPeerHandleError ret = *owner->contents.err;
9966         ret.is_owned = false;
9967         return ret;
9968 }
9969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9970         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
9971         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
9972         int64_t ret_ref = 0;
9973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9974         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9975         return ret_ref;
9976 }
9977
9978 static jclass LDKSendError_Secp256k1_class = NULL;
9979 static jmethodID LDKSendError_Secp256k1_meth = NULL;
9980 static jclass LDKSendError_TooBigPacket_class = NULL;
9981 static jmethodID LDKSendError_TooBigPacket_meth = NULL;
9982 static jclass LDKSendError_TooFewBlindedHops_class = NULL;
9983 static jmethodID LDKSendError_TooFewBlindedHops_meth = NULL;
9984 static jclass LDKSendError_InvalidFirstHop_class = NULL;
9985 static jmethodID LDKSendError_InvalidFirstHop_meth = NULL;
9986 static jclass LDKSendError_InvalidMessage_class = NULL;
9987 static jmethodID LDKSendError_InvalidMessage_meth = NULL;
9988 static jclass LDKSendError_BufferFull_class = NULL;
9989 static jmethodID LDKSendError_BufferFull_meth = NULL;
9990 static jclass LDKSendError_GetNodeIdFailed_class = NULL;
9991 static jmethodID LDKSendError_GetNodeIdFailed_meth = NULL;
9992 static jclass LDKSendError_BlindedPathAdvanceFailed_class = NULL;
9993 static jmethodID LDKSendError_BlindedPathAdvanceFailed_meth = NULL;
9994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSendError_init (JNIEnv *env, jclass clz) {
9995         LDKSendError_Secp256k1_class =
9996                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$Secp256k1"));
9997         CHECK(LDKSendError_Secp256k1_class != NULL);
9998         LDKSendError_Secp256k1_meth = (*env)->GetMethodID(env, LDKSendError_Secp256k1_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
9999         CHECK(LDKSendError_Secp256k1_meth != NULL);
10000         LDKSendError_TooBigPacket_class =
10001                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooBigPacket"));
10002         CHECK(LDKSendError_TooBigPacket_class != NULL);
10003         LDKSendError_TooBigPacket_meth = (*env)->GetMethodID(env, LDKSendError_TooBigPacket_class, "<init>", "()V");
10004         CHECK(LDKSendError_TooBigPacket_meth != NULL);
10005         LDKSendError_TooFewBlindedHops_class =
10006                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooFewBlindedHops"));
10007         CHECK(LDKSendError_TooFewBlindedHops_class != NULL);
10008         LDKSendError_TooFewBlindedHops_meth = (*env)->GetMethodID(env, LDKSendError_TooFewBlindedHops_class, "<init>", "()V");
10009         CHECK(LDKSendError_TooFewBlindedHops_meth != NULL);
10010         LDKSendError_InvalidFirstHop_class =
10011                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidFirstHop"));
10012         CHECK(LDKSendError_InvalidFirstHop_class != NULL);
10013         LDKSendError_InvalidFirstHop_meth = (*env)->GetMethodID(env, LDKSendError_InvalidFirstHop_class, "<init>", "()V");
10014         CHECK(LDKSendError_InvalidFirstHop_meth != NULL);
10015         LDKSendError_InvalidMessage_class =
10016                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidMessage"));
10017         CHECK(LDKSendError_InvalidMessage_class != NULL);
10018         LDKSendError_InvalidMessage_meth = (*env)->GetMethodID(env, LDKSendError_InvalidMessage_class, "<init>", "()V");
10019         CHECK(LDKSendError_InvalidMessage_meth != NULL);
10020         LDKSendError_BufferFull_class =
10021                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$BufferFull"));
10022         CHECK(LDKSendError_BufferFull_class != NULL);
10023         LDKSendError_BufferFull_meth = (*env)->GetMethodID(env, LDKSendError_BufferFull_class, "<init>", "()V");
10024         CHECK(LDKSendError_BufferFull_meth != NULL);
10025         LDKSendError_GetNodeIdFailed_class =
10026                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$GetNodeIdFailed"));
10027         CHECK(LDKSendError_GetNodeIdFailed_class != NULL);
10028         LDKSendError_GetNodeIdFailed_meth = (*env)->GetMethodID(env, LDKSendError_GetNodeIdFailed_class, "<init>", "()V");
10029         CHECK(LDKSendError_GetNodeIdFailed_meth != NULL);
10030         LDKSendError_BlindedPathAdvanceFailed_class =
10031                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$BlindedPathAdvanceFailed"));
10032         CHECK(LDKSendError_BlindedPathAdvanceFailed_class != NULL);
10033         LDKSendError_BlindedPathAdvanceFailed_meth = (*env)->GetMethodID(env, LDKSendError_BlindedPathAdvanceFailed_class, "<init>", "()V");
10034         CHECK(LDKSendError_BlindedPathAdvanceFailed_meth != NULL);
10035 }
10036 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSendError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10037         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
10038         switch(obj->tag) {
10039                 case LDKSendError_Secp256k1: {
10040                         jclass secp256k1_conv = LDKSecp256k1Error_to_java(env, obj->secp256k1);
10041                         return (*env)->NewObject(env, LDKSendError_Secp256k1_class, LDKSendError_Secp256k1_meth, secp256k1_conv);
10042                 }
10043                 case LDKSendError_TooBigPacket: {
10044                         return (*env)->NewObject(env, LDKSendError_TooBigPacket_class, LDKSendError_TooBigPacket_meth);
10045                 }
10046                 case LDKSendError_TooFewBlindedHops: {
10047                         return (*env)->NewObject(env, LDKSendError_TooFewBlindedHops_class, LDKSendError_TooFewBlindedHops_meth);
10048                 }
10049                 case LDKSendError_InvalidFirstHop: {
10050                         return (*env)->NewObject(env, LDKSendError_InvalidFirstHop_class, LDKSendError_InvalidFirstHop_meth);
10051                 }
10052                 case LDKSendError_InvalidMessage: {
10053                         return (*env)->NewObject(env, LDKSendError_InvalidMessage_class, LDKSendError_InvalidMessage_meth);
10054                 }
10055                 case LDKSendError_BufferFull: {
10056                         return (*env)->NewObject(env, LDKSendError_BufferFull_class, LDKSendError_BufferFull_meth);
10057                 }
10058                 case LDKSendError_GetNodeIdFailed: {
10059                         return (*env)->NewObject(env, LDKSendError_GetNodeIdFailed_class, LDKSendError_GetNodeIdFailed_meth);
10060                 }
10061                 case LDKSendError_BlindedPathAdvanceFailed: {
10062                         return (*env)->NewObject(env, LDKSendError_BlindedPathAdvanceFailed_class, LDKSendError_BlindedPathAdvanceFailed_meth);
10063                 }
10064                 default: abort();
10065         }
10066 }
10067 static inline void CResult_NoneSendErrorZ_get_ok(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
10068 CHECK(owner->result_ok);
10069         return *owner->contents.result;
10070 }
10071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10072         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
10073         CResult_NoneSendErrorZ_get_ok(owner_conv);
10074 }
10075
10076 static inline struct LDKSendError CResult_NoneSendErrorZ_get_err(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
10077 CHECK(!owner->result_ok);
10078         return SendError_clone(&*owner->contents.err);
10079 }
10080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10081         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
10082         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
10083         *ret_copy = CResult_NoneSendErrorZ_get_err(owner_conv);
10084         int64_t ret_ref = tag_ptr(ret_copy, true);
10085         return ret_ref;
10086 }
10087
10088 static inline struct LDKBlindedPath CResult_BlindedPathNoneZ_get_ok(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
10089         LDKBlindedPath ret = *owner->contents.result;
10090         ret.is_owned = false;
10091         return ret;
10092 }
10093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10094         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
10095         LDKBlindedPath ret_var = CResult_BlindedPathNoneZ_get_ok(owner_conv);
10096         int64_t ret_ref = 0;
10097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10099         return ret_ref;
10100 }
10101
10102 static inline void CResult_BlindedPathNoneZ_get_err(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
10103 CHECK(!owner->result_ok);
10104         return *owner->contents.err;
10105 }
10106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10107         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
10108         CResult_BlindedPathNoneZ_get_err(owner_conv);
10109 }
10110
10111 static inline struct LDKBlindedPath CResult_BlindedPathDecodeErrorZ_get_ok(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
10112         LDKBlindedPath ret = *owner->contents.result;
10113         ret.is_owned = false;
10114         return ret;
10115 }
10116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10117         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
10118         LDKBlindedPath ret_var = CResult_BlindedPathDecodeErrorZ_get_ok(owner_conv);
10119         int64_t ret_ref = 0;
10120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10121         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10122         return ret_ref;
10123 }
10124
10125 static inline struct LDKDecodeError CResult_BlindedPathDecodeErrorZ_get_err(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
10126 CHECK(!owner->result_ok);
10127         return DecodeError_clone(&*owner->contents.err);
10128 }
10129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10130         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
10131         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10132         *ret_copy = CResult_BlindedPathDecodeErrorZ_get_err(owner_conv);
10133         int64_t ret_ref = tag_ptr(ret_copy, true);
10134         return ret_ref;
10135 }
10136
10137 static inline struct LDKBlindedHop CResult_BlindedHopDecodeErrorZ_get_ok(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
10138         LDKBlindedHop ret = *owner->contents.result;
10139         ret.is_owned = false;
10140         return ret;
10141 }
10142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10143         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
10144         LDKBlindedHop ret_var = CResult_BlindedHopDecodeErrorZ_get_ok(owner_conv);
10145         int64_t ret_ref = 0;
10146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10147         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10148         return ret_ref;
10149 }
10150
10151 static inline struct LDKDecodeError CResult_BlindedHopDecodeErrorZ_get_err(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
10152 CHECK(!owner->result_ok);
10153         return DecodeError_clone(&*owner->contents.err);
10154 }
10155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10156         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
10157         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10158         *ret_copy = CResult_BlindedHopDecodeErrorZ_get_err(owner_conv);
10159         int64_t ret_ref = tag_ptr(ret_copy, true);
10160         return ret_ref;
10161 }
10162
10163 static jclass LDKParseError_Bech32Error_class = NULL;
10164 static jmethodID LDKParseError_Bech32Error_meth = NULL;
10165 static jclass LDKParseError_ParseAmountError_class = NULL;
10166 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
10167 static jclass LDKParseError_MalformedSignature_class = NULL;
10168 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
10169 static jclass LDKParseError_BadPrefix_class = NULL;
10170 static jmethodID LDKParseError_BadPrefix_meth = NULL;
10171 static jclass LDKParseError_UnknownCurrency_class = NULL;
10172 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
10173 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
10174 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
10175 static jclass LDKParseError_MalformedHRP_class = NULL;
10176 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
10177 static jclass LDKParseError_TooShortDataPart_class = NULL;
10178 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
10179 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
10180 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
10181 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
10182 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
10183 static jclass LDKParseError_PaddingError_class = NULL;
10184 static jmethodID LDKParseError_PaddingError_meth = NULL;
10185 static jclass LDKParseError_IntegerOverflowError_class = NULL;
10186 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
10187 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
10188 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
10189 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
10190 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
10191 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
10192 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
10193 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
10194 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
10195 static jclass LDKParseError_InvalidSliceLength_class = NULL;
10196 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
10197 static jclass LDKParseError_Skip_class = NULL;
10198 static jmethodID LDKParseError_Skip_meth = NULL;
10199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
10200         LDKParseError_Bech32Error_class =
10201                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
10202         CHECK(LDKParseError_Bech32Error_class != NULL);
10203         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
10204         CHECK(LDKParseError_Bech32Error_meth != NULL);
10205         LDKParseError_ParseAmountError_class =
10206                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
10207         CHECK(LDKParseError_ParseAmountError_class != NULL);
10208         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
10209         CHECK(LDKParseError_ParseAmountError_meth != NULL);
10210         LDKParseError_MalformedSignature_class =
10211                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
10212         CHECK(LDKParseError_MalformedSignature_class != NULL);
10213         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
10214         CHECK(LDKParseError_MalformedSignature_meth != NULL);
10215         LDKParseError_BadPrefix_class =
10216                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
10217         CHECK(LDKParseError_BadPrefix_class != NULL);
10218         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
10219         CHECK(LDKParseError_BadPrefix_meth != NULL);
10220         LDKParseError_UnknownCurrency_class =
10221                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
10222         CHECK(LDKParseError_UnknownCurrency_class != NULL);
10223         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
10224         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
10225         LDKParseError_UnknownSiPrefix_class =
10226                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
10227         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
10228         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
10229         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
10230         LDKParseError_MalformedHRP_class =
10231                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
10232         CHECK(LDKParseError_MalformedHRP_class != NULL);
10233         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
10234         CHECK(LDKParseError_MalformedHRP_meth != NULL);
10235         LDKParseError_TooShortDataPart_class =
10236                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
10237         CHECK(LDKParseError_TooShortDataPart_class != NULL);
10238         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
10239         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
10240         LDKParseError_UnexpectedEndOfTaggedFields_class =
10241                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
10242         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
10243         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
10244         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
10245         LDKParseError_DescriptionDecodeError_class =
10246                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
10247         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
10248         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
10249         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
10250         LDKParseError_PaddingError_class =
10251                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
10252         CHECK(LDKParseError_PaddingError_class != NULL);
10253         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
10254         CHECK(LDKParseError_PaddingError_meth != NULL);
10255         LDKParseError_IntegerOverflowError_class =
10256                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
10257         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
10258         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
10259         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
10260         LDKParseError_InvalidSegWitProgramLength_class =
10261                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
10262         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
10263         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
10264         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
10265         LDKParseError_InvalidPubKeyHashLength_class =
10266                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
10267         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
10268         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
10269         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
10270         LDKParseError_InvalidScriptHashLength_class =
10271                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
10272         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
10273         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
10274         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
10275         LDKParseError_InvalidRecoveryId_class =
10276                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
10277         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
10278         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
10279         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
10280         LDKParseError_InvalidSliceLength_class =
10281                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
10282         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
10283         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
10284         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
10285         LDKParseError_Skip_class =
10286                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
10287         CHECK(LDKParseError_Skip_class != NULL);
10288         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
10289         CHECK(LDKParseError_Skip_meth != NULL);
10290 }
10291 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10292         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
10293         switch(obj->tag) {
10294                 case LDKParseError_Bech32Error: {
10295                         int64_t bech32_error_ref = tag_ptr(&obj->bech32_error, false);
10296                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
10297                 }
10298                 case LDKParseError_ParseAmountError: {
10299                         /*obj->parse_amount_error*/
10300                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
10301                 }
10302                 case LDKParseError_MalformedSignature: {
10303                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
10304                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
10305                 }
10306                 case LDKParseError_BadPrefix: {
10307                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
10308                 }
10309                 case LDKParseError_UnknownCurrency: {
10310                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
10311                 }
10312                 case LDKParseError_UnknownSiPrefix: {
10313                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
10314                 }
10315                 case LDKParseError_MalformedHRP: {
10316                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
10317                 }
10318                 case LDKParseError_TooShortDataPart: {
10319                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
10320                 }
10321                 case LDKParseError_UnexpectedEndOfTaggedFields: {
10322                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
10323                 }
10324                 case LDKParseError_DescriptionDecodeError: {
10325                         /*obj->description_decode_error*/
10326                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
10327                 }
10328                 case LDKParseError_PaddingError: {
10329                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
10330                 }
10331                 case LDKParseError_IntegerOverflowError: {
10332                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
10333                 }
10334                 case LDKParseError_InvalidSegWitProgramLength: {
10335                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
10336                 }
10337                 case LDKParseError_InvalidPubKeyHashLength: {
10338                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
10339                 }
10340                 case LDKParseError_InvalidScriptHashLength: {
10341                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
10342                 }
10343                 case LDKParseError_InvalidRecoveryId: {
10344                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
10345                 }
10346                 case LDKParseError_InvalidSliceLength: {
10347                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
10348                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
10349                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
10350                 }
10351                 case LDKParseError_Skip: {
10352                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
10353                 }
10354                 default: abort();
10355         }
10356 }
10357 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
10358 CHECK(owner->result_ok);
10359         return SiPrefix_clone(&*owner->contents.result);
10360 }
10361 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10362         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
10363         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
10364         return ret_conv;
10365 }
10366
10367 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
10368 CHECK(!owner->result_ok);
10369         return ParseError_clone(&*owner->contents.err);
10370 }
10371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10372         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
10373         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
10374         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
10375         int64_t ret_ref = tag_ptr(ret_copy, true);
10376         return ret_ref;
10377 }
10378
10379 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
10380 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
10381 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
10382 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
10383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
10384         LDKParseOrSemanticError_ParseError_class =
10385                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
10386         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
10387         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
10388         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
10389         LDKParseOrSemanticError_SemanticError_class =
10390                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
10391         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
10392         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
10393         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
10394 }
10395 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10396         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
10397         switch(obj->tag) {
10398                 case LDKParseOrSemanticError_ParseError: {
10399                         int64_t parse_error_ref = tag_ptr(&obj->parse_error, false);
10400                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
10401                 }
10402                 case LDKParseOrSemanticError_SemanticError: {
10403                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
10404                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
10405                 }
10406                 default: abort();
10407         }
10408 }
10409 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
10410         LDKInvoice ret = *owner->contents.result;
10411         ret.is_owned = false;
10412         return ret;
10413 }
10414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10415         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
10416         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
10417         int64_t ret_ref = 0;
10418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10419         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10420         return ret_ref;
10421 }
10422
10423 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
10424 CHECK(!owner->result_ok);
10425         return ParseOrSemanticError_clone(&*owner->contents.err);
10426 }
10427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10428         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
10429         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
10430         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
10431         int64_t ret_ref = tag_ptr(ret_copy, true);
10432         return ret_ref;
10433 }
10434
10435 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
10436         LDKSignedRawInvoice ret = *owner->contents.result;
10437         ret.is_owned = false;
10438         return ret;
10439 }
10440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10441         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
10442         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
10443         int64_t ret_ref = 0;
10444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10445         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10446         return ret_ref;
10447 }
10448
10449 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
10450 CHECK(!owner->result_ok);
10451         return ParseError_clone(&*owner->contents.err);
10452 }
10453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10454         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
10455         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
10456         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
10457         int64_t ret_ref = tag_ptr(ret_copy, true);
10458         return ret_ref;
10459 }
10460
10461 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
10462         LDKRawInvoice ret = owner->a;
10463         ret.is_owned = false;
10464         return ret;
10465 }
10466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
10467         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
10468         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
10469         int64_t ret_ref = 0;
10470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10471         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10472         return ret_ref;
10473 }
10474
10475 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
10476         return ThirtyTwoBytes_clone(&owner->b);
10477 }
10478 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
10479         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
10480         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
10481         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
10482         return ret_arr;
10483 }
10484
10485 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
10486         LDKInvoiceSignature ret = owner->c;
10487         ret.is_owned = false;
10488         return ret;
10489 }
10490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
10491         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
10492         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
10493         int64_t ret_ref = 0;
10494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10495         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10496         return ret_ref;
10497 }
10498
10499 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
10500         LDKPayeePubKey ret = *owner->contents.result;
10501         ret.is_owned = false;
10502         return ret;
10503 }
10504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10505         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
10506         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
10507         int64_t ret_ref = 0;
10508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10509         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10510         return ret_ref;
10511 }
10512
10513 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
10514 CHECK(!owner->result_ok);
10515         return *owner->contents.err;
10516 }
10517 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10518         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
10519         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
10520         return ret_conv;
10521 }
10522
10523 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
10524         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
10525         for (size_t i = 0; i < ret.datalen; i++) {
10526                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
10527         }
10528         return ret;
10529 }
10530 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
10531         LDKPositiveTimestamp ret = *owner->contents.result;
10532         ret.is_owned = false;
10533         return ret;
10534 }
10535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10536         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
10537         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
10538         int64_t ret_ref = 0;
10539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10540         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10541         return ret_ref;
10542 }
10543
10544 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
10545 CHECK(!owner->result_ok);
10546         return CreationError_clone(&*owner->contents.err);
10547 }
10548 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10549         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
10550         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
10551         return ret_conv;
10552 }
10553
10554 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
10555 CHECK(owner->result_ok);
10556         return *owner->contents.result;
10557 }
10558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10559         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
10560         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
10561 }
10562
10563 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
10564 CHECK(!owner->result_ok);
10565         return SemanticError_clone(&*owner->contents.err);
10566 }
10567 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10568         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
10569         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
10570         return ret_conv;
10571 }
10572
10573 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
10574         LDKInvoice ret = *owner->contents.result;
10575         ret.is_owned = false;
10576         return ret;
10577 }
10578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10579         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
10580         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
10581         int64_t ret_ref = 0;
10582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10584         return ret_ref;
10585 }
10586
10587 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
10588 CHECK(!owner->result_ok);
10589         return SemanticError_clone(&*owner->contents.err);
10590 }
10591 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10592         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
10593         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
10594         return ret_conv;
10595 }
10596
10597 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
10598         LDKDescription ret = *owner->contents.result;
10599         ret.is_owned = false;
10600         return ret;
10601 }
10602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10603         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
10604         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
10605         int64_t ret_ref = 0;
10606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10607         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10608         return ret_ref;
10609 }
10610
10611 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
10612 CHECK(!owner->result_ok);
10613         return CreationError_clone(&*owner->contents.err);
10614 }
10615 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10616         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
10617         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
10618         return ret_conv;
10619 }
10620
10621 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
10622         LDKPrivateRoute ret = *owner->contents.result;
10623         ret.is_owned = false;
10624         return ret;
10625 }
10626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10627         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
10628         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
10629         int64_t ret_ref = 0;
10630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10631         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10632         return ret_ref;
10633 }
10634
10635 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
10636 CHECK(!owner->result_ok);
10637         return CreationError_clone(&*owner->contents.err);
10638 }
10639 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10640         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
10641         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
10642         return ret_conv;
10643 }
10644
10645 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
10646 CHECK(owner->result_ok);
10647         return NetAddress_clone(&*owner->contents.result);
10648 }
10649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10650         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
10651         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
10652         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
10653         int64_t ret_ref = tag_ptr(ret_copy, true);
10654         return ret_ref;
10655 }
10656
10657 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
10658 CHECK(!owner->result_ok);
10659         return DecodeError_clone(&*owner->contents.err);
10660 }
10661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10662         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
10663         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10664         *ret_copy = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
10665         int64_t ret_ref = tag_ptr(ret_copy, true);
10666         return ret_ref;
10667 }
10668
10669 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
10670         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
10671         for (size_t i = 0; i < ret.datalen; i++) {
10672                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
10673         }
10674         return ret;
10675 }
10676 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
10677         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
10678         for (size_t i = 0; i < ret.datalen; i++) {
10679                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
10680         }
10681         return ret;
10682 }
10683 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
10684         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
10685         for (size_t i = 0; i < ret.datalen; i++) {
10686                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
10687         }
10688         return ret;
10689 }
10690 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
10691         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
10692         for (size_t i = 0; i < ret.datalen; i++) {
10693                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
10694         }
10695         return ret;
10696 }
10697 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
10698         LDKAcceptChannel ret = *owner->contents.result;
10699         ret.is_owned = false;
10700         return ret;
10701 }
10702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10703         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
10704         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
10705         int64_t ret_ref = 0;
10706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10707         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10708         return ret_ref;
10709 }
10710
10711 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
10712 CHECK(!owner->result_ok);
10713         return DecodeError_clone(&*owner->contents.err);
10714 }
10715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10716         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
10717         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10718         *ret_copy = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
10719         int64_t ret_ref = tag_ptr(ret_copy, true);
10720         return ret_ref;
10721 }
10722
10723 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
10724         LDKAnnouncementSignatures ret = *owner->contents.result;
10725         ret.is_owned = false;
10726         return ret;
10727 }
10728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10729         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
10730         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
10731         int64_t ret_ref = 0;
10732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10733         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10734         return ret_ref;
10735 }
10736
10737 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
10738 CHECK(!owner->result_ok);
10739         return DecodeError_clone(&*owner->contents.err);
10740 }
10741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10742         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
10743         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10744         *ret_copy = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
10745         int64_t ret_ref = tag_ptr(ret_copy, true);
10746         return ret_ref;
10747 }
10748
10749 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
10750         LDKChannelReestablish ret = *owner->contents.result;
10751         ret.is_owned = false;
10752         return ret;
10753 }
10754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10755         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
10756         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
10757         int64_t ret_ref = 0;
10758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10759         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10760         return ret_ref;
10761 }
10762
10763 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
10764 CHECK(!owner->result_ok);
10765         return DecodeError_clone(&*owner->contents.err);
10766 }
10767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10768         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
10769         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10770         *ret_copy = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
10771         int64_t ret_ref = tag_ptr(ret_copy, true);
10772         return ret_ref;
10773 }
10774
10775 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
10776         LDKClosingSigned ret = *owner->contents.result;
10777         ret.is_owned = false;
10778         return ret;
10779 }
10780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10781         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
10782         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
10783         int64_t ret_ref = 0;
10784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10785         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10786         return ret_ref;
10787 }
10788
10789 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
10790 CHECK(!owner->result_ok);
10791         return DecodeError_clone(&*owner->contents.err);
10792 }
10793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10794         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
10795         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10796         *ret_copy = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
10797         int64_t ret_ref = tag_ptr(ret_copy, true);
10798         return ret_ref;
10799 }
10800
10801 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
10802         LDKClosingSignedFeeRange ret = *owner->contents.result;
10803         ret.is_owned = false;
10804         return ret;
10805 }
10806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10807         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
10808         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
10809         int64_t ret_ref = 0;
10810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10811         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10812         return ret_ref;
10813 }
10814
10815 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
10816 CHECK(!owner->result_ok);
10817         return DecodeError_clone(&*owner->contents.err);
10818 }
10819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10820         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
10821         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10822         *ret_copy = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
10823         int64_t ret_ref = tag_ptr(ret_copy, true);
10824         return ret_ref;
10825 }
10826
10827 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
10828         LDKCommitmentSigned ret = *owner->contents.result;
10829         ret.is_owned = false;
10830         return ret;
10831 }
10832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10833         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
10834         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
10835         int64_t ret_ref = 0;
10836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10837         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10838         return ret_ref;
10839 }
10840
10841 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
10842 CHECK(!owner->result_ok);
10843         return DecodeError_clone(&*owner->contents.err);
10844 }
10845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10846         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
10847         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10848         *ret_copy = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
10849         int64_t ret_ref = tag_ptr(ret_copy, true);
10850         return ret_ref;
10851 }
10852
10853 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
10854         LDKFundingCreated ret = *owner->contents.result;
10855         ret.is_owned = false;
10856         return ret;
10857 }
10858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10859         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
10860         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
10861         int64_t ret_ref = 0;
10862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10863         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10864         return ret_ref;
10865 }
10866
10867 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
10868 CHECK(!owner->result_ok);
10869         return DecodeError_clone(&*owner->contents.err);
10870 }
10871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10872         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
10873         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10874         *ret_copy = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
10875         int64_t ret_ref = tag_ptr(ret_copy, true);
10876         return ret_ref;
10877 }
10878
10879 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
10880         LDKFundingSigned ret = *owner->contents.result;
10881         ret.is_owned = false;
10882         return ret;
10883 }
10884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10885         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
10886         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
10887         int64_t ret_ref = 0;
10888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10889         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10890         return ret_ref;
10891 }
10892
10893 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
10894 CHECK(!owner->result_ok);
10895         return DecodeError_clone(&*owner->contents.err);
10896 }
10897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10898         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
10899         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10900         *ret_copy = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
10901         int64_t ret_ref = tag_ptr(ret_copy, true);
10902         return ret_ref;
10903 }
10904
10905 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
10906         LDKChannelReady ret = *owner->contents.result;
10907         ret.is_owned = false;
10908         return ret;
10909 }
10910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10911         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
10912         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
10913         int64_t ret_ref = 0;
10914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10915         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10916         return ret_ref;
10917 }
10918
10919 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
10920 CHECK(!owner->result_ok);
10921         return DecodeError_clone(&*owner->contents.err);
10922 }
10923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10924         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
10925         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10926         *ret_copy = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
10927         int64_t ret_ref = tag_ptr(ret_copy, true);
10928         return ret_ref;
10929 }
10930
10931 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
10932         LDKInit ret = *owner->contents.result;
10933         ret.is_owned = false;
10934         return ret;
10935 }
10936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10937         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
10938         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
10939         int64_t ret_ref = 0;
10940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10941         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10942         return ret_ref;
10943 }
10944
10945 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
10946 CHECK(!owner->result_ok);
10947         return DecodeError_clone(&*owner->contents.err);
10948 }
10949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10950         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
10951         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10952         *ret_copy = CResult_InitDecodeErrorZ_get_err(owner_conv);
10953         int64_t ret_ref = tag_ptr(ret_copy, true);
10954         return ret_ref;
10955 }
10956
10957 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
10958         LDKOpenChannel ret = *owner->contents.result;
10959         ret.is_owned = false;
10960         return ret;
10961 }
10962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10963         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
10964         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
10965         int64_t ret_ref = 0;
10966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10967         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10968         return ret_ref;
10969 }
10970
10971 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
10972 CHECK(!owner->result_ok);
10973         return DecodeError_clone(&*owner->contents.err);
10974 }
10975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10976         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
10977         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10978         *ret_copy = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
10979         int64_t ret_ref = tag_ptr(ret_copy, true);
10980         return ret_ref;
10981 }
10982
10983 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
10984         LDKRevokeAndACK ret = *owner->contents.result;
10985         ret.is_owned = false;
10986         return ret;
10987 }
10988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10989         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
10990         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
10991         int64_t ret_ref = 0;
10992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10993         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10994         return ret_ref;
10995 }
10996
10997 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
10998 CHECK(!owner->result_ok);
10999         return DecodeError_clone(&*owner->contents.err);
11000 }
11001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11002         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
11003         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11004         *ret_copy = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
11005         int64_t ret_ref = tag_ptr(ret_copy, true);
11006         return ret_ref;
11007 }
11008
11009 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
11010         LDKShutdown ret = *owner->contents.result;
11011         ret.is_owned = false;
11012         return ret;
11013 }
11014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11015         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
11016         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
11017         int64_t ret_ref = 0;
11018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11019         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11020         return ret_ref;
11021 }
11022
11023 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
11024 CHECK(!owner->result_ok);
11025         return DecodeError_clone(&*owner->contents.err);
11026 }
11027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11028         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
11029         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11030         *ret_copy = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
11031         int64_t ret_ref = tag_ptr(ret_copy, true);
11032         return ret_ref;
11033 }
11034
11035 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
11036         LDKUpdateFailHTLC ret = *owner->contents.result;
11037         ret.is_owned = false;
11038         return ret;
11039 }
11040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11041         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
11042         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
11043         int64_t ret_ref = 0;
11044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11045         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11046         return ret_ref;
11047 }
11048
11049 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
11050 CHECK(!owner->result_ok);
11051         return DecodeError_clone(&*owner->contents.err);
11052 }
11053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11054         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
11055         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11056         *ret_copy = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
11057         int64_t ret_ref = tag_ptr(ret_copy, true);
11058         return ret_ref;
11059 }
11060
11061 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
11062         LDKUpdateFailMalformedHTLC ret = *owner->contents.result;
11063         ret.is_owned = false;
11064         return ret;
11065 }
11066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11067         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
11068         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
11069         int64_t ret_ref = 0;
11070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11071         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11072         return ret_ref;
11073 }
11074
11075 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
11076 CHECK(!owner->result_ok);
11077         return DecodeError_clone(&*owner->contents.err);
11078 }
11079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11080         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
11081         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11082         *ret_copy = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
11083         int64_t ret_ref = tag_ptr(ret_copy, true);
11084         return ret_ref;
11085 }
11086
11087 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
11088         LDKUpdateFee ret = *owner->contents.result;
11089         ret.is_owned = false;
11090         return ret;
11091 }
11092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11093         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
11094         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
11095         int64_t ret_ref = 0;
11096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11097         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11098         return ret_ref;
11099 }
11100
11101 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
11102 CHECK(!owner->result_ok);
11103         return DecodeError_clone(&*owner->contents.err);
11104 }
11105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11106         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
11107         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11108         *ret_copy = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
11109         int64_t ret_ref = tag_ptr(ret_copy, true);
11110         return ret_ref;
11111 }
11112
11113 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
11114         LDKUpdateFulfillHTLC ret = *owner->contents.result;
11115         ret.is_owned = false;
11116         return ret;
11117 }
11118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11119         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
11120         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
11121         int64_t ret_ref = 0;
11122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11123         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11124         return ret_ref;
11125 }
11126
11127 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
11128 CHECK(!owner->result_ok);
11129         return DecodeError_clone(&*owner->contents.err);
11130 }
11131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11132         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
11133         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11134         *ret_copy = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
11135         int64_t ret_ref = tag_ptr(ret_copy, true);
11136         return ret_ref;
11137 }
11138
11139 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
11140         LDKUpdateAddHTLC ret = *owner->contents.result;
11141         ret.is_owned = false;
11142         return ret;
11143 }
11144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11145         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
11146         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
11147         int64_t ret_ref = 0;
11148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11150         return ret_ref;
11151 }
11152
11153 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
11154 CHECK(!owner->result_ok);
11155         return DecodeError_clone(&*owner->contents.err);
11156 }
11157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11158         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
11159         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11160         *ret_copy = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
11161         int64_t ret_ref = tag_ptr(ret_copy, true);
11162         return ret_ref;
11163 }
11164
11165 static inline struct LDKOnionMessage CResult_OnionMessageDecodeErrorZ_get_ok(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
11166         LDKOnionMessage ret = *owner->contents.result;
11167         ret.is_owned = false;
11168         return ret;
11169 }
11170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11171         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
11172         LDKOnionMessage ret_var = CResult_OnionMessageDecodeErrorZ_get_ok(owner_conv);
11173         int64_t ret_ref = 0;
11174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11175         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11176         return ret_ref;
11177 }
11178
11179 static inline struct LDKDecodeError CResult_OnionMessageDecodeErrorZ_get_err(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
11180 CHECK(!owner->result_ok);
11181         return DecodeError_clone(&*owner->contents.err);
11182 }
11183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11184         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
11185         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11186         *ret_copy = CResult_OnionMessageDecodeErrorZ_get_err(owner_conv);
11187         int64_t ret_ref = tag_ptr(ret_copy, true);
11188         return ret_ref;
11189 }
11190
11191 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
11192         LDKPing ret = *owner->contents.result;
11193         ret.is_owned = false;
11194         return ret;
11195 }
11196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11197         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
11198         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
11199         int64_t ret_ref = 0;
11200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11201         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11202         return ret_ref;
11203 }
11204
11205 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
11206 CHECK(!owner->result_ok);
11207         return DecodeError_clone(&*owner->contents.err);
11208 }
11209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11210         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
11211         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11212         *ret_copy = CResult_PingDecodeErrorZ_get_err(owner_conv);
11213         int64_t ret_ref = tag_ptr(ret_copy, true);
11214         return ret_ref;
11215 }
11216
11217 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
11218         LDKPong ret = *owner->contents.result;
11219         ret.is_owned = false;
11220         return ret;
11221 }
11222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11223         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
11224         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
11225         int64_t ret_ref = 0;
11226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11227         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11228         return ret_ref;
11229 }
11230
11231 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
11232 CHECK(!owner->result_ok);
11233         return DecodeError_clone(&*owner->contents.err);
11234 }
11235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11236         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
11237         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11238         *ret_copy = CResult_PongDecodeErrorZ_get_err(owner_conv);
11239         int64_t ret_ref = tag_ptr(ret_copy, true);
11240         return ret_ref;
11241 }
11242
11243 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11244         LDKUnsignedChannelAnnouncement ret = *owner->contents.result;
11245         ret.is_owned = false;
11246         return ret;
11247 }
11248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11249         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
11250         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
11251         int64_t ret_ref = 0;
11252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11253         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11254         return ret_ref;
11255 }
11256
11257 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11258 CHECK(!owner->result_ok);
11259         return DecodeError_clone(&*owner->contents.err);
11260 }
11261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11262         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
11263         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11264         *ret_copy = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
11265         int64_t ret_ref = tag_ptr(ret_copy, true);
11266         return ret_ref;
11267 }
11268
11269 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11270         LDKChannelAnnouncement ret = *owner->contents.result;
11271         ret.is_owned = false;
11272         return ret;
11273 }
11274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11275         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
11276         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
11277         int64_t ret_ref = 0;
11278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11279         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11280         return ret_ref;
11281 }
11282
11283 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11284 CHECK(!owner->result_ok);
11285         return DecodeError_clone(&*owner->contents.err);
11286 }
11287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11288         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
11289         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11290         *ret_copy = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
11291         int64_t ret_ref = tag_ptr(ret_copy, true);
11292         return ret_ref;
11293 }
11294
11295 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
11296         LDKUnsignedChannelUpdate ret = *owner->contents.result;
11297         ret.is_owned = false;
11298         return ret;
11299 }
11300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11301         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
11302         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
11303         int64_t ret_ref = 0;
11304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11305         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11306         return ret_ref;
11307 }
11308
11309 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
11310 CHECK(!owner->result_ok);
11311         return DecodeError_clone(&*owner->contents.err);
11312 }
11313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11314         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
11315         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11316         *ret_copy = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
11317         int64_t ret_ref = tag_ptr(ret_copy, true);
11318         return ret_ref;
11319 }
11320
11321 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
11322         LDKChannelUpdate ret = *owner->contents.result;
11323         ret.is_owned = false;
11324         return ret;
11325 }
11326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11327         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
11328         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
11329         int64_t ret_ref = 0;
11330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11331         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11332         return ret_ref;
11333 }
11334
11335 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
11336 CHECK(!owner->result_ok);
11337         return DecodeError_clone(&*owner->contents.err);
11338 }
11339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11340         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
11341         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11342         *ret_copy = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
11343         int64_t ret_ref = tag_ptr(ret_copy, true);
11344         return ret_ref;
11345 }
11346
11347 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
11348         LDKErrorMessage ret = *owner->contents.result;
11349         ret.is_owned = false;
11350         return ret;
11351 }
11352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11353         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
11354         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
11355         int64_t ret_ref = 0;
11356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11358         return ret_ref;
11359 }
11360
11361 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
11362 CHECK(!owner->result_ok);
11363         return DecodeError_clone(&*owner->contents.err);
11364 }
11365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11366         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
11367         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11368         *ret_copy = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
11369         int64_t ret_ref = tag_ptr(ret_copy, true);
11370         return ret_ref;
11371 }
11372
11373 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
11374         LDKWarningMessage ret = *owner->contents.result;
11375         ret.is_owned = false;
11376         return ret;
11377 }
11378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11379         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
11380         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
11381         int64_t ret_ref = 0;
11382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11383         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11384         return ret_ref;
11385 }
11386
11387 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
11388 CHECK(!owner->result_ok);
11389         return DecodeError_clone(&*owner->contents.err);
11390 }
11391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11392         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
11393         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11394         *ret_copy = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
11395         int64_t ret_ref = tag_ptr(ret_copy, true);
11396         return ret_ref;
11397 }
11398
11399 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11400         LDKUnsignedNodeAnnouncement ret = *owner->contents.result;
11401         ret.is_owned = false;
11402         return ret;
11403 }
11404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11405         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
11406         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
11407         int64_t ret_ref = 0;
11408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11409         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11410         return ret_ref;
11411 }
11412
11413 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11414 CHECK(!owner->result_ok);
11415         return DecodeError_clone(&*owner->contents.err);
11416 }
11417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11418         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
11419         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11420         *ret_copy = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
11421         int64_t ret_ref = tag_ptr(ret_copy, true);
11422         return ret_ref;
11423 }
11424
11425 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11426         LDKNodeAnnouncement ret = *owner->contents.result;
11427         ret.is_owned = false;
11428         return ret;
11429 }
11430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11431         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
11432         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
11433         int64_t ret_ref = 0;
11434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11435         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11436         return ret_ref;
11437 }
11438
11439 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
11440 CHECK(!owner->result_ok);
11441         return DecodeError_clone(&*owner->contents.err);
11442 }
11443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11444         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
11445         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11446         *ret_copy = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
11447         int64_t ret_ref = tag_ptr(ret_copy, true);
11448         return ret_ref;
11449 }
11450
11451 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
11452         LDKQueryShortChannelIds ret = *owner->contents.result;
11453         ret.is_owned = false;
11454         return ret;
11455 }
11456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11457         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
11458         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
11459         int64_t ret_ref = 0;
11460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11461         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11462         return ret_ref;
11463 }
11464
11465 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
11466 CHECK(!owner->result_ok);
11467         return DecodeError_clone(&*owner->contents.err);
11468 }
11469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11470         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
11471         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11472         *ret_copy = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
11473         int64_t ret_ref = tag_ptr(ret_copy, true);
11474         return ret_ref;
11475 }
11476
11477 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
11478         LDKReplyShortChannelIdsEnd ret = *owner->contents.result;
11479         ret.is_owned = false;
11480         return ret;
11481 }
11482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11483         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
11484         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
11485         int64_t ret_ref = 0;
11486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11487         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11488         return ret_ref;
11489 }
11490
11491 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
11492 CHECK(!owner->result_ok);
11493         return DecodeError_clone(&*owner->contents.err);
11494 }
11495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11496         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
11497         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11498         *ret_copy = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
11499         int64_t ret_ref = tag_ptr(ret_copy, true);
11500         return ret_ref;
11501 }
11502
11503 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
11504         LDKQueryChannelRange ret = *owner->contents.result;
11505         ret.is_owned = false;
11506         return ret;
11507 }
11508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11509         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
11510         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
11511         int64_t ret_ref = 0;
11512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11513         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11514         return ret_ref;
11515 }
11516
11517 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
11518 CHECK(!owner->result_ok);
11519         return DecodeError_clone(&*owner->contents.err);
11520 }
11521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11522         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
11523         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11524         *ret_copy = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
11525         int64_t ret_ref = tag_ptr(ret_copy, true);
11526         return ret_ref;
11527 }
11528
11529 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
11530         LDKReplyChannelRange ret = *owner->contents.result;
11531         ret.is_owned = false;
11532         return ret;
11533 }
11534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11535         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
11536         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
11537         int64_t ret_ref = 0;
11538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11539         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11540         return ret_ref;
11541 }
11542
11543 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
11544 CHECK(!owner->result_ok);
11545         return DecodeError_clone(&*owner->contents.err);
11546 }
11547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11548         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
11549         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11550         *ret_copy = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
11551         int64_t ret_ref = tag_ptr(ret_copy, true);
11552         return ret_ref;
11553 }
11554
11555 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
11556         LDKGossipTimestampFilter ret = *owner->contents.result;
11557         ret.is_owned = false;
11558         return ret;
11559 }
11560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11561         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
11562         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
11563         int64_t ret_ref = 0;
11564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11565         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11566         return ret_ref;
11567 }
11568
11569 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
11570 CHECK(!owner->result_ok);
11571         return DecodeError_clone(&*owner->contents.err);
11572 }
11573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11574         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
11575         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11576         *ret_copy = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
11577         int64_t ret_ref = tag_ptr(ret_copy, true);
11578         return ret_ref;
11579 }
11580
11581 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
11582         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
11583         for (size_t i = 0; i < ret.datalen; i++) {
11584                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
11585         }
11586         return ret;
11587 }
11588 static jclass LDKSignOrCreationError_SignError_class = NULL;
11589 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
11590 static jclass LDKSignOrCreationError_CreationError_class = NULL;
11591 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
11592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
11593         LDKSignOrCreationError_SignError_class =
11594                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
11595         CHECK(LDKSignOrCreationError_SignError_class != NULL);
11596         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
11597         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
11598         LDKSignOrCreationError_CreationError_class =
11599                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
11600         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
11601         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
11602         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
11603 }
11604 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
11605         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
11606         switch(obj->tag) {
11607                 case LDKSignOrCreationError_SignError: {
11608                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
11609                 }
11610                 case LDKSignOrCreationError_CreationError: {
11611                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
11612                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
11613                 }
11614                 default: abort();
11615         }
11616 }
11617 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
11618         LDKInvoice ret = *owner->contents.result;
11619         ret.is_owned = false;
11620         return ret;
11621 }
11622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11623         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
11624         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
11625         int64_t ret_ref = 0;
11626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11627         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11628         return ret_ref;
11629 }
11630
11631 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
11632 CHECK(!owner->result_ok);
11633         return SignOrCreationError_clone(&*owner->contents.err);
11634 }
11635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11636         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
11637         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
11638         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
11639         int64_t ret_ref = tag_ptr(ret_copy, true);
11640         return ret_ref;
11641 }
11642
11643 static inline LDKCVec_FutureZ CVec_FutureZ_clone(const LDKCVec_FutureZ *orig) {
11644         LDKCVec_FutureZ ret = { .data = MALLOC(sizeof(LDKFuture) * orig->datalen, "LDKCVec_FutureZ clone bytes"), .datalen = orig->datalen };
11645         for (size_t i = 0; i < ret.datalen; i++) {
11646                 ret.data[i] = Future_clone(&orig->data[i]);
11647         }
11648         return ret;
11649 }
11650 typedef struct LDKFilter_JCalls {
11651         atomic_size_t refcnt;
11652         JavaVM *vm;
11653         jweak o;
11654         jmethodID register_tx_meth;
11655         jmethodID register_output_meth;
11656 } LDKFilter_JCalls;
11657 static void LDKFilter_JCalls_free(void* this_arg) {
11658         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11659         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11660                 JNIEnv *env;
11661                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11662                 if (get_jenv_res == JNI_EDETACHED) {
11663                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11664                 } else {
11665                         DO_ASSERT(get_jenv_res == JNI_OK);
11666                 }
11667                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11668                 if (get_jenv_res == JNI_EDETACHED) {
11669                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11670                 }
11671                 FREE(j_calls);
11672         }
11673 }
11674 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
11675         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11676         JNIEnv *env;
11677         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11678         if (get_jenv_res == JNI_EDETACHED) {
11679                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11680         } else {
11681                 DO_ASSERT(get_jenv_res == JNI_OK);
11682         }
11683         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11684         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11685         LDKu8slice script_pubkey_var = script_pubkey;
11686         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
11687         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
11688         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11689         CHECK(obj != NULL);
11690         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
11691         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11692                 (*env)->ExceptionDescribe(env);
11693                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
11694         }
11695         if (get_jenv_res == JNI_EDETACHED) {
11696                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11697         }
11698 }
11699 void register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
11700         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11701         JNIEnv *env;
11702         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11703         if (get_jenv_res == JNI_EDETACHED) {
11704                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11705         } else {
11706                 DO_ASSERT(get_jenv_res == JNI_OK);
11707         }
11708         LDKWatchedOutput output_var = output;
11709         int64_t output_ref = 0;
11710         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
11711         output_ref = tag_ptr(output_var.inner, output_var.is_owned);
11712         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11713         CHECK(obj != NULL);
11714         (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, output_ref);
11715         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11716                 (*env)->ExceptionDescribe(env);
11717                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
11718         }
11719         if (get_jenv_res == JNI_EDETACHED) {
11720                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11721         }
11722 }
11723 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
11724         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
11725         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11726 }
11727 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
11728         jclass c = (*env)->GetObjectClass(env, o);
11729         CHECK(c != NULL);
11730         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
11731         atomic_init(&calls->refcnt, 1);
11732         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11733         calls->o = (*env)->NewWeakGlobalRef(env, o);
11734         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
11735         CHECK(calls->register_tx_meth != NULL);
11736         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)V");
11737         CHECK(calls->register_output_meth != NULL);
11738
11739         LDKFilter ret = {
11740                 .this_arg = (void*) calls,
11741                 .register_tx = register_tx_LDKFilter_jcall,
11742                 .register_output = register_output_LDKFilter_jcall,
11743                 .free = LDKFilter_JCalls_free,
11744         };
11745         return ret;
11746 }
11747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
11748         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
11749         *res_ptr = LDKFilter_init(env, clz, o);
11750         return tag_ptr(res_ptr, true);
11751 }
11752 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) {
11753         void* this_arg_ptr = untag_ptr(this_arg);
11754         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11755         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
11756         uint8_t txid_arr[32];
11757         CHECK((*env)->GetArrayLength(env, txid) == 32);
11758         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11759         uint8_t (*txid_ref)[32] = &txid_arr;
11760         LDKu8slice script_pubkey_ref;
11761         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
11762         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
11763         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
11764         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
11765 }
11766
11767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
11768         void* this_arg_ptr = untag_ptr(this_arg);
11769         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11770         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
11771         LDKWatchedOutput output_conv;
11772         output_conv.inner = untag_ptr(output);
11773         output_conv.is_owned = ptr_is_owned(output);
11774         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
11775         output_conv = WatchedOutput_clone(&output_conv);
11776         (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
11777 }
11778
11779 static jclass LDKCOption_FilterZ_Some_class = NULL;
11780 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
11781 static jclass LDKCOption_FilterZ_None_class = NULL;
11782 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
11783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
11784         LDKCOption_FilterZ_Some_class =
11785                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
11786         CHECK(LDKCOption_FilterZ_Some_class != NULL);
11787         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
11788         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
11789         LDKCOption_FilterZ_None_class =
11790                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
11791         CHECK(LDKCOption_FilterZ_None_class != NULL);
11792         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
11793         CHECK(LDKCOption_FilterZ_None_meth != NULL);
11794 }
11795 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
11796         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
11797         switch(obj->tag) {
11798                 case LDKCOption_FilterZ_Some: {
11799                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
11800                         *some_ret = obj->some;
11801                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
11802                         if ((*some_ret).free == LDKFilter_JCalls_free) {
11803                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11804                                 LDKFilter_JCalls_cloned(&(*some_ret));
11805                         }
11806                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, tag_ptr(some_ret, true));
11807                 }
11808                 case LDKCOption_FilterZ_None: {
11809                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
11810                 }
11811                 default: abort();
11812         }
11813 }
11814 static inline struct LDKLockedChannelMonitor CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
11815         LDKLockedChannelMonitor ret = *owner->contents.result;
11816         ret.is_owned = false;
11817         return ret;
11818 }
11819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11820         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
11821         LDKLockedChannelMonitor ret_var = CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
11822         int64_t ret_ref = 0;
11823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11824         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11825         return ret_ref;
11826 }
11827
11828 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
11829 CHECK(!owner->result_ok);
11830         return *owner->contents.err;
11831 }
11832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11833         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
11834         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
11835 }
11836
11837 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
11838         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
11839         for (size_t i = 0; i < ret.datalen; i++) {
11840                 ret.data[i] = OutPoint_clone(&orig->data[i]);
11841         }
11842         return ret;
11843 }
11844 static inline LDKCVec_MonitorUpdateIdZ CVec_MonitorUpdateIdZ_clone(const LDKCVec_MonitorUpdateIdZ *orig) {
11845         LDKCVec_MonitorUpdateIdZ ret = { .data = MALLOC(sizeof(LDKMonitorUpdateId) * orig->datalen, "LDKCVec_MonitorUpdateIdZ clone bytes"), .datalen = orig->datalen };
11846         for (size_t i = 0; i < ret.datalen; i++) {
11847                 ret.data[i] = MonitorUpdateId_clone(&orig->data[i]);
11848         }
11849         return ret;
11850 }
11851 static inline struct LDKOutPoint C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
11852         LDKOutPoint ret = owner->a;
11853         ret.is_owned = false;
11854         return ret;
11855 }
11856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
11857         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
11858         LDKOutPoint ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(owner_conv);
11859         int64_t ret_ref = 0;
11860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11861         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11862         return ret_ref;
11863 }
11864
11865 static inline struct LDKCVec_MonitorUpdateIdZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
11866         return CVec_MonitorUpdateIdZ_clone(&owner->b);
11867 }
11868 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
11869         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
11870         LDKCVec_MonitorUpdateIdZ ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(owner_conv);
11871         int64_tArray ret_arr = NULL;
11872         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11873         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11874         for (size_t r = 0; r < ret_var.datalen; r++) {
11875                 LDKMonitorUpdateId ret_conv_17_var = ret_var.data[r];
11876                 int64_t ret_conv_17_ref = 0;
11877                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_17_var);
11878                 ret_conv_17_ref = tag_ptr(ret_conv_17_var.inner, ret_conv_17_var.is_owned);
11879                 ret_arr_ptr[r] = ret_conv_17_ref;
11880         }
11881         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11882         FREE(ret_var.data);
11883         return ret_arr;
11884 }
11885
11886 static inline LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_clone(const LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ *orig) {
11887         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ) * orig->datalen, "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ clone bytes"), .datalen = orig->datalen };
11888         for (size_t i = 0; i < ret.datalen; i++) {
11889                 ret.data[i] = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(&orig->data[i]);
11890         }
11891         return ret;
11892 }
11893 static jclass LDKGraphSyncError_DecodeError_class = NULL;
11894 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
11895 static jclass LDKGraphSyncError_LightningError_class = NULL;
11896 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
11897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
11898         LDKGraphSyncError_DecodeError_class =
11899                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
11900         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
11901         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
11902         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
11903         LDKGraphSyncError_LightningError_class =
11904                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
11905         CHECK(LDKGraphSyncError_LightningError_class != NULL);
11906         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
11907         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
11908 }
11909 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
11910         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
11911         switch(obj->tag) {
11912                 case LDKGraphSyncError_DecodeError: {
11913                         int64_t decode_error_ref = tag_ptr(&obj->decode_error, false);
11914                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
11915                 }
11916                 case LDKGraphSyncError_LightningError: {
11917                         LDKLightningError lightning_error_var = obj->lightning_error;
11918                         int64_t lightning_error_ref = 0;
11919                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
11920                         lightning_error_ref = tag_ptr(lightning_error_var.inner, false);
11921                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
11922                 }
11923                 default: abort();
11924         }
11925 }
11926 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
11927 CHECK(owner->result_ok);
11928         return *owner->contents.result;
11929 }
11930 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
11931         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
11932         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
11933         return ret_conv;
11934 }
11935
11936 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
11937 CHECK(!owner->result_ok);
11938         return GraphSyncError_clone(&*owner->contents.err);
11939 }
11940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
11941         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
11942         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
11943         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
11944         int64_t ret_ref = tag_ptr(ret_copy, true);
11945         return ret_ref;
11946 }
11947
11948 typedef struct LDKPersister_JCalls {
11949         atomic_size_t refcnt;
11950         JavaVM *vm;
11951         jweak o;
11952         jmethodID persist_manager_meth;
11953         jmethodID persist_graph_meth;
11954         jmethodID persist_scorer_meth;
11955 } LDKPersister_JCalls;
11956 static void LDKPersister_JCalls_free(void* this_arg) {
11957         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11958         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11959                 JNIEnv *env;
11960                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11961                 if (get_jenv_res == JNI_EDETACHED) {
11962                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11963                 } else {
11964                         DO_ASSERT(get_jenv_res == JNI_OK);
11965                 }
11966                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11967                 if (get_jenv_res == JNI_EDETACHED) {
11968                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11969                 }
11970                 FREE(j_calls);
11971         }
11972 }
11973 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
11974         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11975         JNIEnv *env;
11976         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11977         if (get_jenv_res == JNI_EDETACHED) {
11978                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11979         } else {
11980                 DO_ASSERT(get_jenv_res == JNI_OK);
11981         }
11982         LDKChannelManager channel_manager_var = *channel_manager;
11983         int64_t channel_manager_ref = 0;
11984         // WARNING: we may need a move here but no clone is available for LDKChannelManager
11985         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
11986         channel_manager_ref = tag_ptr(channel_manager_var.inner, channel_manager_var.is_owned);
11987         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11988         CHECK(obj != NULL);
11989         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
11990         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11991                 (*env)->ExceptionDescribe(env);
11992                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
11993         }
11994         void* ret_ptr = untag_ptr(ret);
11995         CHECK_ACCESS(ret_ptr);
11996         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11997         FREE(untag_ptr(ret));
11998         if (get_jenv_res == JNI_EDETACHED) {
11999                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12000         }
12001         return ret_conv;
12002 }
12003 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
12004         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12005         JNIEnv *env;
12006         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12007         if (get_jenv_res == JNI_EDETACHED) {
12008                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12009         } else {
12010                 DO_ASSERT(get_jenv_res == JNI_OK);
12011         }
12012         LDKNetworkGraph network_graph_var = *network_graph;
12013         int64_t network_graph_ref = 0;
12014         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
12015         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
12016         network_graph_ref = tag_ptr(network_graph_var.inner, network_graph_var.is_owned);
12017         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12018         CHECK(obj != NULL);
12019         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
12020         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12021                 (*env)->ExceptionDescribe(env);
12022                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
12023         }
12024         void* ret_ptr = untag_ptr(ret);
12025         CHECK_ACCESS(ret_ptr);
12026         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
12027         FREE(untag_ptr(ret));
12028         if (get_jenv_res == JNI_EDETACHED) {
12029                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12030         }
12031         return ret_conv;
12032 }
12033 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKWriteableScore * scorer) {
12034         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12035         JNIEnv *env;
12036         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12037         if (get_jenv_res == JNI_EDETACHED) {
12038                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12039         } else {
12040                 DO_ASSERT(get_jenv_res == JNI_OK);
12041         }
12042         // WARNING: This object doesn't live past this scope, needs clone!
12043         int64_t ret_scorer = tag_ptr(scorer, false);
12044         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12045         CHECK(obj != NULL);
12046         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, ret_scorer);
12047         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12048                 (*env)->ExceptionDescribe(env);
12049                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
12050         }
12051         void* ret_ptr = untag_ptr(ret);
12052         CHECK_ACCESS(ret_ptr);
12053         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
12054         FREE(untag_ptr(ret));
12055         if (get_jenv_res == JNI_EDETACHED) {
12056                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12057         }
12058         return ret_conv;
12059 }
12060 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
12061         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
12062         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12063 }
12064 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
12065         jclass c = (*env)->GetObjectClass(env, o);
12066         CHECK(c != NULL);
12067         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
12068         atomic_init(&calls->refcnt, 1);
12069         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12070         calls->o = (*env)->NewWeakGlobalRef(env, o);
12071         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
12072         CHECK(calls->persist_manager_meth != NULL);
12073         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
12074         CHECK(calls->persist_graph_meth != NULL);
12075         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
12076         CHECK(calls->persist_scorer_meth != NULL);
12077
12078         LDKPersister ret = {
12079                 .this_arg = (void*) calls,
12080                 .persist_manager = persist_manager_LDKPersister_jcall,
12081                 .persist_graph = persist_graph_LDKPersister_jcall,
12082                 .persist_scorer = persist_scorer_LDKPersister_jcall,
12083                 .free = LDKPersister_JCalls_free,
12084         };
12085         return ret;
12086 }
12087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
12088         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
12089         *res_ptr = LDKPersister_init(env, clz, o);
12090         return tag_ptr(res_ptr, true);
12091 }
12092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
12093         void* this_arg_ptr = untag_ptr(this_arg);
12094         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12095         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12096         LDKChannelManager channel_manager_conv;
12097         channel_manager_conv.inner = untag_ptr(channel_manager);
12098         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
12099         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
12100         channel_manager_conv.is_owned = false;
12101         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12102         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
12103         return tag_ptr(ret_conv, true);
12104 }
12105
12106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
12107         void* this_arg_ptr = untag_ptr(this_arg);
12108         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12109         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12110         LDKNetworkGraph network_graph_conv;
12111         network_graph_conv.inner = untag_ptr(network_graph);
12112         network_graph_conv.is_owned = ptr_is_owned(network_graph);
12113         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
12114         network_graph_conv.is_owned = false;
12115         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12116         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
12117         return tag_ptr(ret_conv, true);
12118 }
12119
12120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
12121         void* this_arg_ptr = untag_ptr(this_arg);
12122         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12123         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12124         void* scorer_ptr = untag_ptr(scorer);
12125         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
12126         LDKWriteableScore* scorer_conv = (LDKWriteableScore*)scorer_ptr;
12127         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12128         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, scorer_conv);
12129         return tag_ptr(ret_conv, true);
12130 }
12131
12132 typedef struct LDKFutureCallback_JCalls {
12133         atomic_size_t refcnt;
12134         JavaVM *vm;
12135         jweak o;
12136         jmethodID call_meth;
12137 } LDKFutureCallback_JCalls;
12138 static void LDKFutureCallback_JCalls_free(void* this_arg) {
12139         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
12140         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12141                 JNIEnv *env;
12142                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12143                 if (get_jenv_res == JNI_EDETACHED) {
12144                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12145                 } else {
12146                         DO_ASSERT(get_jenv_res == JNI_OK);
12147                 }
12148                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12149                 if (get_jenv_res == JNI_EDETACHED) {
12150                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12151                 }
12152                 FREE(j_calls);
12153         }
12154 }
12155 void call_LDKFutureCallback_jcall(const void* this_arg) {
12156         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
12157         JNIEnv *env;
12158         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12159         if (get_jenv_res == JNI_EDETACHED) {
12160                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12161         } else {
12162                 DO_ASSERT(get_jenv_res == JNI_OK);
12163         }
12164         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12165         CHECK(obj != NULL);
12166         (*env)->CallVoidMethod(env, obj, j_calls->call_meth);
12167         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12168                 (*env)->ExceptionDescribe(env);
12169                 (*env)->FatalError(env, "A call to call in LDKFutureCallback from rust threw an exception.");
12170         }
12171         if (get_jenv_res == JNI_EDETACHED) {
12172                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12173         }
12174 }
12175 static void LDKFutureCallback_JCalls_cloned(LDKFutureCallback* new_obj) {
12176         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) new_obj->this_arg;
12177         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12178 }
12179 static inline LDKFutureCallback LDKFutureCallback_init (JNIEnv *env, jclass clz, jobject o) {
12180         jclass c = (*env)->GetObjectClass(env, o);
12181         CHECK(c != NULL);
12182         LDKFutureCallback_JCalls *calls = MALLOC(sizeof(LDKFutureCallback_JCalls), "LDKFutureCallback_JCalls");
12183         atomic_init(&calls->refcnt, 1);
12184         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12185         calls->o = (*env)->NewWeakGlobalRef(env, o);
12186         calls->call_meth = (*env)->GetMethodID(env, c, "call", "()V");
12187         CHECK(calls->call_meth != NULL);
12188
12189         LDKFutureCallback ret = {
12190                 .this_arg = (void*) calls,
12191                 .call = call_LDKFutureCallback_jcall,
12192                 .free = LDKFutureCallback_JCalls_free,
12193         };
12194         return ret;
12195 }
12196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFutureCallback_1new(JNIEnv *env, jclass clz, jobject o) {
12197         LDKFutureCallback *res_ptr = MALLOC(sizeof(LDKFutureCallback), "LDKFutureCallback");
12198         *res_ptr = LDKFutureCallback_init(env, clz, o);
12199         return tag_ptr(res_ptr, true);
12200 }
12201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1call(JNIEnv *env, jclass clz, int64_t this_arg) {
12202         void* this_arg_ptr = untag_ptr(this_arg);
12203         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12204         LDKFutureCallback* this_arg_conv = (LDKFutureCallback*)this_arg_ptr;
12205         (this_arg_conv->call)(this_arg_conv->this_arg);
12206 }
12207
12208 typedef struct LDKListen_JCalls {
12209         atomic_size_t refcnt;
12210         JavaVM *vm;
12211         jweak o;
12212         jmethodID filtered_block_connected_meth;
12213         jmethodID block_connected_meth;
12214         jmethodID block_disconnected_meth;
12215 } LDKListen_JCalls;
12216 static void LDKListen_JCalls_free(void* this_arg) {
12217         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12218         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12219                 JNIEnv *env;
12220                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12221                 if (get_jenv_res == JNI_EDETACHED) {
12222                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12223                 } else {
12224                         DO_ASSERT(get_jenv_res == JNI_OK);
12225                 }
12226                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12227                 if (get_jenv_res == JNI_EDETACHED) {
12228                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12229                 }
12230                 FREE(j_calls);
12231         }
12232 }
12233 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
12234         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12235         JNIEnv *env;
12236         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12237         if (get_jenv_res == JNI_EDETACHED) {
12238                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12239         } else {
12240                 DO_ASSERT(get_jenv_res == JNI_OK);
12241         }
12242         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
12243         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
12244         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
12245         int64_tArray txdata_arr = NULL;
12246         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
12247         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
12248         for (size_t c = 0; c < txdata_var.datalen; c++) {
12249                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12250                 *txdata_conv_28_conv = txdata_var.data[c];
12251                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
12252         }
12253         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
12254         FREE(txdata_var.data);
12255         int32_t height_conv = height;
12256         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12257         CHECK(obj != NULL);
12258         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
12259         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12260                 (*env)->ExceptionDescribe(env);
12261                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
12262         }
12263         if (get_jenv_res == JNI_EDETACHED) {
12264                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12265         }
12266 }
12267 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
12268         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12269         JNIEnv *env;
12270         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12271         if (get_jenv_res == JNI_EDETACHED) {
12272                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12273         } else {
12274                 DO_ASSERT(get_jenv_res == JNI_OK);
12275         }
12276         LDKu8slice block_var = block;
12277         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
12278         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
12279         int32_t height_conv = height;
12280         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12281         CHECK(obj != NULL);
12282         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
12283         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12284                 (*env)->ExceptionDescribe(env);
12285                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
12286         }
12287         if (get_jenv_res == JNI_EDETACHED) {
12288                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12289         }
12290 }
12291 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
12292         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12293         JNIEnv *env;
12294         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12295         if (get_jenv_res == JNI_EDETACHED) {
12296                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12297         } else {
12298                 DO_ASSERT(get_jenv_res == JNI_OK);
12299         }
12300         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
12301         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
12302         int32_t height_conv = height;
12303         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12304         CHECK(obj != NULL);
12305         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
12306         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12307                 (*env)->ExceptionDescribe(env);
12308                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
12309         }
12310         if (get_jenv_res == JNI_EDETACHED) {
12311                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12312         }
12313 }
12314 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
12315         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
12316         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12317 }
12318 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
12319         jclass c = (*env)->GetObjectClass(env, o);
12320         CHECK(c != NULL);
12321         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
12322         atomic_init(&calls->refcnt, 1);
12323         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12324         calls->o = (*env)->NewWeakGlobalRef(env, o);
12325         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
12326         CHECK(calls->filtered_block_connected_meth != NULL);
12327         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
12328         CHECK(calls->block_connected_meth != NULL);
12329         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
12330         CHECK(calls->block_disconnected_meth != NULL);
12331
12332         LDKListen ret = {
12333                 .this_arg = (void*) calls,
12334                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
12335                 .block_connected = block_connected_LDKListen_jcall,
12336                 .block_disconnected = block_disconnected_LDKListen_jcall,
12337                 .free = LDKListen_JCalls_free,
12338         };
12339         return ret;
12340 }
12341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
12342         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
12343         *res_ptr = LDKListen_init(env, clz, o);
12344         return tag_ptr(res_ptr, true);
12345 }
12346 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) {
12347         void* this_arg_ptr = untag_ptr(this_arg);
12348         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12349         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12350         uint8_t header_arr[80];
12351         CHECK((*env)->GetArrayLength(env, header) == 80);
12352         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12353         uint8_t (*header_ref)[80] = &header_arr;
12354         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12355         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
12356         if (txdata_constr.datalen > 0)
12357                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12358         else
12359                 txdata_constr.data = NULL;
12360         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
12361         for (size_t c = 0; c < txdata_constr.datalen; c++) {
12362                 int64_t txdata_conv_28 = txdata_vals[c];
12363                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
12364                 CHECK_ACCESS(txdata_conv_28_ptr);
12365                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
12366                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
12367                 txdata_constr.data[c] = txdata_conv_28_conv;
12368         }
12369         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
12370         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
12371 }
12372
12373 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) {
12374         void* this_arg_ptr = untag_ptr(this_arg);
12375         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12376         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12377         LDKu8slice block_ref;
12378         block_ref.datalen = (*env)->GetArrayLength(env, block);
12379         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
12380         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
12381         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
12382 }
12383
12384 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) {
12385         void* this_arg_ptr = untag_ptr(this_arg);
12386         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12387         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12388         uint8_t header_arr[80];
12389         CHECK((*env)->GetArrayLength(env, header) == 80);
12390         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12391         uint8_t (*header_ref)[80] = &header_arr;
12392         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
12393 }
12394
12395 typedef struct LDKConfirm_JCalls {
12396         atomic_size_t refcnt;
12397         JavaVM *vm;
12398         jweak o;
12399         jmethodID transactions_confirmed_meth;
12400         jmethodID transaction_unconfirmed_meth;
12401         jmethodID best_block_updated_meth;
12402         jmethodID get_relevant_txids_meth;
12403 } LDKConfirm_JCalls;
12404 static void LDKConfirm_JCalls_free(void* this_arg) {
12405         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12406         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12415                 if (get_jenv_res == JNI_EDETACHED) {
12416                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12417                 }
12418                 FREE(j_calls);
12419         }
12420 }
12421 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
12422         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12423         JNIEnv *env;
12424         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12425         if (get_jenv_res == JNI_EDETACHED) {
12426                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12427         } else {
12428                 DO_ASSERT(get_jenv_res == JNI_OK);
12429         }
12430         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
12431         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
12432         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
12433         int64_tArray txdata_arr = NULL;
12434         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
12435         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
12436         for (size_t c = 0; c < txdata_var.datalen; c++) {
12437                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12438                 *txdata_conv_28_conv = txdata_var.data[c];
12439                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
12440         }
12441         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
12442         FREE(txdata_var.data);
12443         int32_t height_conv = height;
12444         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12445         CHECK(obj != NULL);
12446         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
12447         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12448                 (*env)->ExceptionDescribe(env);
12449                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
12450         }
12451         if (get_jenv_res == JNI_EDETACHED) {
12452                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12453         }
12454 }
12455 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
12456         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12457         JNIEnv *env;
12458         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12459         if (get_jenv_res == JNI_EDETACHED) {
12460                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12461         } else {
12462                 DO_ASSERT(get_jenv_res == JNI_OK);
12463         }
12464         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
12465         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
12466         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12467         CHECK(obj != NULL);
12468         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
12469         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12470                 (*env)->ExceptionDescribe(env);
12471                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
12472         }
12473         if (get_jenv_res == JNI_EDETACHED) {
12474                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12475         }
12476 }
12477 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
12478         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12479         JNIEnv *env;
12480         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12481         if (get_jenv_res == JNI_EDETACHED) {
12482                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12483         } else {
12484                 DO_ASSERT(get_jenv_res == JNI_OK);
12485         }
12486         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
12487         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
12488         int32_t height_conv = height;
12489         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12490         CHECK(obj != NULL);
12491         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
12492         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12493                 (*env)->ExceptionDescribe(env);
12494                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
12495         }
12496         if (get_jenv_res == JNI_EDETACHED) {
12497                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12498         }
12499 }
12500 LDKCVec_C2Tuple_TxidBlockHashZZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
12501         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12502         JNIEnv *env;
12503         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12504         if (get_jenv_res == JNI_EDETACHED) {
12505                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12506         } else {
12507                 DO_ASSERT(get_jenv_res == JNI_OK);
12508         }
12509         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12510         CHECK(obj != NULL);
12511         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
12512         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12513                 (*env)->ExceptionDescribe(env);
12514                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
12515         }
12516         LDKCVec_C2Tuple_TxidBlockHashZZ ret_constr;
12517         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12518         if (ret_constr.datalen > 0)
12519                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKCVec_C2Tuple_TxidBlockHashZZ Elements");
12520         else
12521                 ret_constr.data = NULL;
12522         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12523         for (size_t z = 0; z < ret_constr.datalen; z++) {
12524                 int64_t ret_conv_25 = ret_vals[z];
12525                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
12526                 CHECK_ACCESS(ret_conv_25_ptr);
12527                 LDKC2Tuple_TxidBlockHashZ ret_conv_25_conv = *(LDKC2Tuple_TxidBlockHashZ*)(ret_conv_25_ptr);
12528                 FREE(untag_ptr(ret_conv_25));
12529                 ret_constr.data[z] = ret_conv_25_conv;
12530         }
12531         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12532         if (get_jenv_res == JNI_EDETACHED) {
12533                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12534         }
12535         return ret_constr;
12536 }
12537 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
12538         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
12539         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12540 }
12541 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
12542         jclass c = (*env)->GetObjectClass(env, o);
12543         CHECK(c != NULL);
12544         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
12545         atomic_init(&calls->refcnt, 1);
12546         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12547         calls->o = (*env)->NewWeakGlobalRef(env, o);
12548         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
12549         CHECK(calls->transactions_confirmed_meth != NULL);
12550         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
12551         CHECK(calls->transaction_unconfirmed_meth != NULL);
12552         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
12553         CHECK(calls->best_block_updated_meth != NULL);
12554         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[J");
12555         CHECK(calls->get_relevant_txids_meth != NULL);
12556
12557         LDKConfirm ret = {
12558                 .this_arg = (void*) calls,
12559                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
12560                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
12561                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
12562                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
12563                 .free = LDKConfirm_JCalls_free,
12564         };
12565         return ret;
12566 }
12567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
12568         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
12569         *res_ptr = LDKConfirm_init(env, clz, o);
12570         return tag_ptr(res_ptr, true);
12571 }
12572 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) {
12573         void* this_arg_ptr = untag_ptr(this_arg);
12574         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12575         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12576         uint8_t header_arr[80];
12577         CHECK((*env)->GetArrayLength(env, header) == 80);
12578         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12579         uint8_t (*header_ref)[80] = &header_arr;
12580         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12581         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
12582         if (txdata_constr.datalen > 0)
12583                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12584         else
12585                 txdata_constr.data = NULL;
12586         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
12587         for (size_t c = 0; c < txdata_constr.datalen; c++) {
12588                 int64_t txdata_conv_28 = txdata_vals[c];
12589                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
12590                 CHECK_ACCESS(txdata_conv_28_ptr);
12591                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
12592                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
12593                 txdata_constr.data[c] = txdata_conv_28_conv;
12594         }
12595         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
12596         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
12597 }
12598
12599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
12600         void* this_arg_ptr = untag_ptr(this_arg);
12601         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12602         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12603         uint8_t txid_arr[32];
12604         CHECK((*env)->GetArrayLength(env, txid) == 32);
12605         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
12606         uint8_t (*txid_ref)[32] = &txid_arr;
12607         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
12608 }
12609
12610 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) {
12611         void* this_arg_ptr = untag_ptr(this_arg);
12612         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12613         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12614         uint8_t header_arr[80];
12615         CHECK((*env)->GetArrayLength(env, header) == 80);
12616         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
12617         uint8_t (*header_ref)[80] = &header_arr;
12618         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
12619 }
12620
12621 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
12622         void* this_arg_ptr = untag_ptr(this_arg);
12623         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12624         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12625         LDKCVec_C2Tuple_TxidBlockHashZZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
12626         int64_tArray ret_arr = NULL;
12627         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12628         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12629         for (size_t z = 0; z < ret_var.datalen; z++) {
12630                 LDKC2Tuple_TxidBlockHashZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
12631                 *ret_conv_25_conv = ret_var.data[z];
12632                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
12633         }
12634         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12635         FREE(ret_var.data);
12636         return ret_arr;
12637 }
12638
12639 typedef struct LDKPersist_JCalls {
12640         atomic_size_t refcnt;
12641         JavaVM *vm;
12642         jweak o;
12643         jmethodID persist_new_channel_meth;
12644         jmethodID update_persisted_channel_meth;
12645 } LDKPersist_JCalls;
12646 static void LDKPersist_JCalls_free(void* this_arg) {
12647         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12648         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12649                 JNIEnv *env;
12650                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12651                 if (get_jenv_res == JNI_EDETACHED) {
12652                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12653                 } else {
12654                         DO_ASSERT(get_jenv_res == JNI_OK);
12655                 }
12656                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12657                 if (get_jenv_res == JNI_EDETACHED) {
12658                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12659                 }
12660                 FREE(j_calls);
12661         }
12662 }
12663 LDKChannelMonitorUpdateStatus persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
12664         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12665         JNIEnv *env;
12666         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12667         if (get_jenv_res == JNI_EDETACHED) {
12668                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12669         } else {
12670                 DO_ASSERT(get_jenv_res == JNI_OK);
12671         }
12672         LDKOutPoint channel_id_var = channel_id;
12673         int64_t channel_id_ref = 0;
12674         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
12675         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
12676         LDKChannelMonitor data_var = *data;
12677         int64_t data_ref = 0;
12678         data_var = ChannelMonitor_clone(&data_var);
12679         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
12680         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
12681         LDKMonitorUpdateId update_id_var = update_id;
12682         int64_t update_id_ref = 0;
12683         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
12684         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
12685         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12686         CHECK(obj != NULL);
12687         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
12688         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12689                 (*env)->ExceptionDescribe(env);
12690                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
12691         }
12692         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
12693         if (get_jenv_res == JNI_EDETACHED) {
12694                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12695         }
12696         return ret_conv;
12697 }
12698 LDKChannelMonitorUpdateStatus update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, LDKChannelMonitorUpdate update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
12699         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12700         JNIEnv *env;
12701         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12702         if (get_jenv_res == JNI_EDETACHED) {
12703                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12704         } else {
12705                 DO_ASSERT(get_jenv_res == JNI_OK);
12706         }
12707         LDKOutPoint channel_id_var = channel_id;
12708         int64_t channel_id_ref = 0;
12709         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
12710         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
12711         LDKChannelMonitorUpdate update_var = update;
12712         int64_t update_ref = 0;
12713         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
12714         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
12715         LDKChannelMonitor data_var = *data;
12716         int64_t data_ref = 0;
12717         data_var = ChannelMonitor_clone(&data_var);
12718         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
12719         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
12720         LDKMonitorUpdateId update_id_var = update_id;
12721         int64_t update_id_ref = 0;
12722         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
12723         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
12724         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12725         CHECK(obj != NULL);
12726         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
12727         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12728                 (*env)->ExceptionDescribe(env);
12729                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
12730         }
12731         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
12732         if (get_jenv_res == JNI_EDETACHED) {
12733                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12734         }
12735         return ret_conv;
12736 }
12737 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
12738         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
12739         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12740 }
12741 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
12742         jclass c = (*env)->GetObjectClass(env, o);
12743         CHECK(c != NULL);
12744         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
12745         atomic_init(&calls->refcnt, 1);
12746         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12747         calls->o = (*env)->NewWeakGlobalRef(env, o);
12748         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
12749         CHECK(calls->persist_new_channel_meth != NULL);
12750         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
12751         CHECK(calls->update_persisted_channel_meth != NULL);
12752
12753         LDKPersist ret = {
12754                 .this_arg = (void*) calls,
12755                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
12756                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
12757                 .free = LDKPersist_JCalls_free,
12758         };
12759         return ret;
12760 }
12761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
12762         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
12763         *res_ptr = LDKPersist_init(env, clz, o);
12764         return tag_ptr(res_ptr, true);
12765 }
12766 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) {
12767         void* this_arg_ptr = untag_ptr(this_arg);
12768         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12769         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12770         LDKOutPoint channel_id_conv;
12771         channel_id_conv.inner = untag_ptr(channel_id);
12772         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12773         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12774         channel_id_conv = OutPoint_clone(&channel_id_conv);
12775         LDKChannelMonitor data_conv;
12776         data_conv.inner = untag_ptr(data);
12777         data_conv.is_owned = ptr_is_owned(data);
12778         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12779         data_conv.is_owned = false;
12780         LDKMonitorUpdateId update_id_conv;
12781         update_id_conv.inner = untag_ptr(update_id);
12782         update_id_conv.is_owned = ptr_is_owned(update_id);
12783         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12784         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12785         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));
12786         return ret_conv;
12787 }
12788
12789 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) {
12790         void* this_arg_ptr = untag_ptr(this_arg);
12791         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12792         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12793         LDKOutPoint channel_id_conv;
12794         channel_id_conv.inner = untag_ptr(channel_id);
12795         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12796         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12797         channel_id_conv = OutPoint_clone(&channel_id_conv);
12798         LDKChannelMonitorUpdate update_conv;
12799         update_conv.inner = untag_ptr(update);
12800         update_conv.is_owned = ptr_is_owned(update);
12801         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
12802         update_conv = ChannelMonitorUpdate_clone(&update_conv);
12803         LDKChannelMonitor data_conv;
12804         data_conv.inner = untag_ptr(data);
12805         data_conv.is_owned = ptr_is_owned(data);
12806         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12807         data_conv.is_owned = false;
12808         LDKMonitorUpdateId update_id_conv;
12809         update_id_conv.inner = untag_ptr(update_id);
12810         update_id_conv.is_owned = ptr_is_owned(update_id);
12811         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12812         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12813         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));
12814         return ret_conv;
12815 }
12816
12817 typedef struct LDKEventHandler_JCalls {
12818         atomic_size_t refcnt;
12819         JavaVM *vm;
12820         jweak o;
12821         jmethodID handle_event_meth;
12822 } LDKEventHandler_JCalls;
12823 static void LDKEventHandler_JCalls_free(void* this_arg) {
12824         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
12825         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12826                 JNIEnv *env;
12827                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12828                 if (get_jenv_res == JNI_EDETACHED) {
12829                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12830                 } else {
12831                         DO_ASSERT(get_jenv_res == JNI_OK);
12832                 }
12833                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12834                 if (get_jenv_res == JNI_EDETACHED) {
12835                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12836                 }
12837                 FREE(j_calls);
12838         }
12839 }
12840 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
12841         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
12842         JNIEnv *env;
12843         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12844         if (get_jenv_res == JNI_EDETACHED) {
12845                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12846         } else {
12847                 DO_ASSERT(get_jenv_res == JNI_OK);
12848         }
12849         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12850         *event_copy = event;
12851         int64_t event_ref = tag_ptr(event_copy, true);
12852         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12853         CHECK(obj != NULL);
12854         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
12855         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12856                 (*env)->ExceptionDescribe(env);
12857                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
12858         }
12859         if (get_jenv_res == JNI_EDETACHED) {
12860                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12861         }
12862 }
12863 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
12864         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
12865         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12866 }
12867 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
12868         jclass c = (*env)->GetObjectClass(env, o);
12869         CHECK(c != NULL);
12870         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
12871         atomic_init(&calls->refcnt, 1);
12872         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12873         calls->o = (*env)->NewWeakGlobalRef(env, o);
12874         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
12875         CHECK(calls->handle_event_meth != NULL);
12876
12877         LDKEventHandler ret = {
12878                 .this_arg = (void*) calls,
12879                 .handle_event = handle_event_LDKEventHandler_jcall,
12880                 .free = LDKEventHandler_JCalls_free,
12881         };
12882         return ret;
12883 }
12884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
12885         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
12886         *res_ptr = LDKEventHandler_init(env, clz, o);
12887         return tag_ptr(res_ptr, true);
12888 }
12889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
12890         void* this_arg_ptr = untag_ptr(this_arg);
12891         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12892         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
12893         void* event_ptr = untag_ptr(event);
12894         CHECK_ACCESS(event_ptr);
12895         LDKEvent event_conv = *(LDKEvent*)(event_ptr);
12896         event_conv = Event_clone((LDKEvent*)untag_ptr(event));
12897         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
12898 }
12899
12900 typedef struct LDKEventsProvider_JCalls {
12901         atomic_size_t refcnt;
12902         JavaVM *vm;
12903         jweak o;
12904         jmethodID process_pending_events_meth;
12905 } LDKEventsProvider_JCalls;
12906 static void LDKEventsProvider_JCalls_free(void* this_arg) {
12907         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
12908         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12909                 JNIEnv *env;
12910                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12911                 if (get_jenv_res == JNI_EDETACHED) {
12912                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12913                 } else {
12914                         DO_ASSERT(get_jenv_res == JNI_OK);
12915                 }
12916                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12917                 if (get_jenv_res == JNI_EDETACHED) {
12918                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12919                 }
12920                 FREE(j_calls);
12921         }
12922 }
12923 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
12924         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
12925         JNIEnv *env;
12926         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12927         if (get_jenv_res == JNI_EDETACHED) {
12928                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12929         } else {
12930                 DO_ASSERT(get_jenv_res == JNI_OK);
12931         }
12932         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
12933         *handler_ret = handler;
12934         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12935         CHECK(obj != NULL);
12936         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, tag_ptr(handler_ret, true));
12937         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12938                 (*env)->ExceptionDescribe(env);
12939                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
12940         }
12941         if (get_jenv_res == JNI_EDETACHED) {
12942                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12943         }
12944 }
12945 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
12946         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
12947         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12948 }
12949 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
12950         jclass c = (*env)->GetObjectClass(env, o);
12951         CHECK(c != NULL);
12952         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
12953         atomic_init(&calls->refcnt, 1);
12954         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12955         calls->o = (*env)->NewWeakGlobalRef(env, o);
12956         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
12957         CHECK(calls->process_pending_events_meth != NULL);
12958
12959         LDKEventsProvider ret = {
12960                 .this_arg = (void*) calls,
12961                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
12962                 .free = LDKEventsProvider_JCalls_free,
12963         };
12964         return ret;
12965 }
12966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
12967         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
12968         *res_ptr = LDKEventsProvider_init(env, clz, o);
12969         return tag_ptr(res_ptr, true);
12970 }
12971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
12972         void* this_arg_ptr = untag_ptr(this_arg);
12973         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12974         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
12975         void* handler_ptr = untag_ptr(handler);
12976         CHECK_ACCESS(handler_ptr);
12977         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
12978         if (handler_conv.free == LDKEventHandler_JCalls_free) {
12979                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12980                 LDKEventHandler_JCalls_cloned(&handler_conv);
12981         }
12982         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
12983 }
12984
12985 static jclass LDKRetry_Attempts_class = NULL;
12986 static jmethodID LDKRetry_Attempts_meth = NULL;
12987 static jclass LDKRetry_Timeout_class = NULL;
12988 static jmethodID LDKRetry_Timeout_meth = NULL;
12989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
12990         LDKRetry_Attempts_class =
12991                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
12992         CHECK(LDKRetry_Attempts_class != NULL);
12993         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
12994         CHECK(LDKRetry_Attempts_meth != NULL);
12995         LDKRetry_Timeout_class =
12996                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
12997         CHECK(LDKRetry_Timeout_class != NULL);
12998         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
12999         CHECK(LDKRetry_Timeout_meth != NULL);
13000 }
13001 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13002         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
13003         switch(obj->tag) {
13004                 case LDKRetry_Attempts: {
13005                         int64_t attempts_conv = obj->attempts;
13006                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
13007                 }
13008                 case LDKRetry_Timeout: {
13009                         int64_t timeout_conv = obj->timeout;
13010                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
13011                 }
13012                 default: abort();
13013         }
13014 }
13015 typedef struct LDKMessageSendEventsProvider_JCalls {
13016         atomic_size_t refcnt;
13017         JavaVM *vm;
13018         jweak o;
13019         jmethodID get_and_clear_pending_msg_events_meth;
13020 } LDKMessageSendEventsProvider_JCalls;
13021 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
13022         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
13023         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13024                 JNIEnv *env;
13025                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13026                 if (get_jenv_res == JNI_EDETACHED) {
13027                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13028                 } else {
13029                         DO_ASSERT(get_jenv_res == JNI_OK);
13030                 }
13031                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13032                 if (get_jenv_res == JNI_EDETACHED) {
13033                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13034                 }
13035                 FREE(j_calls);
13036         }
13037 }
13038 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
13039         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
13040         JNIEnv *env;
13041         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13042         if (get_jenv_res == JNI_EDETACHED) {
13043                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13044         } else {
13045                 DO_ASSERT(get_jenv_res == JNI_OK);
13046         }
13047         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13048         CHECK(obj != NULL);
13049         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
13050         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13051                 (*env)->ExceptionDescribe(env);
13052                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
13053         }
13054         LDKCVec_MessageSendEventZ ret_constr;
13055         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13056         if (ret_constr.datalen > 0)
13057                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
13058         else
13059                 ret_constr.data = NULL;
13060         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13061         for (size_t s = 0; s < ret_constr.datalen; s++) {
13062                 int64_t ret_conv_18 = ret_vals[s];
13063                 void* ret_conv_18_ptr = untag_ptr(ret_conv_18);
13064                 CHECK_ACCESS(ret_conv_18_ptr);
13065                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
13066                 FREE(untag_ptr(ret_conv_18));
13067                 ret_constr.data[s] = ret_conv_18_conv;
13068         }
13069         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13070         if (get_jenv_res == JNI_EDETACHED) {
13071                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13072         }
13073         return ret_constr;
13074 }
13075 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
13076         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
13077         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13078 }
13079 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
13080         jclass c = (*env)->GetObjectClass(env, o);
13081         CHECK(c != NULL);
13082         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
13083         atomic_init(&calls->refcnt, 1);
13084         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13085         calls->o = (*env)->NewWeakGlobalRef(env, o);
13086         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
13087         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
13088
13089         LDKMessageSendEventsProvider ret = {
13090                 .this_arg = (void*) calls,
13091                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
13092                 .free = LDKMessageSendEventsProvider_JCalls_free,
13093         };
13094         return ret;
13095 }
13096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
13097         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
13098         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
13099         return tag_ptr(res_ptr, true);
13100 }
13101 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
13102         void* this_arg_ptr = untag_ptr(this_arg);
13103         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13104         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
13105         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
13106         int64_tArray ret_arr = NULL;
13107         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13108         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13109         for (size_t s = 0; s < ret_var.datalen; s++) {
13110                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13111                 *ret_conv_18_copy = ret_var.data[s];
13112                 int64_t ret_conv_18_ref = tag_ptr(ret_conv_18_copy, true);
13113                 ret_arr_ptr[s] = ret_conv_18_ref;
13114         }
13115         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13116         FREE(ret_var.data);
13117         return ret_arr;
13118 }
13119
13120 typedef struct LDKChannelMessageHandler_JCalls {
13121         atomic_size_t refcnt;
13122         JavaVM *vm;
13123         jweak o;
13124         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
13125         jmethodID handle_open_channel_meth;
13126         jmethodID handle_accept_channel_meth;
13127         jmethodID handle_funding_created_meth;
13128         jmethodID handle_funding_signed_meth;
13129         jmethodID handle_channel_ready_meth;
13130         jmethodID handle_shutdown_meth;
13131         jmethodID handle_closing_signed_meth;
13132         jmethodID handle_update_add_htlc_meth;
13133         jmethodID handle_update_fulfill_htlc_meth;
13134         jmethodID handle_update_fail_htlc_meth;
13135         jmethodID handle_update_fail_malformed_htlc_meth;
13136         jmethodID handle_commitment_signed_meth;
13137         jmethodID handle_revoke_and_ack_meth;
13138         jmethodID handle_update_fee_meth;
13139         jmethodID handle_announcement_signatures_meth;
13140         jmethodID peer_disconnected_meth;
13141         jmethodID peer_connected_meth;
13142         jmethodID handle_channel_reestablish_meth;
13143         jmethodID handle_channel_update_meth;
13144         jmethodID handle_error_meth;
13145         jmethodID provided_node_features_meth;
13146         jmethodID provided_init_features_meth;
13147 } LDKChannelMessageHandler_JCalls;
13148 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
13149         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13150         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13151                 JNIEnv *env;
13152                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13153                 if (get_jenv_res == JNI_EDETACHED) {
13154                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13155                 } else {
13156                         DO_ASSERT(get_jenv_res == JNI_OK);
13157                 }
13158                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13159                 if (get_jenv_res == JNI_EDETACHED) {
13160                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13161                 }
13162                 FREE(j_calls);
13163         }
13164 }
13165 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKOpenChannel * msg) {
13166         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13167         JNIEnv *env;
13168         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13169         if (get_jenv_res == JNI_EDETACHED) {
13170                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13171         } else {
13172                 DO_ASSERT(get_jenv_res == JNI_OK);
13173         }
13174         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13175         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13176         LDKOpenChannel msg_var = *msg;
13177         int64_t msg_ref = 0;
13178         msg_var = OpenChannel_clone(&msg_var);
13179         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13180         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13181         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13182         CHECK(obj != NULL);
13183         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, msg_ref);
13184         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13185                 (*env)->ExceptionDescribe(env);
13186                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
13187         }
13188         if (get_jenv_res == JNI_EDETACHED) {
13189                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13190         }
13191 }
13192 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAcceptChannel * msg) {
13193         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13194         JNIEnv *env;
13195         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13196         if (get_jenv_res == JNI_EDETACHED) {
13197                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13198         } else {
13199                 DO_ASSERT(get_jenv_res == JNI_OK);
13200         }
13201         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13202         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13203         LDKAcceptChannel msg_var = *msg;
13204         int64_t msg_ref = 0;
13205         msg_var = AcceptChannel_clone(&msg_var);
13206         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13207         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13208         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13209         CHECK(obj != NULL);
13210         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, msg_ref);
13211         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13212                 (*env)->ExceptionDescribe(env);
13213                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
13214         }
13215         if (get_jenv_res == JNI_EDETACHED) {
13216                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13217         }
13218 }
13219 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
13220         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13221         JNIEnv *env;
13222         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13223         if (get_jenv_res == JNI_EDETACHED) {
13224                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13225         } else {
13226                 DO_ASSERT(get_jenv_res == JNI_OK);
13227         }
13228         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13229         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13230         LDKFundingCreated msg_var = *msg;
13231         int64_t msg_ref = 0;
13232         msg_var = FundingCreated_clone(&msg_var);
13233         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13234         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13235         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13236         CHECK(obj != NULL);
13237         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
13238         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13239                 (*env)->ExceptionDescribe(env);
13240                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
13241         }
13242         if (get_jenv_res == JNI_EDETACHED) {
13243                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13244         }
13245 }
13246 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
13247         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13248         JNIEnv *env;
13249         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13250         if (get_jenv_res == JNI_EDETACHED) {
13251                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13252         } else {
13253                 DO_ASSERT(get_jenv_res == JNI_OK);
13254         }
13255         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13256         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13257         LDKFundingSigned msg_var = *msg;
13258         int64_t msg_ref = 0;
13259         msg_var = FundingSigned_clone(&msg_var);
13260         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13261         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13262         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13263         CHECK(obj != NULL);
13264         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
13265         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13266                 (*env)->ExceptionDescribe(env);
13267                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
13268         }
13269         if (get_jenv_res == JNI_EDETACHED) {
13270                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13271         }
13272 }
13273 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
13274         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13275         JNIEnv *env;
13276         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13277         if (get_jenv_res == JNI_EDETACHED) {
13278                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13279         } else {
13280                 DO_ASSERT(get_jenv_res == JNI_OK);
13281         }
13282         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13283         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13284         LDKChannelReady msg_var = *msg;
13285         int64_t msg_ref = 0;
13286         msg_var = ChannelReady_clone(&msg_var);
13287         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13288         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13289         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13290         CHECK(obj != NULL);
13291         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
13292         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13293                 (*env)->ExceptionDescribe(env);
13294                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
13295         }
13296         if (get_jenv_res == JNI_EDETACHED) {
13297                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13298         }
13299 }
13300 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown * msg) {
13301         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13302         JNIEnv *env;
13303         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13304         if (get_jenv_res == JNI_EDETACHED) {
13305                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13306         } else {
13307                 DO_ASSERT(get_jenv_res == JNI_OK);
13308         }
13309         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13310         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13311         LDKShutdown msg_var = *msg;
13312         int64_t msg_ref = 0;
13313         msg_var = Shutdown_clone(&msg_var);
13314         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13315         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13316         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13317         CHECK(obj != NULL);
13318         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, msg_ref);
13319         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13320                 (*env)->ExceptionDescribe(env);
13321                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
13322         }
13323         if (get_jenv_res == JNI_EDETACHED) {
13324                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13325         }
13326 }
13327 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
13328         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13329         JNIEnv *env;
13330         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13331         if (get_jenv_res == JNI_EDETACHED) {
13332                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13333         } else {
13334                 DO_ASSERT(get_jenv_res == JNI_OK);
13335         }
13336         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13337         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13338         LDKClosingSigned msg_var = *msg;
13339         int64_t msg_ref = 0;
13340         msg_var = ClosingSigned_clone(&msg_var);
13341         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13342         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13343         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13344         CHECK(obj != NULL);
13345         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
13346         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13347                 (*env)->ExceptionDescribe(env);
13348                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
13349         }
13350         if (get_jenv_res == JNI_EDETACHED) {
13351                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13352         }
13353 }
13354 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
13355         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13356         JNIEnv *env;
13357         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13358         if (get_jenv_res == JNI_EDETACHED) {
13359                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13360         } else {
13361                 DO_ASSERT(get_jenv_res == JNI_OK);
13362         }
13363         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13364         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13365         LDKUpdateAddHTLC msg_var = *msg;
13366         int64_t msg_ref = 0;
13367         msg_var = UpdateAddHTLC_clone(&msg_var);
13368         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13369         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13370         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13371         CHECK(obj != NULL);
13372         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
13373         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13374                 (*env)->ExceptionDescribe(env);
13375                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
13376         }
13377         if (get_jenv_res == JNI_EDETACHED) {
13378                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13379         }
13380 }
13381 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
13382         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13383         JNIEnv *env;
13384         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13385         if (get_jenv_res == JNI_EDETACHED) {
13386                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13387         } else {
13388                 DO_ASSERT(get_jenv_res == JNI_OK);
13389         }
13390         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13391         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13392         LDKUpdateFulfillHTLC msg_var = *msg;
13393         int64_t msg_ref = 0;
13394         msg_var = UpdateFulfillHTLC_clone(&msg_var);
13395         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13396         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13397         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13398         CHECK(obj != NULL);
13399         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
13400         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13401                 (*env)->ExceptionDescribe(env);
13402                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
13403         }
13404         if (get_jenv_res == JNI_EDETACHED) {
13405                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13406         }
13407 }
13408 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
13409         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13410         JNIEnv *env;
13411         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13412         if (get_jenv_res == JNI_EDETACHED) {
13413                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13414         } else {
13415                 DO_ASSERT(get_jenv_res == JNI_OK);
13416         }
13417         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13418         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13419         LDKUpdateFailHTLC msg_var = *msg;
13420         int64_t msg_ref = 0;
13421         msg_var = UpdateFailHTLC_clone(&msg_var);
13422         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13423         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13424         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13425         CHECK(obj != NULL);
13426         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
13427         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13428                 (*env)->ExceptionDescribe(env);
13429                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
13430         }
13431         if (get_jenv_res == JNI_EDETACHED) {
13432                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13433         }
13434 }
13435 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
13436         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13437         JNIEnv *env;
13438         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13439         if (get_jenv_res == JNI_EDETACHED) {
13440                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13441         } else {
13442                 DO_ASSERT(get_jenv_res == JNI_OK);
13443         }
13444         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13445         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13446         LDKUpdateFailMalformedHTLC msg_var = *msg;
13447         int64_t msg_ref = 0;
13448         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
13449         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13450         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13451         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13452         CHECK(obj != NULL);
13453         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
13454         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13455                 (*env)->ExceptionDescribe(env);
13456                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
13457         }
13458         if (get_jenv_res == JNI_EDETACHED) {
13459                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13460         }
13461 }
13462 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
13463         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13464         JNIEnv *env;
13465         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13466         if (get_jenv_res == JNI_EDETACHED) {
13467                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13468         } else {
13469                 DO_ASSERT(get_jenv_res == JNI_OK);
13470         }
13471         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13472         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13473         LDKCommitmentSigned msg_var = *msg;
13474         int64_t msg_ref = 0;
13475         msg_var = CommitmentSigned_clone(&msg_var);
13476         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13477         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13478         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13479         CHECK(obj != NULL);
13480         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
13481         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13482                 (*env)->ExceptionDescribe(env);
13483                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
13484         }
13485         if (get_jenv_res == JNI_EDETACHED) {
13486                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13487         }
13488 }
13489 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
13490         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13491         JNIEnv *env;
13492         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13493         if (get_jenv_res == JNI_EDETACHED) {
13494                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13495         } else {
13496                 DO_ASSERT(get_jenv_res == JNI_OK);
13497         }
13498         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13499         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13500         LDKRevokeAndACK msg_var = *msg;
13501         int64_t msg_ref = 0;
13502         msg_var = RevokeAndACK_clone(&msg_var);
13503         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13504         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13505         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13506         CHECK(obj != NULL);
13507         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
13508         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13509                 (*env)->ExceptionDescribe(env);
13510                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
13511         }
13512         if (get_jenv_res == JNI_EDETACHED) {
13513                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13514         }
13515 }
13516 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
13517         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13518         JNIEnv *env;
13519         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13520         if (get_jenv_res == JNI_EDETACHED) {
13521                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13522         } else {
13523                 DO_ASSERT(get_jenv_res == JNI_OK);
13524         }
13525         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13526         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13527         LDKUpdateFee msg_var = *msg;
13528         int64_t msg_ref = 0;
13529         msg_var = UpdateFee_clone(&msg_var);
13530         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13531         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13532         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13533         CHECK(obj != NULL);
13534         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
13535         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13536                 (*env)->ExceptionDescribe(env);
13537                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
13538         }
13539         if (get_jenv_res == JNI_EDETACHED) {
13540                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13541         }
13542 }
13543 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
13544         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13545         JNIEnv *env;
13546         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13547         if (get_jenv_res == JNI_EDETACHED) {
13548                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13549         } else {
13550                 DO_ASSERT(get_jenv_res == JNI_OK);
13551         }
13552         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13553         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13554         LDKAnnouncementSignatures msg_var = *msg;
13555         int64_t msg_ref = 0;
13556         msg_var = AnnouncementSignatures_clone(&msg_var);
13557         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13558         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13559         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13560         CHECK(obj != NULL);
13561         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
13562         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13563                 (*env)->ExceptionDescribe(env);
13564                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
13565         }
13566         if (get_jenv_res == JNI_EDETACHED) {
13567                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13568         }
13569 }
13570 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13571         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13572         JNIEnv *env;
13573         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13574         if (get_jenv_res == JNI_EDETACHED) {
13575                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13576         } else {
13577                 DO_ASSERT(get_jenv_res == JNI_OK);
13578         }
13579         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13580         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13581         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13582         CHECK(obj != NULL);
13583         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr);
13584         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13585                 (*env)->ExceptionDescribe(env);
13586                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
13587         }
13588         if (get_jenv_res == JNI_EDETACHED) {
13589                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13590         }
13591 }
13592 LDKCResult_NoneNoneZ peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg, bool inbound) {
13593         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13594         JNIEnv *env;
13595         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13596         if (get_jenv_res == JNI_EDETACHED) {
13597                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13598         } else {
13599                 DO_ASSERT(get_jenv_res == JNI_OK);
13600         }
13601         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13602         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13603         LDKInit msg_var = *msg;
13604         int64_t msg_ref = 0;
13605         msg_var = Init_clone(&msg_var);
13606         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13607         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13608         jboolean inbound_conv = inbound;
13609         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13610         CHECK(obj != NULL);
13611         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref, inbound_conv);
13612         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13613                 (*env)->ExceptionDescribe(env);
13614                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
13615         }
13616         void* ret_ptr = untag_ptr(ret);
13617         CHECK_ACCESS(ret_ptr);
13618         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13619         FREE(untag_ptr(ret));
13620         if (get_jenv_res == JNI_EDETACHED) {
13621                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13622         }
13623         return ret_conv;
13624 }
13625 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
13626         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13627         JNIEnv *env;
13628         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13629         if (get_jenv_res == JNI_EDETACHED) {
13630                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13631         } else {
13632                 DO_ASSERT(get_jenv_res == JNI_OK);
13633         }
13634         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13635         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13636         LDKChannelReestablish msg_var = *msg;
13637         int64_t msg_ref = 0;
13638         msg_var = ChannelReestablish_clone(&msg_var);
13639         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13640         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13641         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13642         CHECK(obj != NULL);
13643         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
13644         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13645                 (*env)->ExceptionDescribe(env);
13646                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
13647         }
13648         if (get_jenv_res == JNI_EDETACHED) {
13649                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13650         }
13651 }
13652 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
13653         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13654         JNIEnv *env;
13655         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13656         if (get_jenv_res == JNI_EDETACHED) {
13657                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13658         } else {
13659                 DO_ASSERT(get_jenv_res == JNI_OK);
13660         }
13661         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13662         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13663         LDKChannelUpdate msg_var = *msg;
13664         int64_t msg_ref = 0;
13665         msg_var = ChannelUpdate_clone(&msg_var);
13666         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13667         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13668         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13669         CHECK(obj != NULL);
13670         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
13671         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13672                 (*env)->ExceptionDescribe(env);
13673                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
13674         }
13675         if (get_jenv_res == JNI_EDETACHED) {
13676                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13677         }
13678 }
13679 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
13680         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13681         JNIEnv *env;
13682         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13683         if (get_jenv_res == JNI_EDETACHED) {
13684                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13685         } else {
13686                 DO_ASSERT(get_jenv_res == JNI_OK);
13687         }
13688         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13689         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13690         LDKErrorMessage msg_var = *msg;
13691         int64_t msg_ref = 0;
13692         msg_var = ErrorMessage_clone(&msg_var);
13693         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13694         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13695         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13696         CHECK(obj != NULL);
13697         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
13698         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13699                 (*env)->ExceptionDescribe(env);
13700                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
13701         }
13702         if (get_jenv_res == JNI_EDETACHED) {
13703                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13704         }
13705 }
13706 LDKNodeFeatures provided_node_features_LDKChannelMessageHandler_jcall(const void* this_arg) {
13707         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13708         JNIEnv *env;
13709         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13710         if (get_jenv_res == JNI_EDETACHED) {
13711                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13712         } else {
13713                 DO_ASSERT(get_jenv_res == JNI_OK);
13714         }
13715         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13716         CHECK(obj != NULL);
13717         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
13718         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13719                 (*env)->ExceptionDescribe(env);
13720                 (*env)->FatalError(env, "A call to provided_node_features in LDKChannelMessageHandler from rust threw an exception.");
13721         }
13722         LDKNodeFeatures ret_conv;
13723         ret_conv.inner = untag_ptr(ret);
13724         ret_conv.is_owned = ptr_is_owned(ret);
13725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13726         if (get_jenv_res == JNI_EDETACHED) {
13727                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13728         }
13729         return ret_conv;
13730 }
13731 LDKInitFeatures provided_init_features_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13732         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13733         JNIEnv *env;
13734         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13735         if (get_jenv_res == JNI_EDETACHED) {
13736                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13737         } else {
13738                 DO_ASSERT(get_jenv_res == JNI_OK);
13739         }
13740         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13741         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13742         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13743         CHECK(obj != NULL);
13744         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
13745         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13746                 (*env)->ExceptionDescribe(env);
13747                 (*env)->FatalError(env, "A call to provided_init_features in LDKChannelMessageHandler from rust threw an exception.");
13748         }
13749         LDKInitFeatures ret_conv;
13750         ret_conv.inner = untag_ptr(ret);
13751         ret_conv.is_owned = ptr_is_owned(ret);
13752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13753         if (get_jenv_res == JNI_EDETACHED) {
13754                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13755         }
13756         return ret_conv;
13757 }
13758 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
13759         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
13760         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13761         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13762 }
13763 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13764         jclass c = (*env)->GetObjectClass(env, o);
13765         CHECK(c != NULL);
13766         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
13767         atomic_init(&calls->refcnt, 1);
13768         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13769         calls->o = (*env)->NewWeakGlobalRef(env, o);
13770         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJ)V");
13771         CHECK(calls->handle_open_channel_meth != NULL);
13772         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJ)V");
13773         CHECK(calls->handle_accept_channel_meth != NULL);
13774         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
13775         CHECK(calls->handle_funding_created_meth != NULL);
13776         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
13777         CHECK(calls->handle_funding_signed_meth != NULL);
13778         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
13779         CHECK(calls->handle_channel_ready_meth != NULL);
13780         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJ)V");
13781         CHECK(calls->handle_shutdown_meth != NULL);
13782         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
13783         CHECK(calls->handle_closing_signed_meth != NULL);
13784         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
13785         CHECK(calls->handle_update_add_htlc_meth != NULL);
13786         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
13787         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
13788         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
13789         CHECK(calls->handle_update_fail_htlc_meth != NULL);
13790         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
13791         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
13792         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
13793         CHECK(calls->handle_commitment_signed_meth != NULL);
13794         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
13795         CHECK(calls->handle_revoke_and_ack_meth != NULL);
13796         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
13797         CHECK(calls->handle_update_fee_meth != NULL);
13798         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
13799         CHECK(calls->handle_announcement_signatures_meth != NULL);
13800         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([B)V");
13801         CHECK(calls->peer_disconnected_meth != NULL);
13802         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJZ)J");
13803         CHECK(calls->peer_connected_meth != NULL);
13804         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
13805         CHECK(calls->handle_channel_reestablish_meth != NULL);
13806         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
13807         CHECK(calls->handle_channel_update_meth != NULL);
13808         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
13809         CHECK(calls->handle_error_meth != NULL);
13810         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
13811         CHECK(calls->provided_node_features_meth != NULL);
13812         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
13813         CHECK(calls->provided_init_features_meth != NULL);
13814
13815         LDKChannelMessageHandler ret = {
13816                 .this_arg = (void*) calls,
13817                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
13818                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
13819                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
13820                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
13821                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
13822                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
13823                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
13824                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
13825                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
13826                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
13827                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
13828                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
13829                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
13830                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
13831                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
13832                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
13833                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
13834                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
13835                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
13836                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
13837                 .provided_node_features = provided_node_features_LDKChannelMessageHandler_jcall,
13838                 .provided_init_features = provided_init_features_LDKChannelMessageHandler_jcall,
13839                 .free = LDKChannelMessageHandler_JCalls_free,
13840                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
13841         };
13842         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13843         return ret;
13844 }
13845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13846         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
13847         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
13848         return tag_ptr(res_ptr, true);
13849 }
13850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
13851         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)untag_ptr(arg);
13852         return tag_ptr(&inp->MessageSendEventsProvider, false);
13853 }
13854 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) {
13855         void* this_arg_ptr = untag_ptr(this_arg);
13856         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13857         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13858         LDKPublicKey their_node_id_ref;
13859         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13860         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13861         LDKOpenChannel msg_conv;
13862         msg_conv.inner = untag_ptr(msg);
13863         msg_conv.is_owned = ptr_is_owned(msg);
13864         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13865         msg_conv.is_owned = false;
13866         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13867 }
13868
13869 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) {
13870         void* this_arg_ptr = untag_ptr(this_arg);
13871         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13872         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13873         LDKPublicKey their_node_id_ref;
13874         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13875         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13876         LDKAcceptChannel msg_conv;
13877         msg_conv.inner = untag_ptr(msg);
13878         msg_conv.is_owned = ptr_is_owned(msg);
13879         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13880         msg_conv.is_owned = false;
13881         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13882 }
13883
13884 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) {
13885         void* this_arg_ptr = untag_ptr(this_arg);
13886         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13887         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13888         LDKPublicKey their_node_id_ref;
13889         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13890         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13891         LDKFundingCreated msg_conv;
13892         msg_conv.inner = untag_ptr(msg);
13893         msg_conv.is_owned = ptr_is_owned(msg);
13894         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13895         msg_conv.is_owned = false;
13896         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13897 }
13898
13899 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) {
13900         void* this_arg_ptr = untag_ptr(this_arg);
13901         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13902         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13903         LDKPublicKey their_node_id_ref;
13904         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13905         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13906         LDKFundingSigned msg_conv;
13907         msg_conv.inner = untag_ptr(msg);
13908         msg_conv.is_owned = ptr_is_owned(msg);
13909         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13910         msg_conv.is_owned = false;
13911         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13912 }
13913
13914 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) {
13915         void* this_arg_ptr = untag_ptr(this_arg);
13916         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13917         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13918         LDKPublicKey their_node_id_ref;
13919         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13920         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13921         LDKChannelReady msg_conv;
13922         msg_conv.inner = untag_ptr(msg);
13923         msg_conv.is_owned = ptr_is_owned(msg);
13924         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13925         msg_conv.is_owned = false;
13926         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13927 }
13928
13929 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) {
13930         void* this_arg_ptr = untag_ptr(this_arg);
13931         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13932         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13933         LDKPublicKey their_node_id_ref;
13934         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13935         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13936         LDKShutdown msg_conv;
13937         msg_conv.inner = untag_ptr(msg);
13938         msg_conv.is_owned = ptr_is_owned(msg);
13939         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13940         msg_conv.is_owned = false;
13941         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13942 }
13943
13944 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) {
13945         void* this_arg_ptr = untag_ptr(this_arg);
13946         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13947         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13948         LDKPublicKey their_node_id_ref;
13949         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13950         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13951         LDKClosingSigned msg_conv;
13952         msg_conv.inner = untag_ptr(msg);
13953         msg_conv.is_owned = ptr_is_owned(msg);
13954         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13955         msg_conv.is_owned = false;
13956         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13957 }
13958
13959 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) {
13960         void* this_arg_ptr = untag_ptr(this_arg);
13961         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13962         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13963         LDKPublicKey their_node_id_ref;
13964         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13965         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13966         LDKUpdateAddHTLC msg_conv;
13967         msg_conv.inner = untag_ptr(msg);
13968         msg_conv.is_owned = ptr_is_owned(msg);
13969         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13970         msg_conv.is_owned = false;
13971         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13972 }
13973
13974 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) {
13975         void* this_arg_ptr = untag_ptr(this_arg);
13976         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13977         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13978         LDKPublicKey their_node_id_ref;
13979         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13980         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13981         LDKUpdateFulfillHTLC msg_conv;
13982         msg_conv.inner = untag_ptr(msg);
13983         msg_conv.is_owned = ptr_is_owned(msg);
13984         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13985         msg_conv.is_owned = false;
13986         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13987 }
13988
13989 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) {
13990         void* this_arg_ptr = untag_ptr(this_arg);
13991         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13992         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13993         LDKPublicKey their_node_id_ref;
13994         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13995         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13996         LDKUpdateFailHTLC msg_conv;
13997         msg_conv.inner = untag_ptr(msg);
13998         msg_conv.is_owned = ptr_is_owned(msg);
13999         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14000         msg_conv.is_owned = false;
14001         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14002 }
14003
14004 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) {
14005         void* this_arg_ptr = untag_ptr(this_arg);
14006         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14007         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14008         LDKPublicKey their_node_id_ref;
14009         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14010         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14011         LDKUpdateFailMalformedHTLC msg_conv;
14012         msg_conv.inner = untag_ptr(msg);
14013         msg_conv.is_owned = ptr_is_owned(msg);
14014         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14015         msg_conv.is_owned = false;
14016         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14017 }
14018
14019 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) {
14020         void* this_arg_ptr = untag_ptr(this_arg);
14021         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14022         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14023         LDKPublicKey their_node_id_ref;
14024         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14025         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14026         LDKCommitmentSigned msg_conv;
14027         msg_conv.inner = untag_ptr(msg);
14028         msg_conv.is_owned = ptr_is_owned(msg);
14029         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14030         msg_conv.is_owned = false;
14031         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14032 }
14033
14034 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) {
14035         void* this_arg_ptr = untag_ptr(this_arg);
14036         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14037         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14038         LDKPublicKey their_node_id_ref;
14039         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14040         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14041         LDKRevokeAndACK msg_conv;
14042         msg_conv.inner = untag_ptr(msg);
14043         msg_conv.is_owned = ptr_is_owned(msg);
14044         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14045         msg_conv.is_owned = false;
14046         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14047 }
14048
14049 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) {
14050         void* this_arg_ptr = untag_ptr(this_arg);
14051         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14052         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14053         LDKPublicKey their_node_id_ref;
14054         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14055         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14056         LDKUpdateFee msg_conv;
14057         msg_conv.inner = untag_ptr(msg);
14058         msg_conv.is_owned = ptr_is_owned(msg);
14059         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14060         msg_conv.is_owned = false;
14061         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14062 }
14063
14064 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) {
14065         void* this_arg_ptr = untag_ptr(this_arg);
14066         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14067         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14068         LDKPublicKey their_node_id_ref;
14069         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14070         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14071         LDKAnnouncementSignatures msg_conv;
14072         msg_conv.inner = untag_ptr(msg);
14073         msg_conv.is_owned = ptr_is_owned(msg);
14074         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14075         msg_conv.is_owned = false;
14076         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14077 }
14078
14079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
14080         void* this_arg_ptr = untag_ptr(this_arg);
14081         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14082         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14083         LDKPublicKey their_node_id_ref;
14084         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14085         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14086         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref);
14087 }
14088
14089 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) {
14090         void* this_arg_ptr = untag_ptr(this_arg);
14091         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14092         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14093         LDKPublicKey their_node_id_ref;
14094         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14095         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14096         LDKInit msg_conv;
14097         msg_conv.inner = untag_ptr(msg);
14098         msg_conv.is_owned = ptr_is_owned(msg);
14099         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14100         msg_conv.is_owned = false;
14101         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14102         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv, inbound);
14103         return tag_ptr(ret_conv, true);
14104 }
14105
14106 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) {
14107         void* this_arg_ptr = untag_ptr(this_arg);
14108         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14109         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14110         LDKPublicKey their_node_id_ref;
14111         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14112         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14113         LDKChannelReestablish msg_conv;
14114         msg_conv.inner = untag_ptr(msg);
14115         msg_conv.is_owned = ptr_is_owned(msg);
14116         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14117         msg_conv.is_owned = false;
14118         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14119 }
14120
14121 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) {
14122         void* this_arg_ptr = untag_ptr(this_arg);
14123         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14124         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14125         LDKPublicKey their_node_id_ref;
14126         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14127         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14128         LDKChannelUpdate msg_conv;
14129         msg_conv.inner = untag_ptr(msg);
14130         msg_conv.is_owned = ptr_is_owned(msg);
14131         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14132         msg_conv.is_owned = false;
14133         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14134 }
14135
14136 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) {
14137         void* this_arg_ptr = untag_ptr(this_arg);
14138         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14139         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14140         LDKPublicKey their_node_id_ref;
14141         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14142         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14143         LDKErrorMessage msg_conv;
14144         msg_conv.inner = untag_ptr(msg);
14145         msg_conv.is_owned = ptr_is_owned(msg);
14146         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14147         msg_conv.is_owned = false;
14148         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
14149 }
14150
14151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
14152         void* this_arg_ptr = untag_ptr(this_arg);
14153         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14154         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14155         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14156         int64_t ret_ref = 0;
14157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14158         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14159         return ret_ref;
14160 }
14161
14162 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) {
14163         void* this_arg_ptr = untag_ptr(this_arg);
14164         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14165         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
14166         LDKPublicKey their_node_id_ref;
14167         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14168         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14169         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14170         int64_t ret_ref = 0;
14171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14172         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14173         return ret_ref;
14174 }
14175
14176 typedef struct LDKRoutingMessageHandler_JCalls {
14177         atomic_size_t refcnt;
14178         JavaVM *vm;
14179         jweak o;
14180         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
14181         jmethodID handle_node_announcement_meth;
14182         jmethodID handle_channel_announcement_meth;
14183         jmethodID handle_channel_update_meth;
14184         jmethodID get_next_channel_announcement_meth;
14185         jmethodID get_next_node_announcement_meth;
14186         jmethodID peer_connected_meth;
14187         jmethodID handle_reply_channel_range_meth;
14188         jmethodID handle_reply_short_channel_ids_end_meth;
14189         jmethodID handle_query_channel_range_meth;
14190         jmethodID handle_query_short_channel_ids_meth;
14191         jmethodID processing_queue_high_meth;
14192         jmethodID provided_node_features_meth;
14193         jmethodID provided_init_features_meth;
14194 } LDKRoutingMessageHandler_JCalls;
14195 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
14196         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14197         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14198                 JNIEnv *env;
14199                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14200                 if (get_jenv_res == JNI_EDETACHED) {
14201                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14202                 } else {
14203                         DO_ASSERT(get_jenv_res == JNI_OK);
14204                 }
14205                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14206                 if (get_jenv_res == JNI_EDETACHED) {
14207                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14208                 }
14209                 FREE(j_calls);
14210         }
14211 }
14212 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
14213         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14214         JNIEnv *env;
14215         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14216         if (get_jenv_res == JNI_EDETACHED) {
14217                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14218         } else {
14219                 DO_ASSERT(get_jenv_res == JNI_OK);
14220         }
14221         LDKNodeAnnouncement msg_var = *msg;
14222         int64_t msg_ref = 0;
14223         msg_var = NodeAnnouncement_clone(&msg_var);
14224         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14225         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14226         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14227         CHECK(obj != NULL);
14228         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
14229         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14230                 (*env)->ExceptionDescribe(env);
14231                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
14232         }
14233         void* ret_ptr = untag_ptr(ret);
14234         CHECK_ACCESS(ret_ptr);
14235         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
14236         FREE(untag_ptr(ret));
14237         if (get_jenv_res == JNI_EDETACHED) {
14238                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14239         }
14240         return ret_conv;
14241 }
14242 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
14243         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14244         JNIEnv *env;
14245         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14246         if (get_jenv_res == JNI_EDETACHED) {
14247                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14248         } else {
14249                 DO_ASSERT(get_jenv_res == JNI_OK);
14250         }
14251         LDKChannelAnnouncement msg_var = *msg;
14252         int64_t msg_ref = 0;
14253         msg_var = ChannelAnnouncement_clone(&msg_var);
14254         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14255         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14256         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14257         CHECK(obj != NULL);
14258         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
14259         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14260                 (*env)->ExceptionDescribe(env);
14261                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
14262         }
14263         void* ret_ptr = untag_ptr(ret);
14264         CHECK_ACCESS(ret_ptr);
14265         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
14266         FREE(untag_ptr(ret));
14267         if (get_jenv_res == JNI_EDETACHED) {
14268                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14269         }
14270         return ret_conv;
14271 }
14272 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
14273         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14274         JNIEnv *env;
14275         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14276         if (get_jenv_res == JNI_EDETACHED) {
14277                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14278         } else {
14279                 DO_ASSERT(get_jenv_res == JNI_OK);
14280         }
14281         LDKChannelUpdate msg_var = *msg;
14282         int64_t msg_ref = 0;
14283         msg_var = ChannelUpdate_clone(&msg_var);
14284         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14285         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14286         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14287         CHECK(obj != NULL);
14288         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
14289         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14290                 (*env)->ExceptionDescribe(env);
14291                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
14292         }
14293         void* ret_ptr = untag_ptr(ret);
14294         CHECK_ACCESS(ret_ptr);
14295         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
14296         FREE(untag_ptr(ret));
14297         if (get_jenv_res == JNI_EDETACHED) {
14298                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14299         }
14300         return ret_conv;
14301 }
14302 LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point) {
14303         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14304         JNIEnv *env;
14305         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14306         if (get_jenv_res == JNI_EDETACHED) {
14307                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14308         } else {
14309                 DO_ASSERT(get_jenv_res == JNI_OK);
14310         }
14311         int64_t starting_point_conv = starting_point;
14312         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14313         CHECK(obj != NULL);
14314         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_channel_announcement_meth, starting_point_conv);
14315         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14316                 (*env)->ExceptionDescribe(env);
14317                 (*env)->FatalError(env, "A call to get_next_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
14318         }
14319         void* ret_ptr = untag_ptr(ret);
14320         CHECK_ACCESS(ret_ptr);
14321         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(ret_ptr);
14322         FREE(untag_ptr(ret));
14323         if (get_jenv_res == JNI_EDETACHED) {
14324                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14325         }
14326         return ret_conv;
14327 }
14328 LDKNodeAnnouncement get_next_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKNodeId starting_point) {
14329         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14330         JNIEnv *env;
14331         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14332         if (get_jenv_res == JNI_EDETACHED) {
14333                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14334         } else {
14335                 DO_ASSERT(get_jenv_res == JNI_OK);
14336         }
14337         LDKNodeId starting_point_var = starting_point;
14338         int64_t starting_point_ref = 0;
14339         CHECK_INNER_FIELD_ACCESS_OR_NULL(starting_point_var);
14340         starting_point_ref = tag_ptr(starting_point_var.inner, starting_point_var.is_owned);
14341         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14342         CHECK(obj != NULL);
14343         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_node_announcement_meth, starting_point_ref);
14344         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14345                 (*env)->ExceptionDescribe(env);
14346                 (*env)->FatalError(env, "A call to get_next_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
14347         }
14348         LDKNodeAnnouncement ret_conv;
14349         ret_conv.inner = untag_ptr(ret);
14350         ret_conv.is_owned = ptr_is_owned(ret);
14351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14352         if (get_jenv_res == JNI_EDETACHED) {
14353                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14354         }
14355         return ret_conv;
14356 }
14357 LDKCResult_NoneNoneZ peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init, bool inbound) {
14358         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14359         JNIEnv *env;
14360         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14361         if (get_jenv_res == JNI_EDETACHED) {
14362                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14363         } else {
14364                 DO_ASSERT(get_jenv_res == JNI_OK);
14365         }
14366         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14367         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14368         LDKInit init_var = *init;
14369         int64_t init_ref = 0;
14370         init_var = Init_clone(&init_var);
14371         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
14372         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
14373         jboolean inbound_conv = inbound;
14374         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14375         CHECK(obj != NULL);
14376         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref, inbound_conv);
14377         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14378                 (*env)->ExceptionDescribe(env);
14379                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
14380         }
14381         void* ret_ptr = untag_ptr(ret);
14382         CHECK_ACCESS(ret_ptr);
14383         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
14384         FREE(untag_ptr(ret));
14385         if (get_jenv_res == JNI_EDETACHED) {
14386                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14387         }
14388         return ret_conv;
14389 }
14390 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
14391         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14392         JNIEnv *env;
14393         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14394         if (get_jenv_res == JNI_EDETACHED) {
14395                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14396         } else {
14397                 DO_ASSERT(get_jenv_res == JNI_OK);
14398         }
14399         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14400         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14401         LDKReplyChannelRange msg_var = msg;
14402         int64_t msg_ref = 0;
14403         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14404         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14405         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14406         CHECK(obj != NULL);
14407         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
14408         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14409                 (*env)->ExceptionDescribe(env);
14410                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
14411         }
14412         void* ret_ptr = untag_ptr(ret);
14413         CHECK_ACCESS(ret_ptr);
14414         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14415         FREE(untag_ptr(ret));
14416         if (get_jenv_res == JNI_EDETACHED) {
14417                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14418         }
14419         return ret_conv;
14420 }
14421 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
14422         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14423         JNIEnv *env;
14424         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14425         if (get_jenv_res == JNI_EDETACHED) {
14426                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14427         } else {
14428                 DO_ASSERT(get_jenv_res == JNI_OK);
14429         }
14430         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14431         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14432         LDKReplyShortChannelIdsEnd msg_var = msg;
14433         int64_t msg_ref = 0;
14434         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14435         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14436         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14437         CHECK(obj != NULL);
14438         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
14439         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14440                 (*env)->ExceptionDescribe(env);
14441                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
14442         }
14443         void* ret_ptr = untag_ptr(ret);
14444         CHECK_ACCESS(ret_ptr);
14445         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14446         FREE(untag_ptr(ret));
14447         if (get_jenv_res == JNI_EDETACHED) {
14448                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14449         }
14450         return ret_conv;
14451 }
14452 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
14453         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14454         JNIEnv *env;
14455         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14456         if (get_jenv_res == JNI_EDETACHED) {
14457                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14458         } else {
14459                 DO_ASSERT(get_jenv_res == JNI_OK);
14460         }
14461         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14462         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14463         LDKQueryChannelRange msg_var = msg;
14464         int64_t msg_ref = 0;
14465         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14466         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14467         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14468         CHECK(obj != NULL);
14469         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
14470         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14471                 (*env)->ExceptionDescribe(env);
14472                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
14473         }
14474         void* ret_ptr = untag_ptr(ret);
14475         CHECK_ACCESS(ret_ptr);
14476         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14477         FREE(untag_ptr(ret));
14478         if (get_jenv_res == JNI_EDETACHED) {
14479                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14480         }
14481         return ret_conv;
14482 }
14483 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
14484         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14485         JNIEnv *env;
14486         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14487         if (get_jenv_res == JNI_EDETACHED) {
14488                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14489         } else {
14490                 DO_ASSERT(get_jenv_res == JNI_OK);
14491         }
14492         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14493         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14494         LDKQueryShortChannelIds msg_var = msg;
14495         int64_t msg_ref = 0;
14496         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14497         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14498         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14499         CHECK(obj != NULL);
14500         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
14501         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14502                 (*env)->ExceptionDescribe(env);
14503                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
14504         }
14505         void* ret_ptr = untag_ptr(ret);
14506         CHECK_ACCESS(ret_ptr);
14507         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14508         FREE(untag_ptr(ret));
14509         if (get_jenv_res == JNI_EDETACHED) {
14510                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14511         }
14512         return ret_conv;
14513 }
14514 bool processing_queue_high_LDKRoutingMessageHandler_jcall(const void* this_arg) {
14515         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14516         JNIEnv *env;
14517         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14518         if (get_jenv_res == JNI_EDETACHED) {
14519                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14520         } else {
14521                 DO_ASSERT(get_jenv_res == JNI_OK);
14522         }
14523         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14524         CHECK(obj != NULL);
14525         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->processing_queue_high_meth);
14526         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14527                 (*env)->ExceptionDescribe(env);
14528                 (*env)->FatalError(env, "A call to processing_queue_high in LDKRoutingMessageHandler from rust threw an exception.");
14529         }
14530         if (get_jenv_res == JNI_EDETACHED) {
14531                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14532         }
14533         return ret;
14534 }
14535 LDKNodeFeatures provided_node_features_LDKRoutingMessageHandler_jcall(const void* this_arg) {
14536         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14537         JNIEnv *env;
14538         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14539         if (get_jenv_res == JNI_EDETACHED) {
14540                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14541         } else {
14542                 DO_ASSERT(get_jenv_res == JNI_OK);
14543         }
14544         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14545         CHECK(obj != NULL);
14546         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
14547         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14548                 (*env)->ExceptionDescribe(env);
14549                 (*env)->FatalError(env, "A call to provided_node_features in LDKRoutingMessageHandler from rust threw an exception.");
14550         }
14551         LDKNodeFeatures ret_conv;
14552         ret_conv.inner = untag_ptr(ret);
14553         ret_conv.is_owned = ptr_is_owned(ret);
14554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14555         if (get_jenv_res == JNI_EDETACHED) {
14556                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14557         }
14558         return ret_conv;
14559 }
14560 LDKInitFeatures provided_init_features_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
14561         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14562         JNIEnv *env;
14563         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14564         if (get_jenv_res == JNI_EDETACHED) {
14565                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14566         } else {
14567                 DO_ASSERT(get_jenv_res == JNI_OK);
14568         }
14569         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14570         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14571         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14572         CHECK(obj != NULL);
14573         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
14574         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14575                 (*env)->ExceptionDescribe(env);
14576                 (*env)->FatalError(env, "A call to provided_init_features in LDKRoutingMessageHandler from rust threw an exception.");
14577         }
14578         LDKInitFeatures ret_conv;
14579         ret_conv.inner = untag_ptr(ret);
14580         ret_conv.is_owned = ptr_is_owned(ret);
14581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14582         if (get_jenv_res == JNI_EDETACHED) {
14583                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14584         }
14585         return ret_conv;
14586 }
14587 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
14588         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
14589         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14590         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
14591 }
14592 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
14593         jclass c = (*env)->GetObjectClass(env, o);
14594         CHECK(c != NULL);
14595         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
14596         atomic_init(&calls->refcnt, 1);
14597         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14598         calls->o = (*env)->NewWeakGlobalRef(env, o);
14599         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
14600         CHECK(calls->handle_node_announcement_meth != NULL);
14601         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
14602         CHECK(calls->handle_channel_announcement_meth != NULL);
14603         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
14604         CHECK(calls->handle_channel_update_meth != NULL);
14605         calls->get_next_channel_announcement_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcement", "(J)J");
14606         CHECK(calls->get_next_channel_announcement_meth != NULL);
14607         calls->get_next_node_announcement_meth = (*env)->GetMethodID(env, c, "get_next_node_announcement", "(J)J");
14608         CHECK(calls->get_next_node_announcement_meth != NULL);
14609         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJZ)J");
14610         CHECK(calls->peer_connected_meth != NULL);
14611         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
14612         CHECK(calls->handle_reply_channel_range_meth != NULL);
14613         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
14614         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
14615         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
14616         CHECK(calls->handle_query_channel_range_meth != NULL);
14617         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
14618         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
14619         calls->processing_queue_high_meth = (*env)->GetMethodID(env, c, "processing_queue_high", "()Z");
14620         CHECK(calls->processing_queue_high_meth != NULL);
14621         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
14622         CHECK(calls->provided_node_features_meth != NULL);
14623         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
14624         CHECK(calls->provided_init_features_meth != NULL);
14625
14626         LDKRoutingMessageHandler ret = {
14627                 .this_arg = (void*) calls,
14628                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
14629                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
14630                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
14631                 .get_next_channel_announcement = get_next_channel_announcement_LDKRoutingMessageHandler_jcall,
14632                 .get_next_node_announcement = get_next_node_announcement_LDKRoutingMessageHandler_jcall,
14633                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
14634                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
14635                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
14636                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
14637                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
14638                 .processing_queue_high = processing_queue_high_LDKRoutingMessageHandler_jcall,
14639                 .provided_node_features = provided_node_features_LDKRoutingMessageHandler_jcall,
14640                 .provided_init_features = provided_init_features_LDKRoutingMessageHandler_jcall,
14641                 .free = LDKRoutingMessageHandler_JCalls_free,
14642                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
14643         };
14644         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
14645         return ret;
14646 }
14647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
14648         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
14649         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
14650         return tag_ptr(res_ptr, true);
14651 }
14652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
14653         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)untag_ptr(arg);
14654         return tag_ptr(&inp->MessageSendEventsProvider, false);
14655 }
14656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
14657         void* this_arg_ptr = untag_ptr(this_arg);
14658         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14659         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14660         LDKNodeAnnouncement msg_conv;
14661         msg_conv.inner = untag_ptr(msg);
14662         msg_conv.is_owned = ptr_is_owned(msg);
14663         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14664         msg_conv.is_owned = false;
14665         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14666         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
14667         return tag_ptr(ret_conv, true);
14668 }
14669
14670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
14671         void* this_arg_ptr = untag_ptr(this_arg);
14672         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14673         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14674         LDKChannelAnnouncement msg_conv;
14675         msg_conv.inner = untag_ptr(msg);
14676         msg_conv.is_owned = ptr_is_owned(msg);
14677         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14678         msg_conv.is_owned = false;
14679         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14680         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
14681         return tag_ptr(ret_conv, true);
14682 }
14683
14684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
14685         void* this_arg_ptr = untag_ptr(this_arg);
14686         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14687         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14688         LDKChannelUpdate msg_conv;
14689         msg_conv.inner = untag_ptr(msg);
14690         msg_conv.is_owned = ptr_is_owned(msg);
14691         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14692         msg_conv.is_owned = false;
14693         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14694         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
14695         return tag_ptr(ret_conv, true);
14696 }
14697
14698 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) {
14699         void* this_arg_ptr = untag_ptr(this_arg);
14700         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14701         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14702         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
14703         *ret_copy = (this_arg_conv->get_next_channel_announcement)(this_arg_conv->this_arg, starting_point);
14704         int64_t ret_ref = tag_ptr(ret_copy, true);
14705         return ret_ref;
14706 }
14707
14708 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) {
14709         void* this_arg_ptr = untag_ptr(this_arg);
14710         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14711         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14712         LDKNodeId starting_point_conv;
14713         starting_point_conv.inner = untag_ptr(starting_point);
14714         starting_point_conv.is_owned = ptr_is_owned(starting_point);
14715         CHECK_INNER_FIELD_ACCESS_OR_NULL(starting_point_conv);
14716         starting_point_conv = NodeId_clone(&starting_point_conv);
14717         LDKNodeAnnouncement ret_var = (this_arg_conv->get_next_node_announcement)(this_arg_conv->this_arg, starting_point_conv);
14718         int64_t ret_ref = 0;
14719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14720         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14721         return ret_ref;
14722 }
14723
14724 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) {
14725         void* this_arg_ptr = untag_ptr(this_arg);
14726         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14727         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14728         LDKPublicKey their_node_id_ref;
14729         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14730         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14731         LDKInit init_conv;
14732         init_conv.inner = untag_ptr(init);
14733         init_conv.is_owned = ptr_is_owned(init);
14734         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
14735         init_conv.is_owned = false;
14736         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14737         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv, inbound);
14738         return tag_ptr(ret_conv, true);
14739 }
14740
14741 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) {
14742         void* this_arg_ptr = untag_ptr(this_arg);
14743         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14744         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14745         LDKPublicKey their_node_id_ref;
14746         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14747         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14748         LDKReplyChannelRange msg_conv;
14749         msg_conv.inner = untag_ptr(msg);
14750         msg_conv.is_owned = ptr_is_owned(msg);
14751         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14752         msg_conv = ReplyChannelRange_clone(&msg_conv);
14753         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14754         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14755         return tag_ptr(ret_conv, true);
14756 }
14757
14758 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) {
14759         void* this_arg_ptr = untag_ptr(this_arg);
14760         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14761         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14762         LDKPublicKey their_node_id_ref;
14763         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14764         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14765         LDKReplyShortChannelIdsEnd msg_conv;
14766         msg_conv.inner = untag_ptr(msg);
14767         msg_conv.is_owned = ptr_is_owned(msg);
14768         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14769         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
14770         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14771         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14772         return tag_ptr(ret_conv, true);
14773 }
14774
14775 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) {
14776         void* this_arg_ptr = untag_ptr(this_arg);
14777         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14778         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14779         LDKPublicKey their_node_id_ref;
14780         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14781         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14782         LDKQueryChannelRange msg_conv;
14783         msg_conv.inner = untag_ptr(msg);
14784         msg_conv.is_owned = ptr_is_owned(msg);
14785         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14786         msg_conv = QueryChannelRange_clone(&msg_conv);
14787         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14788         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14789         return tag_ptr(ret_conv, true);
14790 }
14791
14792 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) {
14793         void* this_arg_ptr = untag_ptr(this_arg);
14794         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14795         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14796         LDKPublicKey their_node_id_ref;
14797         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14798         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14799         LDKQueryShortChannelIds msg_conv;
14800         msg_conv.inner = untag_ptr(msg);
14801         msg_conv.is_owned = ptr_is_owned(msg);
14802         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14803         msg_conv = QueryShortChannelIds_clone(&msg_conv);
14804         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14805         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14806         return tag_ptr(ret_conv, true);
14807 }
14808
14809 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1processing_1queue_1high(JNIEnv *env, jclass clz, int64_t this_arg) {
14810         void* this_arg_ptr = untag_ptr(this_arg);
14811         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14812         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14813         jboolean ret_conv = (this_arg_conv->processing_queue_high)(this_arg_conv->this_arg);
14814         return ret_conv;
14815 }
14816
14817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
14818         void* this_arg_ptr = untag_ptr(this_arg);
14819         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14820         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14821         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14822         int64_t ret_ref = 0;
14823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14824         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14825         return ret_ref;
14826 }
14827
14828 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) {
14829         void* this_arg_ptr = untag_ptr(this_arg);
14830         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14831         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14832         LDKPublicKey their_node_id_ref;
14833         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14834         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14835         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14836         int64_t ret_ref = 0;
14837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14839         return ret_ref;
14840 }
14841
14842 typedef struct LDKOnionMessageProvider_JCalls {
14843         atomic_size_t refcnt;
14844         JavaVM *vm;
14845         jweak o;
14846         jmethodID next_onion_message_for_peer_meth;
14847 } LDKOnionMessageProvider_JCalls;
14848 static void LDKOnionMessageProvider_JCalls_free(void* this_arg) {
14849         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
14850         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14851                 JNIEnv *env;
14852                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14853                 if (get_jenv_res == JNI_EDETACHED) {
14854                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14855                 } else {
14856                         DO_ASSERT(get_jenv_res == JNI_OK);
14857                 }
14858                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14859                 if (get_jenv_res == JNI_EDETACHED) {
14860                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14861                 }
14862                 FREE(j_calls);
14863         }
14864 }
14865 LDKOnionMessage next_onion_message_for_peer_LDKOnionMessageProvider_jcall(const void* this_arg, LDKPublicKey peer_node_id) {
14866         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
14867         JNIEnv *env;
14868         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14869         if (get_jenv_res == JNI_EDETACHED) {
14870                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14871         } else {
14872                 DO_ASSERT(get_jenv_res == JNI_OK);
14873         }
14874         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
14875         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
14876         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14877         CHECK(obj != NULL);
14878         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->next_onion_message_for_peer_meth, peer_node_id_arr);
14879         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14880                 (*env)->ExceptionDescribe(env);
14881                 (*env)->FatalError(env, "A call to next_onion_message_for_peer in LDKOnionMessageProvider from rust threw an exception.");
14882         }
14883         LDKOnionMessage ret_conv;
14884         ret_conv.inner = untag_ptr(ret);
14885         ret_conv.is_owned = ptr_is_owned(ret);
14886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14887         if (get_jenv_res == JNI_EDETACHED) {
14888                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14889         }
14890         return ret_conv;
14891 }
14892 static void LDKOnionMessageProvider_JCalls_cloned(LDKOnionMessageProvider* new_obj) {
14893         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) new_obj->this_arg;
14894         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14895 }
14896 static inline LDKOnionMessageProvider LDKOnionMessageProvider_init (JNIEnv *env, jclass clz, jobject o) {
14897         jclass c = (*env)->GetObjectClass(env, o);
14898         CHECK(c != NULL);
14899         LDKOnionMessageProvider_JCalls *calls = MALLOC(sizeof(LDKOnionMessageProvider_JCalls), "LDKOnionMessageProvider_JCalls");
14900         atomic_init(&calls->refcnt, 1);
14901         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14902         calls->o = (*env)->NewWeakGlobalRef(env, o);
14903         calls->next_onion_message_for_peer_meth = (*env)->GetMethodID(env, c, "next_onion_message_for_peer", "([B)J");
14904         CHECK(calls->next_onion_message_for_peer_meth != NULL);
14905
14906         LDKOnionMessageProvider ret = {
14907                 .this_arg = (void*) calls,
14908                 .next_onion_message_for_peer = next_onion_message_for_peer_LDKOnionMessageProvider_jcall,
14909                 .free = LDKOnionMessageProvider_JCalls_free,
14910         };
14911         return ret;
14912 }
14913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageProvider_1new(JNIEnv *env, jclass clz, jobject o) {
14914         LDKOnionMessageProvider *res_ptr = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
14915         *res_ptr = LDKOnionMessageProvider_init(env, clz, o);
14916         return tag_ptr(res_ptr, true);
14917 }
14918 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) {
14919         void* this_arg_ptr = untag_ptr(this_arg);
14920         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14921         LDKOnionMessageProvider* this_arg_conv = (LDKOnionMessageProvider*)this_arg_ptr;
14922         LDKPublicKey peer_node_id_ref;
14923         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
14924         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
14925         LDKOnionMessage ret_var = (this_arg_conv->next_onion_message_for_peer)(this_arg_conv->this_arg, peer_node_id_ref);
14926         int64_t ret_ref = 0;
14927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14928         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14929         return ret_ref;
14930 }
14931
14932 typedef struct LDKOnionMessageHandler_JCalls {
14933         atomic_size_t refcnt;
14934         JavaVM *vm;
14935         jweak o;
14936         LDKOnionMessageProvider_JCalls* OnionMessageProvider;
14937         jmethodID handle_onion_message_meth;
14938         jmethodID peer_connected_meth;
14939         jmethodID peer_disconnected_meth;
14940         jmethodID provided_node_features_meth;
14941         jmethodID provided_init_features_meth;
14942 } LDKOnionMessageHandler_JCalls;
14943 static void LDKOnionMessageHandler_JCalls_free(void* this_arg) {
14944         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14945         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14946                 JNIEnv *env;
14947                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14948                 if (get_jenv_res == JNI_EDETACHED) {
14949                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14950                 } else {
14951                         DO_ASSERT(get_jenv_res == JNI_OK);
14952                 }
14953                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14954                 if (get_jenv_res == JNI_EDETACHED) {
14955                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14956                 }
14957                 FREE(j_calls);
14958         }
14959 }
14960 void handle_onion_message_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey peer_node_id, const LDKOnionMessage * msg) {
14961         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14962         JNIEnv *env;
14963         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14964         if (get_jenv_res == JNI_EDETACHED) {
14965                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14966         } else {
14967                 DO_ASSERT(get_jenv_res == JNI_OK);
14968         }
14969         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
14970         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
14971         LDKOnionMessage msg_var = *msg;
14972         int64_t msg_ref = 0;
14973         msg_var = OnionMessage_clone(&msg_var);
14974         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14975         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14976         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14977         CHECK(obj != NULL);
14978         (*env)->CallVoidMethod(env, obj, j_calls->handle_onion_message_meth, peer_node_id_arr, msg_ref);
14979         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14980                 (*env)->ExceptionDescribe(env);
14981                 (*env)->FatalError(env, "A call to handle_onion_message in LDKOnionMessageHandler from rust threw an exception.");
14982         }
14983         if (get_jenv_res == JNI_EDETACHED) {
14984                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14985         }
14986 }
14987 LDKCResult_NoneNoneZ peer_connected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init, bool inbound) {
14988         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14989         JNIEnv *env;
14990         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14991         if (get_jenv_res == JNI_EDETACHED) {
14992                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14993         } else {
14994                 DO_ASSERT(get_jenv_res == JNI_OK);
14995         }
14996         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
14997         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
14998         LDKInit init_var = *init;
14999         int64_t init_ref = 0;
15000         init_var = Init_clone(&init_var);
15001         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
15002         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
15003         jboolean inbound_conv = inbound;
15004         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15005         CHECK(obj != NULL);
15006         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref, inbound_conv);
15007         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15008                 (*env)->ExceptionDescribe(env);
15009                 (*env)->FatalError(env, "A call to peer_connected in LDKOnionMessageHandler from rust threw an exception.");
15010         }
15011         void* ret_ptr = untag_ptr(ret);
15012         CHECK_ACCESS(ret_ptr);
15013         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
15014         FREE(untag_ptr(ret));
15015         if (get_jenv_res == JNI_EDETACHED) {
15016                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15017         }
15018         return ret_conv;
15019 }
15020 void peer_disconnected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
15021         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
15022         JNIEnv *env;
15023         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15024         if (get_jenv_res == JNI_EDETACHED) {
15025                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15026         } else {
15027                 DO_ASSERT(get_jenv_res == JNI_OK);
15028         }
15029         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
15030         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
15031         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15032         CHECK(obj != NULL);
15033         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr);
15034         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15035                 (*env)->ExceptionDescribe(env);
15036                 (*env)->FatalError(env, "A call to peer_disconnected in LDKOnionMessageHandler from rust threw an exception.");
15037         }
15038         if (get_jenv_res == JNI_EDETACHED) {
15039                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15040         }
15041 }
15042 LDKNodeFeatures provided_node_features_LDKOnionMessageHandler_jcall(const void* this_arg) {
15043         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
15044         JNIEnv *env;
15045         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15046         if (get_jenv_res == JNI_EDETACHED) {
15047                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15048         } else {
15049                 DO_ASSERT(get_jenv_res == JNI_OK);
15050         }
15051         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15052         CHECK(obj != NULL);
15053         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
15054         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15055                 (*env)->ExceptionDescribe(env);
15056                 (*env)->FatalError(env, "A call to provided_node_features in LDKOnionMessageHandler from rust threw an exception.");
15057         }
15058         LDKNodeFeatures ret_conv;
15059         ret_conv.inner = untag_ptr(ret);
15060         ret_conv.is_owned = ptr_is_owned(ret);
15061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
15062         if (get_jenv_res == JNI_EDETACHED) {
15063                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15064         }
15065         return ret_conv;
15066 }
15067 LDKInitFeatures provided_init_features_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
15068         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
15069         JNIEnv *env;
15070         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15071         if (get_jenv_res == JNI_EDETACHED) {
15072                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15073         } else {
15074                 DO_ASSERT(get_jenv_res == JNI_OK);
15075         }
15076         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
15077         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
15078         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15079         CHECK(obj != NULL);
15080         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
15081         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15082                 (*env)->ExceptionDescribe(env);
15083                 (*env)->FatalError(env, "A call to provided_init_features in LDKOnionMessageHandler from rust threw an exception.");
15084         }
15085         LDKInitFeatures ret_conv;
15086         ret_conv.inner = untag_ptr(ret);
15087         ret_conv.is_owned = ptr_is_owned(ret);
15088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
15089         if (get_jenv_res == JNI_EDETACHED) {
15090                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15091         }
15092         return ret_conv;
15093 }
15094 static void LDKOnionMessageHandler_JCalls_cloned(LDKOnionMessageHandler* new_obj) {
15095         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) new_obj->this_arg;
15096         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15097         atomic_fetch_add_explicit(&j_calls->OnionMessageProvider->refcnt, 1, memory_order_release);
15098 }
15099 static inline LDKOnionMessageHandler LDKOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
15100         jclass c = (*env)->GetObjectClass(env, o);
15101         CHECK(c != NULL);
15102         LDKOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKOnionMessageHandler_JCalls), "LDKOnionMessageHandler_JCalls");
15103         atomic_init(&calls->refcnt, 1);
15104         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15105         calls->o = (*env)->NewWeakGlobalRef(env, o);
15106         calls->handle_onion_message_meth = (*env)->GetMethodID(env, c, "handle_onion_message", "([BJ)V");
15107         CHECK(calls->handle_onion_message_meth != NULL);
15108         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJZ)J");
15109         CHECK(calls->peer_connected_meth != NULL);
15110         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([B)V");
15111         CHECK(calls->peer_disconnected_meth != NULL);
15112         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
15113         CHECK(calls->provided_node_features_meth != NULL);
15114         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
15115         CHECK(calls->provided_init_features_meth != NULL);
15116
15117         LDKOnionMessageHandler ret = {
15118                 .this_arg = (void*) calls,
15119                 .handle_onion_message = handle_onion_message_LDKOnionMessageHandler_jcall,
15120                 .peer_connected = peer_connected_LDKOnionMessageHandler_jcall,
15121                 .peer_disconnected = peer_disconnected_LDKOnionMessageHandler_jcall,
15122                 .provided_node_features = provided_node_features_LDKOnionMessageHandler_jcall,
15123                 .provided_init_features = provided_init_features_LDKOnionMessageHandler_jcall,
15124                 .free = LDKOnionMessageHandler_JCalls_free,
15125                 .OnionMessageProvider = LDKOnionMessageProvider_init(env, clz, OnionMessageProvider),
15126         };
15127         calls->OnionMessageProvider = ret.OnionMessageProvider.this_arg;
15128         return ret;
15129 }
15130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
15131         LDKOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
15132         *res_ptr = LDKOnionMessageHandler_init(env, clz, o, OnionMessageProvider);
15133         return tag_ptr(res_ptr, true);
15134 }
15135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1get_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t arg) {
15136         LDKOnionMessageHandler *inp = (LDKOnionMessageHandler *)untag_ptr(arg);
15137         return tag_ptr(&inp->OnionMessageProvider, false);
15138 }
15139 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) {
15140         void* this_arg_ptr = untag_ptr(this_arg);
15141         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15142         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
15143         LDKPublicKey peer_node_id_ref;
15144         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
15145         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
15146         LDKOnionMessage msg_conv;
15147         msg_conv.inner = untag_ptr(msg);
15148         msg_conv.is_owned = ptr_is_owned(msg);
15149         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
15150         msg_conv.is_owned = false;
15151         (this_arg_conv->handle_onion_message)(this_arg_conv->this_arg, peer_node_id_ref, &msg_conv);
15152 }
15153
15154 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) {
15155         void* this_arg_ptr = untag_ptr(this_arg);
15156         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15157         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
15158         LDKPublicKey their_node_id_ref;
15159         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
15160         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
15161         LDKInit init_conv;
15162         init_conv.inner = untag_ptr(init);
15163         init_conv.is_owned = ptr_is_owned(init);
15164         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
15165         init_conv.is_owned = false;
15166         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15167         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv, inbound);
15168         return tag_ptr(ret_conv, true);
15169 }
15170
15171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
15172         void* this_arg_ptr = untag_ptr(this_arg);
15173         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15174         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
15175         LDKPublicKey their_node_id_ref;
15176         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
15177         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
15178         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref);
15179 }
15180
15181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
15182         void* this_arg_ptr = untag_ptr(this_arg);
15183         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15184         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
15185         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
15186         int64_t ret_ref = 0;
15187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
15188         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
15189         return ret_ref;
15190 }
15191
15192 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) {
15193         void* this_arg_ptr = untag_ptr(this_arg);
15194         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15195         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
15196         LDKPublicKey their_node_id_ref;
15197         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
15198         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
15199         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
15200         int64_t ret_ref = 0;
15201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
15202         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
15203         return ret_ref;
15204 }
15205
15206 typedef struct LDKCustomMessageReader_JCalls {
15207         atomic_size_t refcnt;
15208         JavaVM *vm;
15209         jweak o;
15210         jmethodID read_meth;
15211 } LDKCustomMessageReader_JCalls;
15212 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
15213         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
15214         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15215                 JNIEnv *env;
15216                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15217                 if (get_jenv_res == JNI_EDETACHED) {
15218                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15219                 } else {
15220                         DO_ASSERT(get_jenv_res == JNI_OK);
15221                 }
15222                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
15223                 if (get_jenv_res == JNI_EDETACHED) {
15224                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15225                 }
15226                 FREE(j_calls);
15227         }
15228 }
15229 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
15230         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
15231         JNIEnv *env;
15232         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15233         if (get_jenv_res == JNI_EDETACHED) {
15234                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15235         } else {
15236                 DO_ASSERT(get_jenv_res == JNI_OK);
15237         }
15238         int16_t message_type_conv = message_type;
15239         LDKu8slice buffer_var = buffer;
15240         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
15241         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
15242         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15243         CHECK(obj != NULL);
15244         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
15245         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15246                 (*env)->ExceptionDescribe(env);
15247                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
15248         }
15249         void* ret_ptr = untag_ptr(ret);
15250         CHECK_ACCESS(ret_ptr);
15251         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
15252         FREE(untag_ptr(ret));
15253         if (get_jenv_res == JNI_EDETACHED) {
15254                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15255         }
15256         return ret_conv;
15257 }
15258 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
15259         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
15260         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15261 }
15262 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
15263         jclass c = (*env)->GetObjectClass(env, o);
15264         CHECK(c != NULL);
15265         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
15266         atomic_init(&calls->refcnt, 1);
15267         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15268         calls->o = (*env)->NewWeakGlobalRef(env, o);
15269         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
15270         CHECK(calls->read_meth != NULL);
15271
15272         LDKCustomMessageReader ret = {
15273                 .this_arg = (void*) calls,
15274                 .read = read_LDKCustomMessageReader_jcall,
15275                 .free = LDKCustomMessageReader_JCalls_free,
15276         };
15277         return ret;
15278 }
15279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
15280         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
15281         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
15282         return tag_ptr(res_ptr, true);
15283 }
15284 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) {
15285         void* this_arg_ptr = untag_ptr(this_arg);
15286         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15287         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
15288         LDKu8slice buffer_ref;
15289         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
15290         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
15291         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15292         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
15293         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
15294         return tag_ptr(ret_conv, true);
15295 }
15296
15297 typedef struct LDKCustomMessageHandler_JCalls {
15298         atomic_size_t refcnt;
15299         JavaVM *vm;
15300         jweak o;
15301         LDKCustomMessageReader_JCalls* CustomMessageReader;
15302         jmethodID handle_custom_message_meth;
15303         jmethodID get_and_clear_pending_msg_meth;
15304 } LDKCustomMessageHandler_JCalls;
15305 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
15306         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
15307         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15308                 JNIEnv *env;
15309                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15310                 if (get_jenv_res == JNI_EDETACHED) {
15311                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15312                 } else {
15313                         DO_ASSERT(get_jenv_res == JNI_OK);
15314                 }
15315                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
15316                 if (get_jenv_res == JNI_EDETACHED) {
15317                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15318                 }
15319                 FREE(j_calls);
15320         }
15321 }
15322 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
15323         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
15324         JNIEnv *env;
15325         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15326         if (get_jenv_res == JNI_EDETACHED) {
15327                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15328         } else {
15329                 DO_ASSERT(get_jenv_res == JNI_OK);
15330         }
15331         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
15332         *msg_ret = msg;
15333         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
15334         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
15335         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15336         CHECK(obj != NULL);
15337         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true), sender_node_id_arr);
15338         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15339                 (*env)->ExceptionDescribe(env);
15340                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
15341         }
15342         void* ret_ptr = untag_ptr(ret);
15343         CHECK_ACCESS(ret_ptr);
15344         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
15345         FREE(untag_ptr(ret));
15346         if (get_jenv_res == JNI_EDETACHED) {
15347                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15348         }
15349         return ret_conv;
15350 }
15351 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
15352         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
15353         JNIEnv *env;
15354         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15355         if (get_jenv_res == JNI_EDETACHED) {
15356                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15357         } else {
15358                 DO_ASSERT(get_jenv_res == JNI_OK);
15359         }
15360         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15361         CHECK(obj != NULL);
15362         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
15363         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15364                 (*env)->ExceptionDescribe(env);
15365                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
15366         }
15367         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
15368         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
15369         if (ret_constr.datalen > 0)
15370                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
15371         else
15372                 ret_constr.data = NULL;
15373         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
15374         for (size_t z = 0; z < ret_constr.datalen; z++) {
15375                 int64_t ret_conv_25 = ret_vals[z];
15376                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
15377                 CHECK_ACCESS(ret_conv_25_ptr);
15378                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
15379                 FREE(untag_ptr(ret_conv_25));
15380                 ret_constr.data[z] = ret_conv_25_conv;
15381         }
15382         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
15383         if (get_jenv_res == JNI_EDETACHED) {
15384                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15385         }
15386         return ret_constr;
15387 }
15388 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
15389         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
15390         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15391         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
15392 }
15393 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
15394         jclass c = (*env)->GetObjectClass(env, o);
15395         CHECK(c != NULL);
15396         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
15397         atomic_init(&calls->refcnt, 1);
15398         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15399         calls->o = (*env)->NewWeakGlobalRef(env, o);
15400         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
15401         CHECK(calls->handle_custom_message_meth != NULL);
15402         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
15403         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
15404
15405         LDKCustomMessageHandler ret = {
15406                 .this_arg = (void*) calls,
15407                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
15408                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
15409                 .free = LDKCustomMessageHandler_JCalls_free,
15410                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
15411         };
15412         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
15413         return ret;
15414 }
15415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
15416         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
15417         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
15418         return tag_ptr(res_ptr, true);
15419 }
15420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
15421         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)untag_ptr(arg);
15422         return tag_ptr(&inp->CustomMessageReader, false);
15423 }
15424 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) {
15425         void* this_arg_ptr = untag_ptr(this_arg);
15426         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15427         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
15428         void* msg_ptr = untag_ptr(msg);
15429         CHECK_ACCESS(msg_ptr);
15430         LDKType msg_conv = *(LDKType*)(msg_ptr);
15431         if (msg_conv.free == LDKType_JCalls_free) {
15432                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15433                 LDKType_JCalls_cloned(&msg_conv);
15434         }
15435         LDKPublicKey sender_node_id_ref;
15436         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
15437         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
15438         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15439         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
15440         return tag_ptr(ret_conv, true);
15441 }
15442
15443 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
15444         void* this_arg_ptr = untag_ptr(this_arg);
15445         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15446         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
15447         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
15448         int64_tArray ret_arr = NULL;
15449         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15450         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15451         for (size_t z = 0; z < ret_var.datalen; z++) {
15452                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
15453                 *ret_conv_25_conv = ret_var.data[z];
15454                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
15455         }
15456         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15457         FREE(ret_var.data);
15458         return ret_arr;
15459 }
15460
15461 typedef struct LDKCustomOnionMessageHandler_JCalls {
15462         atomic_size_t refcnt;
15463         JavaVM *vm;
15464         jweak o;
15465         jmethodID handle_custom_message_meth;
15466         jmethodID read_custom_message_meth;
15467 } LDKCustomOnionMessageHandler_JCalls;
15468 static void LDKCustomOnionMessageHandler_JCalls_free(void* this_arg) {
15469         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
15470         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15471                 JNIEnv *env;
15472                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15473                 if (get_jenv_res == JNI_EDETACHED) {
15474                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15475                 } else {
15476                         DO_ASSERT(get_jenv_res == JNI_OK);
15477                 }
15478                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
15479                 if (get_jenv_res == JNI_EDETACHED) {
15480                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15481                 }
15482                 FREE(j_calls);
15483         }
15484 }
15485 void handle_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, LDKCustomOnionMessageContents msg) {
15486         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
15487         JNIEnv *env;
15488         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15489         if (get_jenv_res == JNI_EDETACHED) {
15490                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15491         } else {
15492                 DO_ASSERT(get_jenv_res == JNI_OK);
15493         }
15494         LDKCustomOnionMessageContents* msg_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
15495         *msg_ret = msg;
15496         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15497         CHECK(obj != NULL);
15498         (*env)->CallVoidMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true));
15499         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15500                 (*env)->ExceptionDescribe(env);
15501                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
15502         }
15503         if (get_jenv_res == JNI_EDETACHED) {
15504                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15505         }
15506 }
15507 LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ read_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, uint64_t message_type, LDKu8slice buffer) {
15508         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
15509         JNIEnv *env;
15510         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15511         if (get_jenv_res == JNI_EDETACHED) {
15512                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15513         } else {
15514                 DO_ASSERT(get_jenv_res == JNI_OK);
15515         }
15516         int64_t message_type_conv = message_type;
15517         LDKu8slice buffer_var = buffer;
15518         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
15519         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
15520         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15521         CHECK(obj != NULL);
15522         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_custom_message_meth, message_type_conv, buffer_arr);
15523         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15524                 (*env)->ExceptionDescribe(env);
15525                 (*env)->FatalError(env, "A call to read_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
15526         }
15527         void* ret_ptr = untag_ptr(ret);
15528         CHECK_ACCESS(ret_ptr);
15529         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ ret_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(ret_ptr);
15530         FREE(untag_ptr(ret));
15531         if (get_jenv_res == JNI_EDETACHED) {
15532                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15533         }
15534         return ret_conv;
15535 }
15536 static void LDKCustomOnionMessageHandler_JCalls_cloned(LDKCustomOnionMessageHandler* new_obj) {
15537         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) new_obj->this_arg;
15538         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15539 }
15540 static inline LDKCustomOnionMessageHandler LDKCustomOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o) {
15541         jclass c = (*env)->GetObjectClass(env, o);
15542         CHECK(c != NULL);
15543         LDKCustomOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageHandler_JCalls), "LDKCustomOnionMessageHandler_JCalls");
15544         atomic_init(&calls->refcnt, 1);
15545         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15546         calls->o = (*env)->NewWeakGlobalRef(env, o);
15547         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J)V");
15548         CHECK(calls->handle_custom_message_meth != NULL);
15549         calls->read_custom_message_meth = (*env)->GetMethodID(env, c, "read_custom_message", "(J[B)J");
15550         CHECK(calls->read_custom_message_meth != NULL);
15551
15552         LDKCustomOnionMessageHandler ret = {
15553                 .this_arg = (void*) calls,
15554                 .handle_custom_message = handle_custom_message_LDKCustomOnionMessageHandler_jcall,
15555                 .read_custom_message = read_custom_message_LDKCustomOnionMessageHandler_jcall,
15556                 .free = LDKCustomOnionMessageHandler_JCalls_free,
15557         };
15558         return ret;
15559 }
15560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o) {
15561         LDKCustomOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
15562         *res_ptr = LDKCustomOnionMessageHandler_init(env, clz, o);
15563         return tag_ptr(res_ptr, true);
15564 }
15565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
15566         void* this_arg_ptr = untag_ptr(this_arg);
15567         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15568         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
15569         void* msg_ptr = untag_ptr(msg);
15570         CHECK_ACCESS(msg_ptr);
15571         LDKCustomOnionMessageContents msg_conv = *(LDKCustomOnionMessageContents*)(msg_ptr);
15572         if (msg_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
15573                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15574                 LDKCustomOnionMessageContents_JCalls_cloned(&msg_conv);
15575         }
15576         (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv);
15577 }
15578
15579 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) {
15580         void* this_arg_ptr = untag_ptr(this_arg);
15581         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15582         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
15583         LDKu8slice buffer_ref;
15584         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
15585         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
15586         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
15587         *ret_conv = (this_arg_conv->read_custom_message)(this_arg_conv->this_arg, message_type, buffer_ref);
15588         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
15589         return tag_ptr(ret_conv, true);
15590 }
15591
15592 typedef struct LDKSocketDescriptor_JCalls {
15593         atomic_size_t refcnt;
15594         JavaVM *vm;
15595         jweak o;
15596         jmethodID send_data_meth;
15597         jmethodID disconnect_socket_meth;
15598         jmethodID eq_meth;
15599         jmethodID hash_meth;
15600 } LDKSocketDescriptor_JCalls;
15601 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
15602         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15603         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15604                 JNIEnv *env;
15605                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15606                 if (get_jenv_res == JNI_EDETACHED) {
15607                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15608                 } else {
15609                         DO_ASSERT(get_jenv_res == JNI_OK);
15610                 }
15611                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
15612                 if (get_jenv_res == JNI_EDETACHED) {
15613                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15614                 }
15615                 FREE(j_calls);
15616         }
15617 }
15618 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
15619         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15620         JNIEnv *env;
15621         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15622         if (get_jenv_res == JNI_EDETACHED) {
15623                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15624         } else {
15625                 DO_ASSERT(get_jenv_res == JNI_OK);
15626         }
15627         LDKu8slice data_var = data;
15628         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
15629         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
15630         jboolean resume_read_conv = resume_read;
15631         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15632         CHECK(obj != NULL);
15633         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
15634         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15635                 (*env)->ExceptionDescribe(env);
15636                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
15637         }
15638         if (get_jenv_res == JNI_EDETACHED) {
15639                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15640         }
15641         return ret;
15642 }
15643 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
15644         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15645         JNIEnv *env;
15646         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15647         if (get_jenv_res == JNI_EDETACHED) {
15648                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15649         } else {
15650                 DO_ASSERT(get_jenv_res == JNI_OK);
15651         }
15652         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15653         CHECK(obj != NULL);
15654         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
15655         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15656                 (*env)->ExceptionDescribe(env);
15657                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
15658         }
15659         if (get_jenv_res == JNI_EDETACHED) {
15660                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15661         }
15662 }
15663 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
15664         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15665         JNIEnv *env;
15666         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15667         if (get_jenv_res == JNI_EDETACHED) {
15668                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15669         } else {
15670                 DO_ASSERT(get_jenv_res == JNI_OK);
15671         }
15672         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
15673         *other_arg_clone = SocketDescriptor_clone(other_arg);
15674         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15675         CHECK(obj != NULL);
15676         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, tag_ptr(other_arg_clone, true));
15677         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15678                 (*env)->ExceptionDescribe(env);
15679                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
15680         }
15681         if (get_jenv_res == JNI_EDETACHED) {
15682                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15683         }
15684         return ret;
15685 }
15686 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
15687         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
15688         JNIEnv *env;
15689         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15690         if (get_jenv_res == JNI_EDETACHED) {
15691                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15692         } else {
15693                 DO_ASSERT(get_jenv_res == JNI_OK);
15694         }
15695         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15696         CHECK(obj != NULL);
15697         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
15698         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15699                 (*env)->ExceptionDescribe(env);
15700                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
15701         }
15702         if (get_jenv_res == JNI_EDETACHED) {
15703                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15704         }
15705         return ret;
15706 }
15707 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
15708         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
15709         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15710 }
15711 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
15712         jclass c = (*env)->GetObjectClass(env, o);
15713         CHECK(c != NULL);
15714         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
15715         atomic_init(&calls->refcnt, 1);
15716         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15717         calls->o = (*env)->NewWeakGlobalRef(env, o);
15718         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
15719         CHECK(calls->send_data_meth != NULL);
15720         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
15721         CHECK(calls->disconnect_socket_meth != NULL);
15722         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
15723         CHECK(calls->eq_meth != NULL);
15724         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
15725         CHECK(calls->hash_meth != NULL);
15726
15727         LDKSocketDescriptor ret = {
15728                 .this_arg = (void*) calls,
15729                 .send_data = send_data_LDKSocketDescriptor_jcall,
15730                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
15731                 .eq = eq_LDKSocketDescriptor_jcall,
15732                 .hash = hash_LDKSocketDescriptor_jcall,
15733                 .cloned = LDKSocketDescriptor_JCalls_cloned,
15734                 .free = LDKSocketDescriptor_JCalls_free,
15735         };
15736         return ret;
15737 }
15738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
15739         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
15740         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
15741         return tag_ptr(res_ptr, true);
15742 }
15743 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) {
15744         void* this_arg_ptr = untag_ptr(this_arg);
15745         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15746         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
15747         LDKu8slice data_ref;
15748         data_ref.datalen = (*env)->GetArrayLength(env, data);
15749         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
15750         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
15751         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
15752         return ret_conv;
15753 }
15754
15755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
15756         void* this_arg_ptr = untag_ptr(this_arg);
15757         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15758         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
15759         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
15760 }
15761
15762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
15763         void* this_arg_ptr = untag_ptr(this_arg);
15764         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15765         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
15766         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
15767         return ret_conv;
15768 }
15769
15770 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
15771 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
15772 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
15773 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
15774 static jclass LDKEffectiveCapacity_Total_class = NULL;
15775 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
15776 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
15777 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
15778 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
15779 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
15780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
15781         LDKEffectiveCapacity_ExactLiquidity_class =
15782                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
15783         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
15784         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
15785         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
15786         LDKEffectiveCapacity_MaximumHTLC_class =
15787                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
15788         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
15789         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
15790         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
15791         LDKEffectiveCapacity_Total_class =
15792                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
15793         CHECK(LDKEffectiveCapacity_Total_class != NULL);
15794         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
15795         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
15796         LDKEffectiveCapacity_Infinite_class =
15797                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
15798         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
15799         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
15800         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
15801         LDKEffectiveCapacity_Unknown_class =
15802                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
15803         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
15804         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
15805         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
15806 }
15807 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15808         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
15809         switch(obj->tag) {
15810                 case LDKEffectiveCapacity_ExactLiquidity: {
15811                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
15812                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
15813                 }
15814                 case LDKEffectiveCapacity_MaximumHTLC: {
15815                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
15816                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
15817                 }
15818                 case LDKEffectiveCapacity_Total: {
15819                         int64_t capacity_msat_conv = obj->total.capacity_msat;
15820                         int64_t htlc_maximum_msat_conv = obj->total.htlc_maximum_msat;
15821                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_conv);
15822                 }
15823                 case LDKEffectiveCapacity_Infinite: {
15824                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
15825                 }
15826                 case LDKEffectiveCapacity_Unknown: {
15827                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
15828                 }
15829                 default: abort();
15830         }
15831 }
15832 static jclass LDKHints_Blinded_class = NULL;
15833 static jmethodID LDKHints_Blinded_meth = NULL;
15834 static jclass LDKHints_Clear_class = NULL;
15835 static jmethodID LDKHints_Clear_meth = NULL;
15836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHints_init (JNIEnv *env, jclass clz) {
15837         LDKHints_Blinded_class =
15838                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHints$Blinded"));
15839         CHECK(LDKHints_Blinded_class != NULL);
15840         LDKHints_Blinded_meth = (*env)->GetMethodID(env, LDKHints_Blinded_class, "<init>", "([J)V");
15841         CHECK(LDKHints_Blinded_meth != NULL);
15842         LDKHints_Clear_class =
15843                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHints$Clear"));
15844         CHECK(LDKHints_Clear_class != NULL);
15845         LDKHints_Clear_meth = (*env)->GetMethodID(env, LDKHints_Clear_class, "<init>", "([J)V");
15846         CHECK(LDKHints_Clear_meth != NULL);
15847 }
15848 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHints_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15849         LDKHints *obj = (LDKHints*)untag_ptr(ptr);
15850         switch(obj->tag) {
15851                 case LDKHints_Blinded: {
15852                         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ blinded_var = obj->blinded;
15853                         int64_tArray blinded_arr = NULL;
15854                         blinded_arr = (*env)->NewLongArray(env, blinded_var.datalen);
15855                         int64_t *blinded_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, blinded_arr, NULL);
15856                         for (size_t l = 0; l < blinded_var.datalen; l++) {
15857                                 LDKC2Tuple_BlindedPayInfoBlindedPathZ* blinded_conv_37_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
15858                                 *blinded_conv_37_conv = blinded_var.data[l];
15859                                 *blinded_conv_37_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone(blinded_conv_37_conv);
15860                                 blinded_arr_ptr[l] = tag_ptr(blinded_conv_37_conv, true);
15861                         }
15862                         (*env)->ReleasePrimitiveArrayCritical(env, blinded_arr, blinded_arr_ptr, 0);
15863                         return (*env)->NewObject(env, LDKHints_Blinded_class, LDKHints_Blinded_meth, blinded_arr);
15864                 }
15865                 case LDKHints_Clear: {
15866                         LDKCVec_RouteHintZ clear_var = obj->clear;
15867                         int64_tArray clear_arr = NULL;
15868                         clear_arr = (*env)->NewLongArray(env, clear_var.datalen);
15869                         int64_t *clear_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, clear_arr, NULL);
15870                         for (size_t l = 0; l < clear_var.datalen; l++) {
15871                                 LDKRouteHint clear_conv_11_var = clear_var.data[l];
15872                                 int64_t clear_conv_11_ref = 0;
15873                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(clear_conv_11_var);
15874                                 clear_conv_11_ref = tag_ptr(clear_conv_11_var.inner, false);
15875                                 clear_arr_ptr[l] = clear_conv_11_ref;
15876                         }
15877                         (*env)->ReleasePrimitiveArrayCritical(env, clear_arr, clear_arr_ptr, 0);
15878                         return (*env)->NewObject(env, LDKHints_Clear_class, LDKHints_Clear_meth, clear_arr);
15879                 }
15880                 default: abort();
15881         }
15882 }
15883 static jclass LDKDestination_Node_class = NULL;
15884 static jmethodID LDKDestination_Node_meth = NULL;
15885 static jclass LDKDestination_BlindedPath_class = NULL;
15886 static jmethodID LDKDestination_BlindedPath_meth = NULL;
15887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDestination_init (JNIEnv *env, jclass clz) {
15888         LDKDestination_Node_class =
15889                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$Node"));
15890         CHECK(LDKDestination_Node_class != NULL);
15891         LDKDestination_Node_meth = (*env)->GetMethodID(env, LDKDestination_Node_class, "<init>", "([B)V");
15892         CHECK(LDKDestination_Node_meth != NULL);
15893         LDKDestination_BlindedPath_class =
15894                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$BlindedPath"));
15895         CHECK(LDKDestination_BlindedPath_class != NULL);
15896         LDKDestination_BlindedPath_meth = (*env)->GetMethodID(env, LDKDestination_BlindedPath_class, "<init>", "(J)V");
15897         CHECK(LDKDestination_BlindedPath_meth != NULL);
15898 }
15899 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15900         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
15901         switch(obj->tag) {
15902                 case LDKDestination_Node: {
15903                         int8_tArray node_arr = (*env)->NewByteArray(env, 33);
15904                         (*env)->SetByteArrayRegion(env, node_arr, 0, 33, obj->node.compressed_form);
15905                         return (*env)->NewObject(env, LDKDestination_Node_class, LDKDestination_Node_meth, node_arr);
15906                 }
15907                 case LDKDestination_BlindedPath: {
15908                         LDKBlindedPath blinded_path_var = obj->blinded_path;
15909                         int64_t blinded_path_ref = 0;
15910                         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_path_var);
15911                         blinded_path_ref = tag_ptr(blinded_path_var.inner, false);
15912                         return (*env)->NewObject(env, LDKDestination_BlindedPath_class, LDKDestination_BlindedPath_meth, blinded_path_ref);
15913                 }
15914                 default: abort();
15915         }
15916 }
15917 static jclass LDKOnionMessageContents_Custom_class = NULL;
15918 static jmethodID LDKOnionMessageContents_Custom_meth = NULL;
15919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKOnionMessageContents_init (JNIEnv *env, jclass clz) {
15920         LDKOnionMessageContents_Custom_class =
15921                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKOnionMessageContents$Custom"));
15922         CHECK(LDKOnionMessageContents_Custom_class != NULL);
15923         LDKOnionMessageContents_Custom_meth = (*env)->GetMethodID(env, LDKOnionMessageContents_Custom_class, "<init>", "(J)V");
15924         CHECK(LDKOnionMessageContents_Custom_meth != NULL);
15925 }
15926 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageContents_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15927         LDKOnionMessageContents *obj = (LDKOnionMessageContents*)untag_ptr(ptr);
15928         switch(obj->tag) {
15929                 case LDKOnionMessageContents_Custom: {
15930                         LDKCustomOnionMessageContents* custom_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
15931                         *custom_ret = CustomOnionMessageContents_clone(&obj->custom);
15932                         return (*env)->NewObject(env, LDKOnionMessageContents_Custom_class, LDKOnionMessageContents_Custom_meth, tag_ptr(custom_ret, true));
15933                 }
15934                 default: abort();
15935         }
15936 }
15937 static jclass LDKGossipSync_P2P_class = NULL;
15938 static jmethodID LDKGossipSync_P2P_meth = NULL;
15939 static jclass LDKGossipSync_Rapid_class = NULL;
15940 static jmethodID LDKGossipSync_Rapid_meth = NULL;
15941 static jclass LDKGossipSync_None_class = NULL;
15942 static jmethodID LDKGossipSync_None_meth = NULL;
15943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
15944         LDKGossipSync_P2P_class =
15945                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
15946         CHECK(LDKGossipSync_P2P_class != NULL);
15947         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
15948         CHECK(LDKGossipSync_P2P_meth != NULL);
15949         LDKGossipSync_Rapid_class =
15950                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
15951         CHECK(LDKGossipSync_Rapid_class != NULL);
15952         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
15953         CHECK(LDKGossipSync_Rapid_meth != NULL);
15954         LDKGossipSync_None_class =
15955                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
15956         CHECK(LDKGossipSync_None_class != NULL);
15957         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
15958         CHECK(LDKGossipSync_None_meth != NULL);
15959 }
15960 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15961         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
15962         switch(obj->tag) {
15963                 case LDKGossipSync_P2P: {
15964                         LDKP2PGossipSync p2p_var = obj->p2p;
15965                         int64_t p2p_ref = 0;
15966                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
15967                         p2p_ref = tag_ptr(p2p_var.inner, false);
15968                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
15969                 }
15970                 case LDKGossipSync_Rapid: {
15971                         LDKRapidGossipSync rapid_var = obj->rapid;
15972                         int64_t rapid_ref = 0;
15973                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
15974                         rapid_ref = tag_ptr(rapid_var.inner, false);
15975                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
15976                 }
15977                 case LDKGossipSync_None: {
15978                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
15979                 }
15980                 default: abort();
15981         }
15982 }
15983 static jclass LDKFallback_SegWitProgram_class = NULL;
15984 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
15985 static jclass LDKFallback_PubKeyHash_class = NULL;
15986 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
15987 static jclass LDKFallback_ScriptHash_class = NULL;
15988 static jmethodID LDKFallback_ScriptHash_meth = NULL;
15989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
15990         LDKFallback_SegWitProgram_class =
15991                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
15992         CHECK(LDKFallback_SegWitProgram_class != NULL);
15993         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
15994         CHECK(LDKFallback_SegWitProgram_meth != NULL);
15995         LDKFallback_PubKeyHash_class =
15996                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
15997         CHECK(LDKFallback_PubKeyHash_class != NULL);
15998         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
15999         CHECK(LDKFallback_PubKeyHash_meth != NULL);
16000         LDKFallback_ScriptHash_class =
16001                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
16002         CHECK(LDKFallback_ScriptHash_class != NULL);
16003         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
16004         CHECK(LDKFallback_ScriptHash_meth != NULL);
16005 }
16006 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
16007         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
16008         switch(obj->tag) {
16009                 case LDKFallback_SegWitProgram: {
16010                         uint8_t version_val = obj->seg_wit_program.version._0;
16011                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
16012                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
16013                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
16014                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
16015                 }
16016                 case LDKFallback_PubKeyHash: {
16017                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
16018                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
16019                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
16020                 }
16021                 case LDKFallback_ScriptHash: {
16022                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
16023                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
16024                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
16025                 }
16026                 default: abort();
16027         }
16028 }
16029 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
16030         LDKStr ret_str = _ldk_get_compiled_version();
16031         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
16032         Str_free(ret_str);
16033         return ret_conv;
16034 }
16035
16036 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
16037         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
16038         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
16039         Str_free(ret_str);
16040         return ret_conv;
16041 }
16042
16043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_U128_1le_1bytes(JNIEnv *env, jclass clz, int8_tArray val) {
16044         LDKU128 val_ref;
16045         CHECK((*env)->GetArrayLength(env, val) == 16);
16046         (*env)->GetByteArrayRegion(env, val, 0, 16, val_ref.le_bytes);
16047         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
16048         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, U128_le_bytes(val_ref).data);
16049         return ret_arr;
16050 }
16051
16052 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_U128_1new(JNIEnv *env, jclass clz, int8_tArray le_bytes) {
16053         LDKSixteenBytes le_bytes_ref;
16054         CHECK((*env)->GetArrayLength(env, le_bytes) == 16);
16055         (*env)->GetByteArrayRegion(env, le_bytes, 0, 16, le_bytes_ref.data);
16056         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
16057         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, U128_new(le_bytes_ref).le_bytes);
16058         return ret_arr;
16059 }
16060
16061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1new(JNIEnv *env, jclass clz, int8_tArray big_endian_bytes) {
16062         LDKThirtyTwoBytes big_endian_bytes_ref;
16063         CHECK((*env)->GetArrayLength(env, big_endian_bytes) == 32);
16064         (*env)->GetByteArrayRegion(env, big_endian_bytes, 0, 32, big_endian_bytes_ref.data);
16065         LDKBigEndianScalar* ret_ref = MALLOC(sizeof(LDKBigEndianScalar), "LDKBigEndianScalar");
16066         *ret_ref = BigEndianScalar_new(big_endian_bytes_ref);
16067         return tag_ptr(ret_ref, true);
16068 }
16069
16070 static inline uint64_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
16071         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
16072         *ret_copy = Bech32Error_clone(arg);
16073         int64_t ret_ref = tag_ptr(ret_copy, true);
16074         return ret_ref;
16075 }
16076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16077         LDKBech32Error* arg_conv = (LDKBech32Error*)untag_ptr(arg);
16078         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
16079         return ret_conv;
16080 }
16081
16082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16083         LDKBech32Error* orig_conv = (LDKBech32Error*)untag_ptr(orig);
16084         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
16085         *ret_copy = Bech32Error_clone(orig_conv);
16086         int64_t ret_ref = tag_ptr(ret_copy, true);
16087         return ret_ref;
16088 }
16089
16090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
16091         if (!ptr_is_owned(o)) return;
16092         void* o_ptr = untag_ptr(o);
16093         CHECK_ACCESS(o_ptr);
16094         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
16095         FREE(untag_ptr(o));
16096         Bech32Error_free(o_conv);
16097 }
16098
16099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
16100         LDKTransaction _res_ref;
16101         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
16102         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
16103         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
16104         _res_ref.data_is_owned = true;
16105         Transaction_free(_res_ref);
16106 }
16107
16108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Witness_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
16109         LDKWitness _res_ref;
16110         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
16111         _res_ref.data = MALLOC(_res_ref.datalen, "LDKWitness Bytes");
16112         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
16113         _res_ref.data_is_owned = true;
16114         Witness_free(_res_ref);
16115 }
16116
16117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
16118         LDKCVec_u8Z script_pubkey_ref;
16119         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
16120         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
16121         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
16122         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
16123         *ret_ref = TxOut_new(script_pubkey_ref, value);
16124         return tag_ptr(ret_ref, true);
16125 }
16126
16127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
16128         if (!ptr_is_owned(_res)) return;
16129         void* _res_ptr = untag_ptr(_res);
16130         CHECK_ACCESS(_res_ptr);
16131         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
16132         FREE(untag_ptr(_res));
16133         TxOut_free(_res_conv);
16134 }
16135
16136 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
16137         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
16138         *ret_ref = TxOut_clone(arg);
16139         return tag_ptr(ret_ref, true);
16140 }
16141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16142         LDKTxOut* arg_conv = (LDKTxOut*)untag_ptr(arg);
16143         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
16144         return ret_conv;
16145 }
16146
16147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16148         LDKTxOut* orig_conv = (LDKTxOut*)untag_ptr(orig);
16149         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
16150         *ret_ref = TxOut_clone(orig_conv);
16151         return tag_ptr(ret_ref, true);
16152 }
16153
16154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
16155         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
16156         Str_free(dummy);
16157 }
16158
16159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1DurationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16160         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
16161         *ret_copy = COption_DurationZ_some(o);
16162         int64_t ret_ref = tag_ptr(ret_copy, true);
16163         return ret_ref;
16164 }
16165
16166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1DurationZ_1none(JNIEnv *env, jclass clz) {
16167         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
16168         *ret_copy = COption_DurationZ_none();
16169         int64_t ret_ref = tag_ptr(ret_copy, true);
16170         return ret_ref;
16171 }
16172
16173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1DurationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16174         if (!ptr_is_owned(_res)) return;
16175         void* _res_ptr = untag_ptr(_res);
16176         CHECK_ACCESS(_res_ptr);
16177         LDKCOption_DurationZ _res_conv = *(LDKCOption_DurationZ*)(_res_ptr);
16178         FREE(untag_ptr(_res));
16179         COption_DurationZ_free(_res_conv);
16180 }
16181
16182 static inline uint64_t COption_DurationZ_clone_ptr(LDKCOption_DurationZ *NONNULL_PTR arg) {
16183         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
16184         *ret_copy = COption_DurationZ_clone(arg);
16185         int64_t ret_ref = tag_ptr(ret_copy, true);
16186         return ret_ref;
16187 }
16188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1DurationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16189         LDKCOption_DurationZ* arg_conv = (LDKCOption_DurationZ*)untag_ptr(arg);
16190         int64_t ret_conv = COption_DurationZ_clone_ptr(arg_conv);
16191         return ret_conv;
16192 }
16193
16194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1DurationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16195         LDKCOption_DurationZ* orig_conv = (LDKCOption_DurationZ*)untag_ptr(orig);
16196         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
16197         *ret_copy = COption_DurationZ_clone(orig_conv);
16198         int64_t ret_ref = tag_ptr(ret_copy, true);
16199         return ret_ref;
16200 }
16201
16202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BlindedPathZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16203         LDKCVec_BlindedPathZ _res_constr;
16204         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16205         if (_res_constr.datalen > 0)
16206                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBlindedPath), "LDKCVec_BlindedPathZ Elements");
16207         else
16208                 _res_constr.data = NULL;
16209         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16210         for (size_t n = 0; n < _res_constr.datalen; n++) {
16211                 int64_t _res_conv_13 = _res_vals[n];
16212                 LDKBlindedPath _res_conv_13_conv;
16213                 _res_conv_13_conv.inner = untag_ptr(_res_conv_13);
16214                 _res_conv_13_conv.is_owned = ptr_is_owned(_res_conv_13);
16215                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_13_conv);
16216                 _res_constr.data[n] = _res_conv_13_conv;
16217         }
16218         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16219         CVec_BlindedPathZ_free(_res_constr);
16220 }
16221
16222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
16223         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16224         *ret_copy = COption_u64Z_some(o);
16225         int64_t ret_ref = tag_ptr(ret_copy, true);
16226         return ret_ref;
16227 }
16228
16229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
16230         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16231         *ret_copy = COption_u64Z_none();
16232         int64_t ret_ref = tag_ptr(ret_copy, true);
16233         return ret_ref;
16234 }
16235
16236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16237         if (!ptr_is_owned(_res)) return;
16238         void* _res_ptr = untag_ptr(_res);
16239         CHECK_ACCESS(_res_ptr);
16240         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
16241         FREE(untag_ptr(_res));
16242         COption_u64Z_free(_res_conv);
16243 }
16244
16245 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
16246         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16247         *ret_copy = COption_u64Z_clone(arg);
16248         int64_t ret_ref = tag_ptr(ret_copy, true);
16249         return ret_ref;
16250 }
16251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16252         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)untag_ptr(arg);
16253         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
16254         return ret_conv;
16255 }
16256
16257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16258         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)untag_ptr(orig);
16259         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16260         *ret_copy = COption_u64Z_clone(orig_conv);
16261         int64_t ret_ref = tag_ptr(ret_copy, true);
16262         return ret_ref;
16263 }
16264
16265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
16266         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16267         *ret_conv = CResult_NoneAPIErrorZ_ok();
16268         return tag_ptr(ret_conv, true);
16269 }
16270
16271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16272         void* e_ptr = untag_ptr(e);
16273         CHECK_ACCESS(e_ptr);
16274         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16275         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
16276         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16277         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
16278         return tag_ptr(ret_conv, true);
16279 }
16280
16281 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16282         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(o);
16283         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
16284         return ret_conv;
16285 }
16286
16287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16288         if (!ptr_is_owned(_res)) return;
16289         void* _res_ptr = untag_ptr(_res);
16290         CHECK_ACCESS(_res_ptr);
16291         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
16292         FREE(untag_ptr(_res));
16293         CResult_NoneAPIErrorZ_free(_res_conv);
16294 }
16295
16296 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
16297         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16298         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
16299         return tag_ptr(ret_conv, true);
16300 }
16301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16302         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(arg);
16303         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
16304         return ret_conv;
16305 }
16306
16307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16308         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(orig);
16309         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16310         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
16311         return tag_ptr(ret_conv, true);
16312 }
16313
16314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16315         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
16316         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16317         if (_res_constr.datalen > 0)
16318                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
16319         else
16320                 _res_constr.data = NULL;
16321         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16322         for (size_t w = 0; w < _res_constr.datalen; w++) {
16323                 int64_t _res_conv_22 = _res_vals[w];
16324                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
16325                 CHECK_ACCESS(_res_conv_22_ptr);
16326                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
16327                 FREE(untag_ptr(_res_conv_22));
16328                 _res_constr.data[w] = _res_conv_22_conv;
16329         }
16330         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16331         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
16332 }
16333
16334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16335         LDKCVec_APIErrorZ _res_constr;
16336         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16337         if (_res_constr.datalen > 0)
16338                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
16339         else
16340                 _res_constr.data = NULL;
16341         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16342         for (size_t k = 0; k < _res_constr.datalen; k++) {
16343                 int64_t _res_conv_10 = _res_vals[k];
16344                 void* _res_conv_10_ptr = untag_ptr(_res_conv_10);
16345                 CHECK_ACCESS(_res_conv_10_ptr);
16346                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
16347                 FREE(untag_ptr(_res_conv_10));
16348                 _res_constr.data[k] = _res_conv_10_conv;
16349         }
16350         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16351         CVec_APIErrorZ_free(_res_constr);
16352 }
16353
16354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
16355         LDKCVec_u8Z _res_ref;
16356         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
16357         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
16358         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
16359         CVec_u8Z_free(_res_ref);
16360 }
16361
16362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1u8ZZ_1some(JNIEnv *env, jclass clz, int8_tArray o) {
16363         LDKCVec_u8Z o_ref;
16364         o_ref.datalen = (*env)->GetArrayLength(env, o);
16365         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
16366         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
16367         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
16368         *ret_copy = COption_CVec_u8ZZ_some(o_ref);
16369         int64_t ret_ref = tag_ptr(ret_copy, true);
16370         return ret_ref;
16371 }
16372
16373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1u8ZZ_1none(JNIEnv *env, jclass clz) {
16374         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
16375         *ret_copy = COption_CVec_u8ZZ_none();
16376         int64_t ret_ref = tag_ptr(ret_copy, true);
16377         return ret_ref;
16378 }
16379
16380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16381         if (!ptr_is_owned(_res)) return;
16382         void* _res_ptr = untag_ptr(_res);
16383         CHECK_ACCESS(_res_ptr);
16384         LDKCOption_CVec_u8ZZ _res_conv = *(LDKCOption_CVec_u8ZZ*)(_res_ptr);
16385         FREE(untag_ptr(_res));
16386         COption_CVec_u8ZZ_free(_res_conv);
16387 }
16388
16389 static inline uint64_t COption_CVec_u8ZZ_clone_ptr(LDKCOption_CVec_u8ZZ *NONNULL_PTR arg) {
16390         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
16391         *ret_copy = COption_CVec_u8ZZ_clone(arg);
16392         int64_t ret_ref = tag_ptr(ret_copy, true);
16393         return ret_ref;
16394 }
16395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1u8ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16396         LDKCOption_CVec_u8ZZ* arg_conv = (LDKCOption_CVec_u8ZZ*)untag_ptr(arg);
16397         int64_t ret_conv = COption_CVec_u8ZZ_clone_ptr(arg_conv);
16398         return ret_conv;
16399 }
16400
16401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1u8ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16402         LDKCOption_CVec_u8ZZ* orig_conv = (LDKCOption_CVec_u8ZZ*)untag_ptr(orig);
16403         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
16404         *ret_copy = COption_CVec_u8ZZ_clone(orig_conv);
16405         int64_t ret_ref = tag_ptr(ret_copy, true);
16406         return ret_ref;
16407 }
16408
16409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16410         LDKRecipientOnionFields o_conv;
16411         o_conv.inner = untag_ptr(o);
16412         o_conv.is_owned = ptr_is_owned(o);
16413         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16414         o_conv = RecipientOnionFields_clone(&o_conv);
16415         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16416         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_ok(o_conv);
16417         return tag_ptr(ret_conv, true);
16418 }
16419
16420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16421         void* e_ptr = untag_ptr(e);
16422         CHECK_ACCESS(e_ptr);
16423         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16424         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16425         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16426         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_err(e_conv);
16427         return tag_ptr(ret_conv, true);
16428 }
16429
16430 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16431         LDKCResult_RecipientOnionFieldsDecodeErrorZ* o_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(o);
16432         jboolean ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_is_ok(o_conv);
16433         return ret_conv;
16434 }
16435
16436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16437         if (!ptr_is_owned(_res)) return;
16438         void* _res_ptr = untag_ptr(_res);
16439         CHECK_ACCESS(_res_ptr);
16440         LDKCResult_RecipientOnionFieldsDecodeErrorZ _res_conv = *(LDKCResult_RecipientOnionFieldsDecodeErrorZ*)(_res_ptr);
16441         FREE(untag_ptr(_res));
16442         CResult_RecipientOnionFieldsDecodeErrorZ_free(_res_conv);
16443 }
16444
16445 static inline uint64_t CResult_RecipientOnionFieldsDecodeErrorZ_clone_ptr(LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR arg) {
16446         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16447         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_clone(arg);
16448         return tag_ptr(ret_conv, true);
16449 }
16450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16451         LDKCResult_RecipientOnionFieldsDecodeErrorZ* arg_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(arg);
16452         int64_t ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_clone_ptr(arg_conv);
16453         return ret_conv;
16454 }
16455
16456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecipientOnionFieldsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16457         LDKCResult_RecipientOnionFieldsDecodeErrorZ* orig_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(orig);
16458         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16459         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_clone(orig_conv);
16460         return tag_ptr(ret_conv, true);
16461 }
16462
16463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1some(JNIEnv *env, jclass clz, jclass o) {
16464         LDKHTLCClaim o_conv = LDKHTLCClaim_from_java(env, o);
16465         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
16466         *ret_copy = COption_HTLCClaimZ_some(o_conv);
16467         int64_t ret_ref = tag_ptr(ret_copy, true);
16468         return ret_ref;
16469 }
16470
16471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1none(JNIEnv *env, jclass clz) {
16472         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
16473         *ret_copy = COption_HTLCClaimZ_none();
16474         int64_t ret_ref = tag_ptr(ret_copy, true);
16475         return ret_ref;
16476 }
16477
16478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16479         if (!ptr_is_owned(_res)) return;
16480         void* _res_ptr = untag_ptr(_res);
16481         CHECK_ACCESS(_res_ptr);
16482         LDKCOption_HTLCClaimZ _res_conv = *(LDKCOption_HTLCClaimZ*)(_res_ptr);
16483         FREE(untag_ptr(_res));
16484         COption_HTLCClaimZ_free(_res_conv);
16485 }
16486
16487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
16488         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16489         *ret_conv = CResult_NoneNoneZ_ok();
16490         return tag_ptr(ret_conv, true);
16491 }
16492
16493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
16494         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16495         *ret_conv = CResult_NoneNoneZ_err();
16496         return tag_ptr(ret_conv, true);
16497 }
16498
16499 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16500         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)untag_ptr(o);
16501         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
16502         return ret_conv;
16503 }
16504
16505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16506         if (!ptr_is_owned(_res)) return;
16507         void* _res_ptr = untag_ptr(_res);
16508         CHECK_ACCESS(_res_ptr);
16509         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
16510         FREE(untag_ptr(_res));
16511         CResult_NoneNoneZ_free(_res_conv);
16512 }
16513
16514 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
16515         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16516         *ret_conv = CResult_NoneNoneZ_clone(arg);
16517         return tag_ptr(ret_conv, true);
16518 }
16519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16520         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)untag_ptr(arg);
16521         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
16522         return ret_conv;
16523 }
16524
16525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16526         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)untag_ptr(orig);
16527         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16528         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
16529         return tag_ptr(ret_conv, true);
16530 }
16531
16532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16533         LDKCounterpartyCommitmentSecrets o_conv;
16534         o_conv.inner = untag_ptr(o);
16535         o_conv.is_owned = ptr_is_owned(o);
16536         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16537         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
16538         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16539         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
16540         return tag_ptr(ret_conv, true);
16541 }
16542
16543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16544         void* e_ptr = untag_ptr(e);
16545         CHECK_ACCESS(e_ptr);
16546         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16547         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16548         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16549         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
16550         return tag_ptr(ret_conv, true);
16551 }
16552
16553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16554         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(o);
16555         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
16556         return ret_conv;
16557 }
16558
16559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16560         if (!ptr_is_owned(_res)) return;
16561         void* _res_ptr = untag_ptr(_res);
16562         CHECK_ACCESS(_res_ptr);
16563         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
16564         FREE(untag_ptr(_res));
16565         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
16566 }
16567
16568 static inline uint64_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
16569         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16570         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
16571         return tag_ptr(ret_conv, true);
16572 }
16573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16574         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(arg);
16575         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
16576         return ret_conv;
16577 }
16578
16579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16580         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(orig);
16581         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16582         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
16583         return tag_ptr(ret_conv, true);
16584 }
16585
16586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16587         LDKTxCreationKeys o_conv;
16588         o_conv.inner = untag_ptr(o);
16589         o_conv.is_owned = ptr_is_owned(o);
16590         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16591         o_conv = TxCreationKeys_clone(&o_conv);
16592         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16593         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
16594         return tag_ptr(ret_conv, true);
16595 }
16596
16597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16598         void* e_ptr = untag_ptr(e);
16599         CHECK_ACCESS(e_ptr);
16600         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16601         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16602         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16603         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
16604         return tag_ptr(ret_conv, true);
16605 }
16606
16607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16608         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(o);
16609         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
16610         return ret_conv;
16611 }
16612
16613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16614         if (!ptr_is_owned(_res)) return;
16615         void* _res_ptr = untag_ptr(_res);
16616         CHECK_ACCESS(_res_ptr);
16617         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
16618         FREE(untag_ptr(_res));
16619         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
16620 }
16621
16622 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
16623         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16624         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
16625         return tag_ptr(ret_conv, true);
16626 }
16627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16628         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(arg);
16629         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
16630         return ret_conv;
16631 }
16632
16633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16634         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(orig);
16635         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16636         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
16637         return tag_ptr(ret_conv, true);
16638 }
16639
16640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16641         LDKChannelPublicKeys o_conv;
16642         o_conv.inner = untag_ptr(o);
16643         o_conv.is_owned = ptr_is_owned(o);
16644         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16645         o_conv = ChannelPublicKeys_clone(&o_conv);
16646         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16647         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
16648         return tag_ptr(ret_conv, true);
16649 }
16650
16651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16652         void* e_ptr = untag_ptr(e);
16653         CHECK_ACCESS(e_ptr);
16654         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16655         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16656         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16657         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
16658         return tag_ptr(ret_conv, true);
16659 }
16660
16661 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16662         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(o);
16663         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
16664         return ret_conv;
16665 }
16666
16667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16668         if (!ptr_is_owned(_res)) return;
16669         void* _res_ptr = untag_ptr(_res);
16670         CHECK_ACCESS(_res_ptr);
16671         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
16672         FREE(untag_ptr(_res));
16673         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
16674 }
16675
16676 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
16677         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16678         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
16679         return tag_ptr(ret_conv, true);
16680 }
16681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16682         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(arg);
16683         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
16684         return ret_conv;
16685 }
16686
16687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16688         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(orig);
16689         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16690         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
16691         return tag_ptr(ret_conv, true);
16692 }
16693
16694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
16695         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16696         *ret_copy = COption_u32Z_some(o);
16697         int64_t ret_ref = tag_ptr(ret_copy, true);
16698         return ret_ref;
16699 }
16700
16701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
16702         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16703         *ret_copy = COption_u32Z_none();
16704         int64_t ret_ref = tag_ptr(ret_copy, true);
16705         return ret_ref;
16706 }
16707
16708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16709         if (!ptr_is_owned(_res)) return;
16710         void* _res_ptr = untag_ptr(_res);
16711         CHECK_ACCESS(_res_ptr);
16712         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
16713         FREE(untag_ptr(_res));
16714         COption_u32Z_free(_res_conv);
16715 }
16716
16717 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
16718         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16719         *ret_copy = COption_u32Z_clone(arg);
16720         int64_t ret_ref = tag_ptr(ret_copy, true);
16721         return ret_ref;
16722 }
16723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16724         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)untag_ptr(arg);
16725         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
16726         return ret_conv;
16727 }
16728
16729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16730         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)untag_ptr(orig);
16731         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16732         *ret_copy = COption_u32Z_clone(orig_conv);
16733         int64_t ret_ref = tag_ptr(ret_copy, true);
16734         return ret_ref;
16735 }
16736
16737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16738         LDKHTLCOutputInCommitment o_conv;
16739         o_conv.inner = untag_ptr(o);
16740         o_conv.is_owned = ptr_is_owned(o);
16741         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16742         o_conv = HTLCOutputInCommitment_clone(&o_conv);
16743         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16744         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
16745         return tag_ptr(ret_conv, true);
16746 }
16747
16748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16749         void* e_ptr = untag_ptr(e);
16750         CHECK_ACCESS(e_ptr);
16751         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16752         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16753         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16754         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
16755         return tag_ptr(ret_conv, true);
16756 }
16757
16758 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16759         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(o);
16760         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
16761         return ret_conv;
16762 }
16763
16764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16765         if (!ptr_is_owned(_res)) return;
16766         void* _res_ptr = untag_ptr(_res);
16767         CHECK_ACCESS(_res_ptr);
16768         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
16769         FREE(untag_ptr(_res));
16770         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
16771 }
16772
16773 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
16774         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16775         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
16776         return tag_ptr(ret_conv, true);
16777 }
16778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16779         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(arg);
16780         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
16781         return ret_conv;
16782 }
16783
16784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16785         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(orig);
16786         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16787         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
16788         return tag_ptr(ret_conv, true);
16789 }
16790
16791 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
16792         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
16793         return ret_conv;
16794 }
16795
16796 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
16797         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
16798         return ret_conv;
16799 }
16800
16801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
16802         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
16803         COption_NoneZ_free(_res_conv);
16804 }
16805
16806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16807         LDKCounterpartyChannelTransactionParameters o_conv;
16808         o_conv.inner = untag_ptr(o);
16809         o_conv.is_owned = ptr_is_owned(o);
16810         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16811         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
16812         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16813         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16814         return tag_ptr(ret_conv, true);
16815 }
16816
16817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16818         void* e_ptr = untag_ptr(e);
16819         CHECK_ACCESS(e_ptr);
16820         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16821         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16822         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16823         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
16824         return tag_ptr(ret_conv, true);
16825 }
16826
16827 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16828         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16829         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16830         return ret_conv;
16831 }
16832
16833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16834         if (!ptr_is_owned(_res)) return;
16835         void* _res_ptr = untag_ptr(_res);
16836         CHECK_ACCESS(_res_ptr);
16837         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16838         FREE(untag_ptr(_res));
16839         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16840 }
16841
16842 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16843         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16844         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
16845         return tag_ptr(ret_conv, true);
16846 }
16847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16848         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16849         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16850         return ret_conv;
16851 }
16852
16853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16854         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16855         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16856         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16857         return tag_ptr(ret_conv, true);
16858 }
16859
16860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16861         LDKChannelTransactionParameters o_conv;
16862         o_conv.inner = untag_ptr(o);
16863         o_conv.is_owned = ptr_is_owned(o);
16864         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16865         o_conv = ChannelTransactionParameters_clone(&o_conv);
16866         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16867         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16868         return tag_ptr(ret_conv, true);
16869 }
16870
16871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16872         void* e_ptr = untag_ptr(e);
16873         CHECK_ACCESS(e_ptr);
16874         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16875         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16876         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16877         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
16878         return tag_ptr(ret_conv, true);
16879 }
16880
16881 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16882         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16883         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16884         return ret_conv;
16885 }
16886
16887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16888         if (!ptr_is_owned(_res)) return;
16889         void* _res_ptr = untag_ptr(_res);
16890         CHECK_ACCESS(_res_ptr);
16891         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16892         FREE(untag_ptr(_res));
16893         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16894 }
16895
16896 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16897         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16898         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
16899         return tag_ptr(ret_conv, true);
16900 }
16901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16902         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16903         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16904         return ret_conv;
16905 }
16906
16907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16908         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16909         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16910         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16911         return tag_ptr(ret_conv, true);
16912 }
16913
16914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16915         LDKCVec_SignatureZ _res_constr;
16916         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16917         if (_res_constr.datalen > 0)
16918                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16919         else
16920                 _res_constr.data = NULL;
16921         for (size_t i = 0; i < _res_constr.datalen; i++) {
16922                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16923                 LDKSignature _res_conv_8_ref;
16924                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
16925                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
16926                 _res_constr.data[i] = _res_conv_8_ref;
16927         }
16928         CVec_SignatureZ_free(_res_constr);
16929 }
16930
16931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16932         LDKHolderCommitmentTransaction o_conv;
16933         o_conv.inner = untag_ptr(o);
16934         o_conv.is_owned = ptr_is_owned(o);
16935         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16936         o_conv = HolderCommitmentTransaction_clone(&o_conv);
16937         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16938         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
16939         return tag_ptr(ret_conv, true);
16940 }
16941
16942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16943         void* e_ptr = untag_ptr(e);
16944         CHECK_ACCESS(e_ptr);
16945         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16946         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16947         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16948         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
16949         return tag_ptr(ret_conv, true);
16950 }
16951
16952 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16953         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16954         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16955         return ret_conv;
16956 }
16957
16958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16959         if (!ptr_is_owned(_res)) return;
16960         void* _res_ptr = untag_ptr(_res);
16961         CHECK_ACCESS(_res_ptr);
16962         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
16963         FREE(untag_ptr(_res));
16964         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
16965 }
16966
16967 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16968         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16969         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
16970         return tag_ptr(ret_conv, true);
16971 }
16972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16973         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16974         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16975         return ret_conv;
16976 }
16977
16978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16979         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16980         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16981         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
16982         return tag_ptr(ret_conv, true);
16983 }
16984
16985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16986         LDKBuiltCommitmentTransaction o_conv;
16987         o_conv.inner = untag_ptr(o);
16988         o_conv.is_owned = ptr_is_owned(o);
16989         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16990         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
16991         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16992         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
16993         return tag_ptr(ret_conv, true);
16994 }
16995
16996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16997         void* e_ptr = untag_ptr(e);
16998         CHECK_ACCESS(e_ptr);
16999         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17000         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17001         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
17002         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
17003         return tag_ptr(ret_conv, true);
17004 }
17005
17006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17007         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
17008         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
17009         return ret_conv;
17010 }
17011
17012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17013         if (!ptr_is_owned(_res)) return;
17014         void* _res_ptr = untag_ptr(_res);
17015         CHECK_ACCESS(_res_ptr);
17016         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
17017         FREE(untag_ptr(_res));
17018         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
17019 }
17020
17021 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
17022         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
17023         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
17024         return tag_ptr(ret_conv, true);
17025 }
17026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17027         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
17028         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
17029         return ret_conv;
17030 }
17031
17032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17033         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
17034         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
17035         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
17036         return tag_ptr(ret_conv, true);
17037 }
17038
17039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17040         LDKTrustedClosingTransaction o_conv;
17041         o_conv.inner = untag_ptr(o);
17042         o_conv.is_owned = ptr_is_owned(o);
17043         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17044         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
17045         
17046         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
17047         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
17048         return tag_ptr(ret_conv, true);
17049 }
17050
17051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
17052         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
17053         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
17054         return tag_ptr(ret_conv, true);
17055 }
17056
17057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17058         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(o);
17059         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
17060         return ret_conv;
17061 }
17062
17063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17064         if (!ptr_is_owned(_res)) return;
17065         void* _res_ptr = untag_ptr(_res);
17066         CHECK_ACCESS(_res_ptr);
17067         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
17068         FREE(untag_ptr(_res));
17069         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
17070 }
17071
17072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17073         LDKCommitmentTransaction o_conv;
17074         o_conv.inner = untag_ptr(o);
17075         o_conv.is_owned = ptr_is_owned(o);
17076         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17077         o_conv = CommitmentTransaction_clone(&o_conv);
17078         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
17079         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
17080         return tag_ptr(ret_conv, true);
17081 }
17082
17083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17084         void* e_ptr = untag_ptr(e);
17085         CHECK_ACCESS(e_ptr);
17086         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17087         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17088         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
17089         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
17090         return tag_ptr(ret_conv, true);
17091 }
17092
17093 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17094         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(o);
17095         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
17096         return ret_conv;
17097 }
17098
17099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17100         if (!ptr_is_owned(_res)) return;
17101         void* _res_ptr = untag_ptr(_res);
17102         CHECK_ACCESS(_res_ptr);
17103         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
17104         FREE(untag_ptr(_res));
17105         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
17106 }
17107
17108 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
17109         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
17110         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
17111         return tag_ptr(ret_conv, true);
17112 }
17113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17114         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
17115         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
17116         return ret_conv;
17117 }
17118
17119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17120         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
17121         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
17122         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
17123         return tag_ptr(ret_conv, true);
17124 }
17125
17126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17127         LDKTrustedCommitmentTransaction o_conv;
17128         o_conv.inner = untag_ptr(o);
17129         o_conv.is_owned = ptr_is_owned(o);
17130         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17131         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
17132         
17133         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
17134         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
17135         return tag_ptr(ret_conv, true);
17136 }
17137
17138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
17139         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
17140         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
17141         return tag_ptr(ret_conv, true);
17142 }
17143
17144 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17145         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(o);
17146         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
17147         return ret_conv;
17148 }
17149
17150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17151         if (!ptr_is_owned(_res)) return;
17152         void* _res_ptr = untag_ptr(_res);
17153         CHECK_ACCESS(_res_ptr);
17154         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
17155         FREE(untag_ptr(_res));
17156         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
17157 }
17158
17159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
17160         LDKCVec_SignatureZ o_constr;
17161         o_constr.datalen = (*env)->GetArrayLength(env, o);
17162         if (o_constr.datalen > 0)
17163                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17164         else
17165                 o_constr.data = NULL;
17166         for (size_t i = 0; i < o_constr.datalen; i++) {
17167                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
17168                 LDKSignature o_conv_8_ref;
17169                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
17170                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
17171                 o_constr.data[i] = o_conv_8_ref;
17172         }
17173         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
17174         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
17175         return tag_ptr(ret_conv, true);
17176 }
17177
17178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
17179         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
17180         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
17181         return tag_ptr(ret_conv, true);
17182 }
17183
17184 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17185         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(o);
17186         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
17187         return ret_conv;
17188 }
17189
17190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17191         if (!ptr_is_owned(_res)) return;
17192         void* _res_ptr = untag_ptr(_res);
17193         CHECK_ACCESS(_res_ptr);
17194         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
17195         FREE(untag_ptr(_res));
17196         CResult_CVec_SignatureZNoneZ_free(_res_conv);
17197 }
17198
17199 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
17200         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
17201         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
17202         return tag_ptr(ret_conv, true);
17203 }
17204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17205         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(arg);
17206         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
17207         return ret_conv;
17208 }
17209
17210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17211         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(orig);
17212         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
17213         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
17214         return tag_ptr(ret_conv, true);
17215 }
17216
17217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17218         LDKShutdownScript o_conv;
17219         o_conv.inner = untag_ptr(o);
17220         o_conv.is_owned = ptr_is_owned(o);
17221         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17222         o_conv = ShutdownScript_clone(&o_conv);
17223         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
17224         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
17225         return tag_ptr(ret_conv, true);
17226 }
17227
17228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17229         void* e_ptr = untag_ptr(e);
17230         CHECK_ACCESS(e_ptr);
17231         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17232         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17233         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
17234         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
17235         return tag_ptr(ret_conv, true);
17236 }
17237
17238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17239         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(o);
17240         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
17241         return ret_conv;
17242 }
17243
17244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17245         if (!ptr_is_owned(_res)) return;
17246         void* _res_ptr = untag_ptr(_res);
17247         CHECK_ACCESS(_res_ptr);
17248         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
17249         FREE(untag_ptr(_res));
17250         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
17251 }
17252
17253 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
17254         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
17255         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
17256         return tag_ptr(ret_conv, true);
17257 }
17258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17259         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(arg);
17260         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
17261         return ret_conv;
17262 }
17263
17264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17265         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(orig);
17266         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
17267         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
17268         return tag_ptr(ret_conv, true);
17269 }
17270
17271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17272         LDKShutdownScript o_conv;
17273         o_conv.inner = untag_ptr(o);
17274         o_conv.is_owned = ptr_is_owned(o);
17275         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17276         o_conv = ShutdownScript_clone(&o_conv);
17277         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
17278         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
17279         return tag_ptr(ret_conv, true);
17280 }
17281
17282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17283         LDKInvalidShutdownScript e_conv;
17284         e_conv.inner = untag_ptr(e);
17285         e_conv.is_owned = ptr_is_owned(e);
17286         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17287         e_conv = InvalidShutdownScript_clone(&e_conv);
17288         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
17289         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
17290         return tag_ptr(ret_conv, true);
17291 }
17292
17293 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17294         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(o);
17295         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
17296         return ret_conv;
17297 }
17298
17299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17300         if (!ptr_is_owned(_res)) return;
17301         void* _res_ptr = untag_ptr(_res);
17302         CHECK_ACCESS(_res_ptr);
17303         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
17304         FREE(untag_ptr(_res));
17305         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
17306 }
17307
17308 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
17309         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
17310         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
17311         return tag_ptr(ret_conv, true);
17312 }
17313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17314         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(arg);
17315         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
17316         return ret_conv;
17317 }
17318
17319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17320         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(orig);
17321         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
17322         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
17323         return tag_ptr(ret_conv, true);
17324 }
17325
17326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17327         LDKBlindedPayInfo o_conv;
17328         o_conv.inner = untag_ptr(o);
17329         o_conv.is_owned = ptr_is_owned(o);
17330         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17331         o_conv = BlindedPayInfo_clone(&o_conv);
17332         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
17333         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_ok(o_conv);
17334         return tag_ptr(ret_conv, true);
17335 }
17336
17337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17338         void* e_ptr = untag_ptr(e);
17339         CHECK_ACCESS(e_ptr);
17340         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17341         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17342         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
17343         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_err(e_conv);
17344         return tag_ptr(ret_conv, true);
17345 }
17346
17347 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17348         LDKCResult_BlindedPayInfoDecodeErrorZ* o_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(o);
17349         jboolean ret_conv = CResult_BlindedPayInfoDecodeErrorZ_is_ok(o_conv);
17350         return ret_conv;
17351 }
17352
17353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17354         if (!ptr_is_owned(_res)) return;
17355         void* _res_ptr = untag_ptr(_res);
17356         CHECK_ACCESS(_res_ptr);
17357         LDKCResult_BlindedPayInfoDecodeErrorZ _res_conv = *(LDKCResult_BlindedPayInfoDecodeErrorZ*)(_res_ptr);
17358         FREE(untag_ptr(_res));
17359         CResult_BlindedPayInfoDecodeErrorZ_free(_res_conv);
17360 }
17361
17362 static inline uint64_t CResult_BlindedPayInfoDecodeErrorZ_clone_ptr(LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR arg) {
17363         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
17364         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_clone(arg);
17365         return tag_ptr(ret_conv, true);
17366 }
17367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17368         LDKCResult_BlindedPayInfoDecodeErrorZ* arg_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(arg);
17369         int64_t ret_conv = CResult_BlindedPayInfoDecodeErrorZ_clone_ptr(arg_conv);
17370         return ret_conv;
17371 }
17372
17373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPayInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17374         LDKCResult_BlindedPayInfoDecodeErrorZ* orig_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(orig);
17375         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
17376         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_clone(orig_conv);
17377         return tag_ptr(ret_conv, true);
17378 }
17379
17380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17381         void* o_ptr = untag_ptr(o);
17382         CHECK_ACCESS(o_ptr);
17383         LDKWriteableScore o_conv = *(LDKWriteableScore*)(o_ptr);
17384         if (o_conv.free == LDKWriteableScore_JCalls_free) {
17385                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17386                 LDKWriteableScore_JCalls_cloned(&o_conv);
17387         }
17388         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
17389         *ret_copy = COption_WriteableScoreZ_some(o_conv);
17390         int64_t ret_ref = tag_ptr(ret_copy, true);
17391         return ret_ref;
17392 }
17393
17394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1none(JNIEnv *env, jclass clz) {
17395         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
17396         *ret_copy = COption_WriteableScoreZ_none();
17397         int64_t ret_ref = tag_ptr(ret_copy, true);
17398         return ret_ref;
17399 }
17400
17401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17402         if (!ptr_is_owned(_res)) return;
17403         void* _res_ptr = untag_ptr(_res);
17404         CHECK_ACCESS(_res_ptr);
17405         LDKCOption_WriteableScoreZ _res_conv = *(LDKCOption_WriteableScoreZ*)(_res_ptr);
17406         FREE(untag_ptr(_res));
17407         COption_WriteableScoreZ_free(_res_conv);
17408 }
17409
17410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
17411         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17412         *ret_conv = CResult_NoneErrorZ_ok();
17413         return tag_ptr(ret_conv, true);
17414 }
17415
17416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17417         LDKIOError e_conv = LDKIOError_from_java(env, e);
17418         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17419         *ret_conv = CResult_NoneErrorZ_err(e_conv);
17420         return tag_ptr(ret_conv, true);
17421 }
17422
17423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17424         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)untag_ptr(o);
17425         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
17426         return ret_conv;
17427 }
17428
17429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17430         if (!ptr_is_owned(_res)) return;
17431         void* _res_ptr = untag_ptr(_res);
17432         CHECK_ACCESS(_res_ptr);
17433         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
17434         FREE(untag_ptr(_res));
17435         CResult_NoneErrorZ_free(_res_conv);
17436 }
17437
17438 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
17439         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17440         *ret_conv = CResult_NoneErrorZ_clone(arg);
17441         return tag_ptr(ret_conv, true);
17442 }
17443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17444         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)untag_ptr(arg);
17445         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
17446         return ret_conv;
17447 }
17448
17449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17450         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)untag_ptr(orig);
17451         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17452         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
17453         return tag_ptr(ret_conv, true);
17454 }
17455
17456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17457         LDKCVec_ChannelDetailsZ _res_constr;
17458         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17459         if (_res_constr.datalen > 0)
17460                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
17461         else
17462                 _res_constr.data = NULL;
17463         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17464         for (size_t q = 0; q < _res_constr.datalen; q++) {
17465                 int64_t _res_conv_16 = _res_vals[q];
17466                 LDKChannelDetails _res_conv_16_conv;
17467                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
17468                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
17469                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17470                 _res_constr.data[q] = _res_conv_16_conv;
17471         }
17472         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17473         CVec_ChannelDetailsZ_free(_res_constr);
17474 }
17475
17476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17477         LDKRoute o_conv;
17478         o_conv.inner = untag_ptr(o);
17479         o_conv.is_owned = ptr_is_owned(o);
17480         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17481         o_conv = Route_clone(&o_conv);
17482         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17483         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
17484         return tag_ptr(ret_conv, true);
17485 }
17486
17487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17488         LDKLightningError e_conv;
17489         e_conv.inner = untag_ptr(e);
17490         e_conv.is_owned = ptr_is_owned(e);
17491         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17492         e_conv = LightningError_clone(&e_conv);
17493         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17494         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
17495         return tag_ptr(ret_conv, true);
17496 }
17497
17498 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17499         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(o);
17500         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
17501         return ret_conv;
17502 }
17503
17504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17505         if (!ptr_is_owned(_res)) return;
17506         void* _res_ptr = untag_ptr(_res);
17507         CHECK_ACCESS(_res_ptr);
17508         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
17509         FREE(untag_ptr(_res));
17510         CResult_RouteLightningErrorZ_free(_res_conv);
17511 }
17512
17513 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
17514         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17515         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
17516         return tag_ptr(ret_conv, true);
17517 }
17518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17519         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(arg);
17520         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
17521         return ret_conv;
17522 }
17523
17524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17525         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(orig);
17526         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17527         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
17528         return tag_ptr(ret_conv, true);
17529 }
17530
17531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17532         LDKInFlightHtlcs o_conv;
17533         o_conv.inner = untag_ptr(o);
17534         o_conv.is_owned = ptr_is_owned(o);
17535         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17536         o_conv = InFlightHtlcs_clone(&o_conv);
17537         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17538         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_ok(o_conv);
17539         return tag_ptr(ret_conv, true);
17540 }
17541
17542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17543         void* e_ptr = untag_ptr(e);
17544         CHECK_ACCESS(e_ptr);
17545         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17546         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17547         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17548         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_err(e_conv);
17549         return tag_ptr(ret_conv, true);
17550 }
17551
17552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17553         LDKCResult_InFlightHtlcsDecodeErrorZ* o_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(o);
17554         jboolean ret_conv = CResult_InFlightHtlcsDecodeErrorZ_is_ok(o_conv);
17555         return ret_conv;
17556 }
17557
17558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17559         if (!ptr_is_owned(_res)) return;
17560         void* _res_ptr = untag_ptr(_res);
17561         CHECK_ACCESS(_res_ptr);
17562         LDKCResult_InFlightHtlcsDecodeErrorZ _res_conv = *(LDKCResult_InFlightHtlcsDecodeErrorZ*)(_res_ptr);
17563         FREE(untag_ptr(_res));
17564         CResult_InFlightHtlcsDecodeErrorZ_free(_res_conv);
17565 }
17566
17567 static inline uint64_t CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR arg) {
17568         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17569         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(arg);
17570         return tag_ptr(ret_conv, true);
17571 }
17572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17573         LDKCResult_InFlightHtlcsDecodeErrorZ* arg_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(arg);
17574         int64_t ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(arg_conv);
17575         return ret_conv;
17576 }
17577
17578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17579         LDKCResult_InFlightHtlcsDecodeErrorZ* orig_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(orig);
17580         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17581         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(orig_conv);
17582         return tag_ptr(ret_conv, true);
17583 }
17584
17585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17586         LDKRouteHop o_conv;
17587         o_conv.inner = untag_ptr(o);
17588         o_conv.is_owned = ptr_is_owned(o);
17589         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17590         o_conv = RouteHop_clone(&o_conv);
17591         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17592         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
17593         return tag_ptr(ret_conv, true);
17594 }
17595
17596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17597         void* e_ptr = untag_ptr(e);
17598         CHECK_ACCESS(e_ptr);
17599         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17600         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17601         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17602         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
17603         return tag_ptr(ret_conv, true);
17604 }
17605
17606 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17607         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(o);
17608         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
17609         return ret_conv;
17610 }
17611
17612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17613         if (!ptr_is_owned(_res)) return;
17614         void* _res_ptr = untag_ptr(_res);
17615         CHECK_ACCESS(_res_ptr);
17616         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
17617         FREE(untag_ptr(_res));
17618         CResult_RouteHopDecodeErrorZ_free(_res_conv);
17619 }
17620
17621 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
17622         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17623         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
17624         return tag_ptr(ret_conv, true);
17625 }
17626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17627         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(arg);
17628         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
17629         return ret_conv;
17630 }
17631
17632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17633         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(orig);
17634         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17635         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
17636         return tag_ptr(ret_conv, true);
17637 }
17638
17639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BlindedHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17640         LDKCVec_BlindedHopZ _res_constr;
17641         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17642         if (_res_constr.datalen > 0)
17643                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
17644         else
17645                 _res_constr.data = NULL;
17646         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17647         for (size_t m = 0; m < _res_constr.datalen; m++) {
17648                 int64_t _res_conv_12 = _res_vals[m];
17649                 LDKBlindedHop _res_conv_12_conv;
17650                 _res_conv_12_conv.inner = untag_ptr(_res_conv_12);
17651                 _res_conv_12_conv.is_owned = ptr_is_owned(_res_conv_12);
17652                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv);
17653                 _res_constr.data[m] = _res_conv_12_conv;
17654         }
17655         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17656         CVec_BlindedHopZ_free(_res_constr);
17657 }
17658
17659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17660         LDKBlindedTail o_conv;
17661         o_conv.inner = untag_ptr(o);
17662         o_conv.is_owned = ptr_is_owned(o);
17663         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17664         o_conv = BlindedTail_clone(&o_conv);
17665         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17666         *ret_conv = CResult_BlindedTailDecodeErrorZ_ok(o_conv);
17667         return tag_ptr(ret_conv, true);
17668 }
17669
17670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17671         void* e_ptr = untag_ptr(e);
17672         CHECK_ACCESS(e_ptr);
17673         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17674         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17675         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17676         *ret_conv = CResult_BlindedTailDecodeErrorZ_err(e_conv);
17677         return tag_ptr(ret_conv, true);
17678 }
17679
17680 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17681         LDKCResult_BlindedTailDecodeErrorZ* o_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(o);
17682         jboolean ret_conv = CResult_BlindedTailDecodeErrorZ_is_ok(o_conv);
17683         return ret_conv;
17684 }
17685
17686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17687         if (!ptr_is_owned(_res)) return;
17688         void* _res_ptr = untag_ptr(_res);
17689         CHECK_ACCESS(_res_ptr);
17690         LDKCResult_BlindedTailDecodeErrorZ _res_conv = *(LDKCResult_BlindedTailDecodeErrorZ*)(_res_ptr);
17691         FREE(untag_ptr(_res));
17692         CResult_BlindedTailDecodeErrorZ_free(_res_conv);
17693 }
17694
17695 static inline uint64_t CResult_BlindedTailDecodeErrorZ_clone_ptr(LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR arg) {
17696         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17697         *ret_conv = CResult_BlindedTailDecodeErrorZ_clone(arg);
17698         return tag_ptr(ret_conv, true);
17699 }
17700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17701         LDKCResult_BlindedTailDecodeErrorZ* arg_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(arg);
17702         int64_t ret_conv = CResult_BlindedTailDecodeErrorZ_clone_ptr(arg_conv);
17703         return ret_conv;
17704 }
17705
17706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedTailDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17707         LDKCResult_BlindedTailDecodeErrorZ* orig_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(orig);
17708         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17709         *ret_conv = CResult_BlindedTailDecodeErrorZ_clone(orig_conv);
17710         return tag_ptr(ret_conv, true);
17711 }
17712
17713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17714         LDKCVec_RouteHopZ _res_constr;
17715         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17716         if (_res_constr.datalen > 0)
17717                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17718         else
17719                 _res_constr.data = NULL;
17720         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17721         for (size_t k = 0; k < _res_constr.datalen; k++) {
17722                 int64_t _res_conv_10 = _res_vals[k];
17723                 LDKRouteHop _res_conv_10_conv;
17724                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
17725                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
17726                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
17727                 _res_constr.data[k] = _res_conv_10_conv;
17728         }
17729         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17730         CVec_RouteHopZ_free(_res_constr);
17731 }
17732
17733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PathZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17734         LDKCVec_PathZ _res_constr;
17735         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17736         if (_res_constr.datalen > 0)
17737                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
17738         else
17739                 _res_constr.data = NULL;
17740         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17741         for (size_t g = 0; g < _res_constr.datalen; g++) {
17742                 int64_t _res_conv_6 = _res_vals[g];
17743                 LDKPath _res_conv_6_conv;
17744                 _res_conv_6_conv.inner = untag_ptr(_res_conv_6);
17745                 _res_conv_6_conv.is_owned = ptr_is_owned(_res_conv_6);
17746                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_6_conv);
17747                 _res_constr.data[g] = _res_conv_6_conv;
17748         }
17749         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17750         CVec_PathZ_free(_res_constr);
17751 }
17752
17753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17754         LDKRoute o_conv;
17755         o_conv.inner = untag_ptr(o);
17756         o_conv.is_owned = ptr_is_owned(o);
17757         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17758         o_conv = Route_clone(&o_conv);
17759         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17760         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
17761         return tag_ptr(ret_conv, true);
17762 }
17763
17764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17765         void* e_ptr = untag_ptr(e);
17766         CHECK_ACCESS(e_ptr);
17767         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17768         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17769         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17770         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
17771         return tag_ptr(ret_conv, true);
17772 }
17773
17774 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17775         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(o);
17776         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
17777         return ret_conv;
17778 }
17779
17780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17781         if (!ptr_is_owned(_res)) return;
17782         void* _res_ptr = untag_ptr(_res);
17783         CHECK_ACCESS(_res_ptr);
17784         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
17785         FREE(untag_ptr(_res));
17786         CResult_RouteDecodeErrorZ_free(_res_conv);
17787 }
17788
17789 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
17790         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17791         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
17792         return tag_ptr(ret_conv, true);
17793 }
17794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17795         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(arg);
17796         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
17797         return ret_conv;
17798 }
17799
17800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17801         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(orig);
17802         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17803         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
17804         return tag_ptr(ret_conv, true);
17805 }
17806
17807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17808         LDKRouteParameters o_conv;
17809         o_conv.inner = untag_ptr(o);
17810         o_conv.is_owned = ptr_is_owned(o);
17811         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17812         o_conv = RouteParameters_clone(&o_conv);
17813         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17814         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
17815         return tag_ptr(ret_conv, true);
17816 }
17817
17818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17819         void* e_ptr = untag_ptr(e);
17820         CHECK_ACCESS(e_ptr);
17821         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17822         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17823         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17824         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
17825         return tag_ptr(ret_conv, true);
17826 }
17827
17828 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17829         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(o);
17830         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
17831         return ret_conv;
17832 }
17833
17834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17835         if (!ptr_is_owned(_res)) return;
17836         void* _res_ptr = untag_ptr(_res);
17837         CHECK_ACCESS(_res_ptr);
17838         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
17839         FREE(untag_ptr(_res));
17840         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
17841 }
17842
17843 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
17844         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17845         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
17846         return tag_ptr(ret_conv, true);
17847 }
17848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17849         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(arg);
17850         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
17851         return ret_conv;
17852 }
17853
17854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17855         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(orig);
17856         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17857         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
17858         return tag_ptr(ret_conv, true);
17859 }
17860
17861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17862         LDKCVec_u64Z _res_constr;
17863         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17864         if (_res_constr.datalen > 0)
17865                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17866         else
17867                 _res_constr.data = NULL;
17868         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17869         for (size_t g = 0; g < _res_constr.datalen; g++) {
17870                 int64_t _res_conv_6 = _res_vals[g];
17871                 _res_constr.data[g] = _res_conv_6;
17872         }
17873         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17874         CVec_u64Z_free(_res_constr);
17875 }
17876
17877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17878         LDKPaymentParameters o_conv;
17879         o_conv.inner = untag_ptr(o);
17880         o_conv.is_owned = ptr_is_owned(o);
17881         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17882         o_conv = PaymentParameters_clone(&o_conv);
17883         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17884         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
17885         return tag_ptr(ret_conv, true);
17886 }
17887
17888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17889         void* e_ptr = untag_ptr(e);
17890         CHECK_ACCESS(e_ptr);
17891         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17892         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17893         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17894         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
17895         return tag_ptr(ret_conv, true);
17896 }
17897
17898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17899         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(o);
17900         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
17901         return ret_conv;
17902 }
17903
17904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17905         if (!ptr_is_owned(_res)) return;
17906         void* _res_ptr = untag_ptr(_res);
17907         CHECK_ACCESS(_res_ptr);
17908         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
17909         FREE(untag_ptr(_res));
17910         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
17911 }
17912
17913 static inline uint64_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
17914         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17915         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
17916         return tag_ptr(ret_conv, true);
17917 }
17918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17919         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(arg);
17920         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
17921         return ret_conv;
17922 }
17923
17924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17925         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(orig);
17926         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17927         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
17928         return tag_ptr(ret_conv, true);
17929 }
17930
17931 static inline uint64_t C2Tuple_BlindedPayInfoBlindedPathZ_clone_ptr(LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR arg) {
17932         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
17933         *ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone(arg);
17934         return tag_ptr(ret_conv, true);
17935 }
17936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlindedPayInfoBlindedPathZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17937         LDKC2Tuple_BlindedPayInfoBlindedPathZ* arg_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(arg);
17938         int64_t ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone_ptr(arg_conv);
17939         return ret_conv;
17940 }
17941
17942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlindedPayInfoBlindedPathZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17943         LDKC2Tuple_BlindedPayInfoBlindedPathZ* orig_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(orig);
17944         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
17945         *ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone(orig_conv);
17946         return tag_ptr(ret_conv, true);
17947 }
17948
17949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlindedPayInfoBlindedPathZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17950         LDKBlindedPayInfo a_conv;
17951         a_conv.inner = untag_ptr(a);
17952         a_conv.is_owned = ptr_is_owned(a);
17953         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17954         a_conv = BlindedPayInfo_clone(&a_conv);
17955         LDKBlindedPath b_conv;
17956         b_conv.inner = untag_ptr(b);
17957         b_conv.is_owned = ptr_is_owned(b);
17958         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17959         b_conv = BlindedPath_clone(&b_conv);
17960         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
17961         *ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_new(a_conv, b_conv);
17962         return tag_ptr(ret_conv, true);
17963 }
17964
17965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlindedPayInfoBlindedPathZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17966         if (!ptr_is_owned(_res)) return;
17967         void* _res_ptr = untag_ptr(_res);
17968         CHECK_ACCESS(_res_ptr);
17969         LDKC2Tuple_BlindedPayInfoBlindedPathZ _res_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(_res_ptr);
17970         FREE(untag_ptr(_res));
17971         C2Tuple_BlindedPayInfoBlindedPathZ_free(_res_conv);
17972 }
17973
17974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlindedPayInfoBlindedPathZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17975         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ _res_constr;
17976         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17977         if (_res_constr.datalen > 0)
17978                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ Elements");
17979         else
17980                 _res_constr.data = NULL;
17981         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17982         for (size_t l = 0; l < _res_constr.datalen; l++) {
17983                 int64_t _res_conv_37 = _res_vals[l];
17984                 void* _res_conv_37_ptr = untag_ptr(_res_conv_37);
17985                 CHECK_ACCESS(_res_conv_37_ptr);
17986                 LDKC2Tuple_BlindedPayInfoBlindedPathZ _res_conv_37_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(_res_conv_37_ptr);
17987                 FREE(untag_ptr(_res_conv_37));
17988                 _res_constr.data[l] = _res_conv_37_conv;
17989         }
17990         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17991         CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(_res_constr);
17992 }
17993
17994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17995         LDKCVec_RouteHintZ _res_constr;
17996         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17997         if (_res_constr.datalen > 0)
17998                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
17999         else
18000                 _res_constr.data = NULL;
18001         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18002         for (size_t l = 0; l < _res_constr.datalen; l++) {
18003                 int64_t _res_conv_11 = _res_vals[l];
18004                 LDKRouteHint _res_conv_11_conv;
18005                 _res_conv_11_conv.inner = untag_ptr(_res_conv_11);
18006                 _res_conv_11_conv.is_owned = ptr_is_owned(_res_conv_11);
18007                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
18008                 _res_constr.data[l] = _res_conv_11_conv;
18009         }
18010         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18011         CVec_RouteHintZ_free(_res_constr);
18012 }
18013
18014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18015         LDKCVec_RouteHintHopZ _res_constr;
18016         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18017         if (_res_constr.datalen > 0)
18018                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
18019         else
18020                 _res_constr.data = NULL;
18021         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18022         for (size_t o = 0; o < _res_constr.datalen; o++) {
18023                 int64_t _res_conv_14 = _res_vals[o];
18024                 LDKRouteHintHop _res_conv_14_conv;
18025                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
18026                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
18027                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
18028                 _res_constr.data[o] = _res_conv_14_conv;
18029         }
18030         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18031         CVec_RouteHintHopZ_free(_res_constr);
18032 }
18033
18034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18035         LDKRouteHint o_conv;
18036         o_conv.inner = untag_ptr(o);
18037         o_conv.is_owned = ptr_is_owned(o);
18038         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18039         o_conv = RouteHint_clone(&o_conv);
18040         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18041         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
18042         return tag_ptr(ret_conv, true);
18043 }
18044
18045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18046         void* e_ptr = untag_ptr(e);
18047         CHECK_ACCESS(e_ptr);
18048         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18049         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18050         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18051         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
18052         return tag_ptr(ret_conv, true);
18053 }
18054
18055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18056         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(o);
18057         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
18058         return ret_conv;
18059 }
18060
18061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18062         if (!ptr_is_owned(_res)) return;
18063         void* _res_ptr = untag_ptr(_res);
18064         CHECK_ACCESS(_res_ptr);
18065         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
18066         FREE(untag_ptr(_res));
18067         CResult_RouteHintDecodeErrorZ_free(_res_conv);
18068 }
18069
18070 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
18071         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18072         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
18073         return tag_ptr(ret_conv, true);
18074 }
18075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18076         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(arg);
18077         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
18078         return ret_conv;
18079 }
18080
18081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18082         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(orig);
18083         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18084         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
18085         return tag_ptr(ret_conv, true);
18086 }
18087
18088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18089         LDKRouteHintHop o_conv;
18090         o_conv.inner = untag_ptr(o);
18091         o_conv.is_owned = ptr_is_owned(o);
18092         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18093         o_conv = RouteHintHop_clone(&o_conv);
18094         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18095         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
18096         return tag_ptr(ret_conv, true);
18097 }
18098
18099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18100         void* e_ptr = untag_ptr(e);
18101         CHECK_ACCESS(e_ptr);
18102         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18103         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18104         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18105         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
18106         return tag_ptr(ret_conv, true);
18107 }
18108
18109 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18110         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(o);
18111         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
18112         return ret_conv;
18113 }
18114
18115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18116         if (!ptr_is_owned(_res)) return;
18117         void* _res_ptr = untag_ptr(_res);
18118         CHECK_ACCESS(_res_ptr);
18119         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
18120         FREE(untag_ptr(_res));
18121         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
18122 }
18123
18124 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
18125         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18126         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
18127         return tag_ptr(ret_conv, true);
18128 }
18129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18130         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(arg);
18131         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
18132         return ret_conv;
18133 }
18134
18135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18136         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(orig);
18137         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18138         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
18139         return tag_ptr(ret_conv, true);
18140 }
18141
18142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18143         LDKCVec_PublicKeyZ _res_constr;
18144         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18145         if (_res_constr.datalen > 0)
18146                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
18147         else
18148                 _res_constr.data = NULL;
18149         for (size_t i = 0; i < _res_constr.datalen; i++) {
18150                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
18151                 LDKPublicKey _res_conv_8_ref;
18152                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
18153                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
18154                 _res_constr.data[i] = _res_conv_8_ref;
18155         }
18156         CVec_PublicKeyZ_free(_res_constr);
18157 }
18158
18159 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
18160         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18161         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
18162         return tag_ptr(ret_conv, true);
18163 }
18164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18165         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(arg);
18166         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
18167         return ret_conv;
18168 }
18169
18170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18171         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(orig);
18172         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18173         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
18174         return tag_ptr(ret_conv, true);
18175 }
18176
18177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
18178         LDKTransaction b_ref;
18179         b_ref.datalen = (*env)->GetArrayLength(env, b);
18180         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
18181         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
18182         b_ref.data_is_owned = true;
18183         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18184         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
18185         return tag_ptr(ret_conv, true);
18186 }
18187
18188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18189         if (!ptr_is_owned(_res)) return;
18190         void* _res_ptr = untag_ptr(_res);
18191         CHECK_ACCESS(_res_ptr);
18192         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
18193         FREE(untag_ptr(_res));
18194         C2Tuple_usizeTransactionZ_free(_res_conv);
18195 }
18196
18197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18198         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
18199         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18200         if (_res_constr.datalen > 0)
18201                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
18202         else
18203                 _res_constr.data = NULL;
18204         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18205         for (size_t c = 0; c < _res_constr.datalen; c++) {
18206                 int64_t _res_conv_28 = _res_vals[c];
18207                 void* _res_conv_28_ptr = untag_ptr(_res_conv_28);
18208                 CHECK_ACCESS(_res_conv_28_ptr);
18209                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
18210                 FREE(untag_ptr(_res_conv_28));
18211                 _res_constr.data[c] = _res_conv_28_conv;
18212         }
18213         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18214         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
18215 }
18216
18217 static inline uint64_t C2Tuple_TxidBlockHashZ_clone_ptr(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR arg) {
18218         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18219         *ret_conv = C2Tuple_TxidBlockHashZ_clone(arg);
18220         return tag_ptr(ret_conv, true);
18221 }
18222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18223         LDKC2Tuple_TxidBlockHashZ* arg_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(arg);
18224         int64_t ret_conv = C2Tuple_TxidBlockHashZ_clone_ptr(arg_conv);
18225         return ret_conv;
18226 }
18227
18228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18229         LDKC2Tuple_TxidBlockHashZ* orig_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(orig);
18230         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18231         *ret_conv = C2Tuple_TxidBlockHashZ_clone(orig_conv);
18232         return tag_ptr(ret_conv, true);
18233 }
18234
18235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
18236         LDKThirtyTwoBytes a_ref;
18237         CHECK((*env)->GetArrayLength(env, a) == 32);
18238         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18239         LDKThirtyTwoBytes b_ref;
18240         CHECK((*env)->GetArrayLength(env, b) == 32);
18241         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
18242         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18243         *ret_conv = C2Tuple_TxidBlockHashZ_new(a_ref, b_ref);
18244         return tag_ptr(ret_conv, true);
18245 }
18246
18247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18248         if (!ptr_is_owned(_res)) return;
18249         void* _res_ptr = untag_ptr(_res);
18250         CHECK_ACCESS(_res_ptr);
18251         LDKC2Tuple_TxidBlockHashZ _res_conv = *(LDKC2Tuple_TxidBlockHashZ*)(_res_ptr);
18252         FREE(untag_ptr(_res));
18253         C2Tuple_TxidBlockHashZ_free(_res_conv);
18254 }
18255
18256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidBlockHashZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18257         LDKCVec_C2Tuple_TxidBlockHashZZ _res_constr;
18258         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18259         if (_res_constr.datalen > 0)
18260                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKCVec_C2Tuple_TxidBlockHashZZ Elements");
18261         else
18262                 _res_constr.data = NULL;
18263         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18264         for (size_t z = 0; z < _res_constr.datalen; z++) {
18265                 int64_t _res_conv_25 = _res_vals[z];
18266                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
18267                 CHECK_ACCESS(_res_conv_25_ptr);
18268                 LDKC2Tuple_TxidBlockHashZ _res_conv_25_conv = *(LDKC2Tuple_TxidBlockHashZ*)(_res_conv_25_ptr);
18269                 FREE(untag_ptr(_res_conv_25));
18270                 _res_constr.data[z] = _res_conv_25_conv;
18271         }
18272         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18273         CVec_C2Tuple_TxidBlockHashZZ_free(_res_constr);
18274 }
18275
18276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18277         LDKCVec_MonitorEventZ _res_constr;
18278         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18279         if (_res_constr.datalen > 0)
18280                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18281         else
18282                 _res_constr.data = NULL;
18283         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18284         for (size_t o = 0; o < _res_constr.datalen; o++) {
18285                 int64_t _res_conv_14 = _res_vals[o];
18286                 void* _res_conv_14_ptr = untag_ptr(_res_conv_14);
18287                 CHECK_ACCESS(_res_conv_14_ptr);
18288                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
18289                 FREE(untag_ptr(_res_conv_14));
18290                 _res_constr.data[o] = _res_conv_14_conv;
18291         }
18292         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18293         CVec_MonitorEventZ_free(_res_constr);
18294 }
18295
18296 static inline uint64_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
18297         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18298         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
18299         return tag_ptr(ret_conv, true);
18300 }
18301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18302         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(arg);
18303         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
18304         return ret_conv;
18305 }
18306
18307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18308         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(orig);
18309         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18310         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
18311         return tag_ptr(ret_conv, true);
18312 }
18313
18314 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) {
18315         LDKOutPoint a_conv;
18316         a_conv.inner = untag_ptr(a);
18317         a_conv.is_owned = ptr_is_owned(a);
18318         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18319         a_conv = OutPoint_clone(&a_conv);
18320         LDKCVec_MonitorEventZ b_constr;
18321         b_constr.datalen = (*env)->GetArrayLength(env, b);
18322         if (b_constr.datalen > 0)
18323                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18324         else
18325                 b_constr.data = NULL;
18326         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
18327         for (size_t o = 0; o < b_constr.datalen; o++) {
18328                 int64_t b_conv_14 = b_vals[o];
18329                 void* b_conv_14_ptr = untag_ptr(b_conv_14);
18330                 CHECK_ACCESS(b_conv_14_ptr);
18331                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
18332                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(b_conv_14));
18333                 b_constr.data[o] = b_conv_14_conv;
18334         }
18335         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
18336         LDKPublicKey c_ref;
18337         CHECK((*env)->GetArrayLength(env, c) == 33);
18338         (*env)->GetByteArrayRegion(env, c, 0, 33, c_ref.compressed_form);
18339         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18340         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
18341         return tag_ptr(ret_conv, true);
18342 }
18343
18344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18345         if (!ptr_is_owned(_res)) return;
18346         void* _res_ptr = untag_ptr(_res);
18347         CHECK_ACCESS(_res_ptr);
18348         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
18349         FREE(untag_ptr(_res));
18350         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
18351 }
18352
18353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18354         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
18355         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18356         if (_res_constr.datalen > 0)
18357                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
18358         else
18359                 _res_constr.data = NULL;
18360         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18361         for (size_t x = 0; x < _res_constr.datalen; x++) {
18362                 int64_t _res_conv_49 = _res_vals[x];
18363                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
18364                 CHECK_ACCESS(_res_conv_49_ptr);
18365                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
18366                 FREE(untag_ptr(_res_conv_49));
18367                 _res_constr.data[x] = _res_conv_49_conv;
18368         }
18369         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18370         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
18371 }
18372
18373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18374         LDKFixedPenaltyScorer o_conv;
18375         o_conv.inner = untag_ptr(o);
18376         o_conv.is_owned = ptr_is_owned(o);
18377         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18378         o_conv = FixedPenaltyScorer_clone(&o_conv);
18379         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18380         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
18381         return tag_ptr(ret_conv, true);
18382 }
18383
18384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18385         void* e_ptr = untag_ptr(e);
18386         CHECK_ACCESS(e_ptr);
18387         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18388         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18389         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18390         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
18391         return tag_ptr(ret_conv, true);
18392 }
18393
18394 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18395         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(o);
18396         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
18397         return ret_conv;
18398 }
18399
18400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18401         if (!ptr_is_owned(_res)) return;
18402         void* _res_ptr = untag_ptr(_res);
18403         CHECK_ACCESS(_res_ptr);
18404         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
18405         FREE(untag_ptr(_res));
18406         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
18407 }
18408
18409 static inline uint64_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
18410         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18411         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
18412         return tag_ptr(ret_conv, true);
18413 }
18414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18415         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(arg);
18416         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
18417         return ret_conv;
18418 }
18419
18420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18421         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(orig);
18422         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18423         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
18424         return tag_ptr(ret_conv, true);
18425 }
18426
18427 static inline uint64_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
18428         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18429         *ret_conv = C2Tuple_u64u64Z_clone(arg);
18430         return tag_ptr(ret_conv, true);
18431 }
18432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18433         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(arg);
18434         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
18435         return ret_conv;
18436 }
18437
18438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18439         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(orig);
18440         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18441         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
18442         return tag_ptr(ret_conv, true);
18443 }
18444
18445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
18446         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18447         *ret_conv = C2Tuple_u64u64Z_new(a, b);
18448         return tag_ptr(ret_conv, true);
18449 }
18450
18451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18452         if (!ptr_is_owned(_res)) return;
18453         void* _res_ptr = untag_ptr(_res);
18454         CHECK_ACCESS(_res_ptr);
18455         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
18456         FREE(untag_ptr(_res));
18457         C2Tuple_u64u64Z_free(_res_conv);
18458 }
18459
18460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18461         void* o_ptr = untag_ptr(o);
18462         CHECK_ACCESS(o_ptr);
18463         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
18464         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)untag_ptr(o));
18465         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18466         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
18467         int64_t ret_ref = tag_ptr(ret_copy, true);
18468         return ret_ref;
18469 }
18470
18471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
18472         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18473         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
18474         int64_t ret_ref = tag_ptr(ret_copy, true);
18475         return ret_ref;
18476 }
18477
18478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18479         if (!ptr_is_owned(_res)) return;
18480         void* _res_ptr = untag_ptr(_res);
18481         CHECK_ACCESS(_res_ptr);
18482         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
18483         FREE(untag_ptr(_res));
18484         COption_C2Tuple_u64u64ZZ_free(_res_conv);
18485 }
18486
18487 static inline uint64_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
18488         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18489         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
18490         int64_t ret_ref = tag_ptr(ret_copy, true);
18491         return ret_ref;
18492 }
18493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18494         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(arg);
18495         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
18496         return ret_conv;
18497 }
18498
18499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18500         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(orig);
18501         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18502         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
18503         int64_t ret_ref = tag_ptr(ret_copy, true);
18504         return ret_ref;
18505 }
18506
18507 static inline uint64_t C2Tuple_Z_clone_ptr(LDKC2Tuple_Z *NONNULL_PTR arg) {
18508         LDKC2Tuple_Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_Z), "LDKC2Tuple_Z");
18509         *ret_conv = C2Tuple_Z_clone(arg);
18510         return tag_ptr(ret_conv, true);
18511 }
18512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18513         LDKC2Tuple_Z* arg_conv = (LDKC2Tuple_Z*)untag_ptr(arg);
18514         int64_t ret_conv = C2Tuple_Z_clone_ptr(arg_conv);
18515         return ret_conv;
18516 }
18517
18518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18519         LDKC2Tuple_Z* orig_conv = (LDKC2Tuple_Z*)untag_ptr(orig);
18520         LDKC2Tuple_Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_Z), "LDKC2Tuple_Z");
18521         *ret_conv = C2Tuple_Z_clone(orig_conv);
18522         return tag_ptr(ret_conv, true);
18523 }
18524
18525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1new(JNIEnv *env, jclass clz, int16_tArray a, int16_tArray b) {
18526         LDKEightU16s a_ref;
18527         CHECK((*env)->GetArrayLength(env, a) == 8);
18528         (*env)->GetShortArrayRegion(env, a, 0, 8, a_ref.data);
18529         LDKEightU16s b_ref;
18530         CHECK((*env)->GetArrayLength(env, b) == 8);
18531         (*env)->GetShortArrayRegion(env, b, 0, 8, b_ref.data);
18532         LDKC2Tuple_Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_Z), "LDKC2Tuple_Z");
18533         *ret_conv = C2Tuple_Z_new(a_ref, b_ref);
18534         return tag_ptr(ret_conv, true);
18535 }
18536
18537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18538         if (!ptr_is_owned(_res)) return;
18539         void* _res_ptr = untag_ptr(_res);
18540         CHECK_ACCESS(_res_ptr);
18541         LDKC2Tuple_Z _res_conv = *(LDKC2Tuple_Z*)(_res_ptr);
18542         FREE(untag_ptr(_res));
18543         C2Tuple_Z_free(_res_conv);
18544 }
18545
18546 static inline uint64_t C2Tuple__u168_u168Z_clone_ptr(LDKC2Tuple__u168_u168Z *NONNULL_PTR arg) {
18547         LDKC2Tuple__u168_u168Z* ret_conv = MALLOC(sizeof(LDKC2Tuple__u168_u168Z), "LDKC2Tuple__u168_u168Z");
18548         *ret_conv = C2Tuple__u168_u168Z_clone(arg);
18549         return tag_ptr(ret_conv, true);
18550 }
18551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18552         LDKC2Tuple__u168_u168Z* arg_conv = (LDKC2Tuple__u168_u168Z*)untag_ptr(arg);
18553         int64_t ret_conv = C2Tuple__u168_u168Z_clone_ptr(arg_conv);
18554         return ret_conv;
18555 }
18556
18557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18558         LDKC2Tuple__u168_u168Z* orig_conv = (LDKC2Tuple__u168_u168Z*)untag_ptr(orig);
18559         LDKC2Tuple__u168_u168Z* ret_conv = MALLOC(sizeof(LDKC2Tuple__u168_u168Z), "LDKC2Tuple__u168_u168Z");
18560         *ret_conv = C2Tuple__u168_u168Z_clone(orig_conv);
18561         return tag_ptr(ret_conv, true);
18562 }
18563
18564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1new(JNIEnv *env, jclass clz, int16_tArray a, int16_tArray b) {
18565         LDKEightU16s a_ref;
18566         CHECK((*env)->GetArrayLength(env, a) == 8);
18567         (*env)->GetShortArrayRegion(env, a, 0, 8, a_ref.data);
18568         LDKEightU16s b_ref;
18569         CHECK((*env)->GetArrayLength(env, b) == 8);
18570         (*env)->GetShortArrayRegion(env, b, 0, 8, b_ref.data);
18571         LDKC2Tuple__u168_u168Z* ret_conv = MALLOC(sizeof(LDKC2Tuple__u168_u168Z), "LDKC2Tuple__u168_u168Z");
18572         *ret_conv = C2Tuple__u168_u168Z_new(a_ref, b_ref);
18573         return tag_ptr(ret_conv, true);
18574 }
18575
18576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1_1u168_1u168Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18577         if (!ptr_is_owned(_res)) return;
18578         void* _res_ptr = untag_ptr(_res);
18579         CHECK_ACCESS(_res_ptr);
18580         LDKC2Tuple__u168_u168Z _res_conv = *(LDKC2Tuple__u168_u168Z*)(_res_ptr);
18581         FREE(untag_ptr(_res));
18582         C2Tuple__u168_u168Z_free(_res_conv);
18583 }
18584
18585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18586         void* o_ptr = untag_ptr(o);
18587         CHECK_ACCESS(o_ptr);
18588         LDKC2Tuple__u168_u168Z o_conv = *(LDKC2Tuple__u168_u168Z*)(o_ptr);
18589         o_conv = C2Tuple__u168_u168Z_clone((LDKC2Tuple__u168_u168Z*)untag_ptr(o));
18590         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
18591         *ret_copy = COption_C2Tuple_EightU16sEightU16sZZ_some(o_conv);
18592         int64_t ret_ref = tag_ptr(ret_copy, true);
18593         return ret_ref;
18594 }
18595
18596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1none(JNIEnv *env, jclass clz) {
18597         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
18598         *ret_copy = COption_C2Tuple_EightU16sEightU16sZZ_none();
18599         int64_t ret_ref = tag_ptr(ret_copy, true);
18600         return ret_ref;
18601 }
18602
18603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18604         if (!ptr_is_owned(_res)) return;
18605         void* _res_ptr = untag_ptr(_res);
18606         CHECK_ACCESS(_res_ptr);
18607         LDKCOption_C2Tuple_EightU16sEightU16sZZ _res_conv = *(LDKCOption_C2Tuple_EightU16sEightU16sZZ*)(_res_ptr);
18608         FREE(untag_ptr(_res));
18609         COption_C2Tuple_EightU16sEightU16sZZ_free(_res_conv);
18610 }
18611
18612 static inline uint64_t COption_C2Tuple_EightU16sEightU16sZZ_clone_ptr(LDKCOption_C2Tuple_EightU16sEightU16sZZ *NONNULL_PTR arg) {
18613         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
18614         *ret_copy = COption_C2Tuple_EightU16sEightU16sZZ_clone(arg);
18615         int64_t ret_ref = tag_ptr(ret_copy, true);
18616         return ret_ref;
18617 }
18618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18619         LDKCOption_C2Tuple_EightU16sEightU16sZZ* arg_conv = (LDKCOption_C2Tuple_EightU16sEightU16sZZ*)untag_ptr(arg);
18620         int64_t ret_conv = COption_C2Tuple_EightU16sEightU16sZZ_clone_ptr(arg_conv);
18621         return ret_conv;
18622 }
18623
18624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1EightU16sEightU16sZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18625         LDKCOption_C2Tuple_EightU16sEightU16sZZ* orig_conv = (LDKCOption_C2Tuple_EightU16sEightU16sZZ*)untag_ptr(orig);
18626         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
18627         *ret_copy = COption_C2Tuple_EightU16sEightU16sZZ_clone(orig_conv);
18628         int64_t ret_ref = tag_ptr(ret_copy, true);
18629         return ret_ref;
18630 }
18631
18632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18633         LDKCVec_NodeIdZ _res_constr;
18634         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18635         if (_res_constr.datalen > 0)
18636                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
18637         else
18638                 _res_constr.data = NULL;
18639         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18640         for (size_t i = 0; i < _res_constr.datalen; i++) {
18641                 int64_t _res_conv_8 = _res_vals[i];
18642                 LDKNodeId _res_conv_8_conv;
18643                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
18644                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
18645                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
18646                 _res_constr.data[i] = _res_conv_8_conv;
18647         }
18648         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18649         CVec_NodeIdZ_free(_res_constr);
18650 }
18651
18652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18653         LDKProbabilisticScorer o_conv;
18654         o_conv.inner = untag_ptr(o);
18655         o_conv.is_owned = ptr_is_owned(o);
18656         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18657         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
18658         
18659         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18660         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
18661         return tag_ptr(ret_conv, true);
18662 }
18663
18664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18665         void* e_ptr = untag_ptr(e);
18666         CHECK_ACCESS(e_ptr);
18667         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18668         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18669         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18670         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
18671         return tag_ptr(ret_conv, true);
18672 }
18673
18674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18675         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(o);
18676         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
18677         return ret_conv;
18678 }
18679
18680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18681         if (!ptr_is_owned(_res)) return;
18682         void* _res_ptr = untag_ptr(_res);
18683         CHECK_ACCESS(_res_ptr);
18684         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
18685         FREE(untag_ptr(_res));
18686         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
18687 }
18688
18689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18690         LDKInitFeatures o_conv;
18691         o_conv.inner = untag_ptr(o);
18692         o_conv.is_owned = ptr_is_owned(o);
18693         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18694         o_conv = InitFeatures_clone(&o_conv);
18695         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18696         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
18697         return tag_ptr(ret_conv, true);
18698 }
18699
18700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18701         void* e_ptr = untag_ptr(e);
18702         CHECK_ACCESS(e_ptr);
18703         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18704         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18705         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18706         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
18707         return tag_ptr(ret_conv, true);
18708 }
18709
18710 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18711         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(o);
18712         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
18713         return ret_conv;
18714 }
18715
18716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18717         if (!ptr_is_owned(_res)) return;
18718         void* _res_ptr = untag_ptr(_res);
18719         CHECK_ACCESS(_res_ptr);
18720         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
18721         FREE(untag_ptr(_res));
18722         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
18723 }
18724
18725 static inline uint64_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18726         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18727         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
18728         return tag_ptr(ret_conv, true);
18729 }
18730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18731         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(arg);
18732         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18733         return ret_conv;
18734 }
18735
18736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18737         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(orig);
18738         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18739         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
18740         return tag_ptr(ret_conv, true);
18741 }
18742
18743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18744         LDKChannelFeatures 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         o_conv = ChannelFeatures_clone(&o_conv);
18749         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18750         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
18751         return tag_ptr(ret_conv, true);
18752 }
18753
18754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18755         void* e_ptr = untag_ptr(e);
18756         CHECK_ACCESS(e_ptr);
18757         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18758         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18759         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18760         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
18761         return tag_ptr(ret_conv, true);
18762 }
18763
18764 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18765         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(o);
18766         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
18767         return ret_conv;
18768 }
18769
18770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18771         if (!ptr_is_owned(_res)) return;
18772         void* _res_ptr = untag_ptr(_res);
18773         CHECK_ACCESS(_res_ptr);
18774         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
18775         FREE(untag_ptr(_res));
18776         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
18777 }
18778
18779 static inline uint64_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18780         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18781         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
18782         return tag_ptr(ret_conv, true);
18783 }
18784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18785         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(arg);
18786         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18787         return ret_conv;
18788 }
18789
18790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18791         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(orig);
18792         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18793         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
18794         return tag_ptr(ret_conv, true);
18795 }
18796
18797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18798         LDKNodeFeatures o_conv;
18799         o_conv.inner = untag_ptr(o);
18800         o_conv.is_owned = ptr_is_owned(o);
18801         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18802         o_conv = NodeFeatures_clone(&o_conv);
18803         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18804         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
18805         return tag_ptr(ret_conv, true);
18806 }
18807
18808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18809         void* e_ptr = untag_ptr(e);
18810         CHECK_ACCESS(e_ptr);
18811         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18812         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18813         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18814         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
18815         return tag_ptr(ret_conv, true);
18816 }
18817
18818 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18819         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(o);
18820         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
18821         return ret_conv;
18822 }
18823
18824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18825         if (!ptr_is_owned(_res)) return;
18826         void* _res_ptr = untag_ptr(_res);
18827         CHECK_ACCESS(_res_ptr);
18828         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
18829         FREE(untag_ptr(_res));
18830         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
18831 }
18832
18833 static inline uint64_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18834         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18835         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
18836         return tag_ptr(ret_conv, true);
18837 }
18838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18839         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(arg);
18840         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18841         return ret_conv;
18842 }
18843
18844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18845         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(orig);
18846         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18847         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
18848         return tag_ptr(ret_conv, true);
18849 }
18850
18851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18852         LDKInvoiceFeatures o_conv;
18853         o_conv.inner = untag_ptr(o);
18854         o_conv.is_owned = ptr_is_owned(o);
18855         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18856         o_conv = InvoiceFeatures_clone(&o_conv);
18857         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18858         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
18859         return tag_ptr(ret_conv, true);
18860 }
18861
18862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18863         void* e_ptr = untag_ptr(e);
18864         CHECK_ACCESS(e_ptr);
18865         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18866         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18867         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18868         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
18869         return tag_ptr(ret_conv, true);
18870 }
18871
18872 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18873         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
18874         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
18875         return ret_conv;
18876 }
18877
18878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18879         if (!ptr_is_owned(_res)) return;
18880         void* _res_ptr = untag_ptr(_res);
18881         CHECK_ACCESS(_res_ptr);
18882         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
18883         FREE(untag_ptr(_res));
18884         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
18885 }
18886
18887 static inline uint64_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18888         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18889         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
18890         return tag_ptr(ret_conv, true);
18891 }
18892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18893         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
18894         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18895         return ret_conv;
18896 }
18897
18898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18899         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
18900         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18901         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
18902         return tag_ptr(ret_conv, true);
18903 }
18904
18905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18906         LDKBlindedHopFeatures o_conv;
18907         o_conv.inner = untag_ptr(o);
18908         o_conv.is_owned = ptr_is_owned(o);
18909         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18910         o_conv = BlindedHopFeatures_clone(&o_conv);
18911         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
18912         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_ok(o_conv);
18913         return tag_ptr(ret_conv, true);
18914 }
18915
18916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18917         void* e_ptr = untag_ptr(e);
18918         CHECK_ACCESS(e_ptr);
18919         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18920         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18921         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
18922         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_err(e_conv);
18923         return tag_ptr(ret_conv, true);
18924 }
18925
18926 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18927         LDKCResult_BlindedHopFeaturesDecodeErrorZ* o_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(o);
18928         jboolean ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(o_conv);
18929         return ret_conv;
18930 }
18931
18932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18933         if (!ptr_is_owned(_res)) return;
18934         void* _res_ptr = untag_ptr(_res);
18935         CHECK_ACCESS(_res_ptr);
18936         LDKCResult_BlindedHopFeaturesDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopFeaturesDecodeErrorZ*)(_res_ptr);
18937         FREE(untag_ptr(_res));
18938         CResult_BlindedHopFeaturesDecodeErrorZ_free(_res_conv);
18939 }
18940
18941 static inline uint64_t CResult_BlindedHopFeaturesDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18942         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
18943         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone(arg);
18944         return tag_ptr(ret_conv, true);
18945 }
18946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18947         LDKCResult_BlindedHopFeaturesDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(arg);
18948         int64_t ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18949         return ret_conv;
18950 }
18951
18952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18953         LDKCResult_BlindedHopFeaturesDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(orig);
18954         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
18955         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig_conv);
18956         return tag_ptr(ret_conv, true);
18957 }
18958
18959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18960         LDKChannelTypeFeatures o_conv;
18961         o_conv.inner = untag_ptr(o);
18962         o_conv.is_owned = ptr_is_owned(o);
18963         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18964         o_conv = ChannelTypeFeatures_clone(&o_conv);
18965         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18966         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
18967         return tag_ptr(ret_conv, true);
18968 }
18969
18970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18971         void* e_ptr = untag_ptr(e);
18972         CHECK_ACCESS(e_ptr);
18973         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18974         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18975         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18976         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
18977         return tag_ptr(ret_conv, true);
18978 }
18979
18980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18981         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(o);
18982         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
18983         return ret_conv;
18984 }
18985
18986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18987         if (!ptr_is_owned(_res)) return;
18988         void* _res_ptr = untag_ptr(_res);
18989         CHECK_ACCESS(_res_ptr);
18990         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
18991         FREE(untag_ptr(_res));
18992         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
18993 }
18994
18995 static inline uint64_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18996         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18997         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
18998         return tag_ptr(ret_conv, true);
18999 }
19000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19001         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(arg);
19002         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19003         return ret_conv;
19004 }
19005
19006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19007         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(orig);
19008         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19009         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
19010         return tag_ptr(ret_conv, true);
19011 }
19012
19013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19014         void* o_ptr = untag_ptr(o);
19015         CHECK_ACCESS(o_ptr);
19016         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
19017         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(o));
19018         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
19019         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
19020         return tag_ptr(ret_conv, true);
19021 }
19022
19023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19024         void* e_ptr = untag_ptr(e);
19025         CHECK_ACCESS(e_ptr);
19026         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19027         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19028         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
19029         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
19030         return tag_ptr(ret_conv, true);
19031 }
19032
19033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19034         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(o);
19035         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
19036         return ret_conv;
19037 }
19038
19039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19040         if (!ptr_is_owned(_res)) return;
19041         void* _res_ptr = untag_ptr(_res);
19042         CHECK_ACCESS(_res_ptr);
19043         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
19044         FREE(untag_ptr(_res));
19045         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
19046 }
19047
19048 static inline uint64_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
19049         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
19050         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
19051         return tag_ptr(ret_conv, true);
19052 }
19053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19054         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(arg);
19055         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
19056         return ret_conv;
19057 }
19058
19059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19060         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(orig);
19061         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
19062         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
19063         return tag_ptr(ret_conv, true);
19064 }
19065
19066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19067         void* o_ptr = untag_ptr(o);
19068         CHECK_ACCESS(o_ptr);
19069         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
19070         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)untag_ptr(o));
19071         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19072         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
19073         int64_t ret_ref = tag_ptr(ret_copy, true);
19074         return ret_ref;
19075 }
19076
19077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
19078         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19079         *ret_copy = COption_NetworkUpdateZ_none();
19080         int64_t ret_ref = tag_ptr(ret_copy, true);
19081         return ret_ref;
19082 }
19083
19084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19085         if (!ptr_is_owned(_res)) return;
19086         void* _res_ptr = untag_ptr(_res);
19087         CHECK_ACCESS(_res_ptr);
19088         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
19089         FREE(untag_ptr(_res));
19090         COption_NetworkUpdateZ_free(_res_conv);
19091 }
19092
19093 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
19094         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19095         *ret_copy = COption_NetworkUpdateZ_clone(arg);
19096         int64_t ret_ref = tag_ptr(ret_copy, true);
19097         return ret_ref;
19098 }
19099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19100         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(arg);
19101         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
19102         return ret_conv;
19103 }
19104
19105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19106         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(orig);
19107         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19108         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
19109         int64_t ret_ref = tag_ptr(ret_copy, true);
19110         return ret_ref;
19111 }
19112
19113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19114         void* o_ptr = untag_ptr(o);
19115         CHECK_ACCESS(o_ptr);
19116         LDKPathFailure o_conv = *(LDKPathFailure*)(o_ptr);
19117         o_conv = PathFailure_clone((LDKPathFailure*)untag_ptr(o));
19118         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
19119         *ret_copy = COption_PathFailureZ_some(o_conv);
19120         int64_t ret_ref = tag_ptr(ret_copy, true);
19121         return ret_ref;
19122 }
19123
19124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_1none(JNIEnv *env, jclass clz) {
19125         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
19126         *ret_copy = COption_PathFailureZ_none();
19127         int64_t ret_ref = tag_ptr(ret_copy, true);
19128         return ret_ref;
19129 }
19130
19131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_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         LDKCOption_PathFailureZ _res_conv = *(LDKCOption_PathFailureZ*)(_res_ptr);
19136         FREE(untag_ptr(_res));
19137         COption_PathFailureZ_free(_res_conv);
19138 }
19139
19140 static inline uint64_t COption_PathFailureZ_clone_ptr(LDKCOption_PathFailureZ *NONNULL_PTR arg) {
19141         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
19142         *ret_copy = COption_PathFailureZ_clone(arg);
19143         int64_t ret_ref = tag_ptr(ret_copy, true);
19144         return ret_ref;
19145 }
19146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19147         LDKCOption_PathFailureZ* arg_conv = (LDKCOption_PathFailureZ*)untag_ptr(arg);
19148         int64_t ret_conv = COption_PathFailureZ_clone_ptr(arg_conv);
19149         return ret_conv;
19150 }
19151
19152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PathFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19153         LDKCOption_PathFailureZ* orig_conv = (LDKCOption_PathFailureZ*)untag_ptr(orig);
19154         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
19155         *ret_copy = COption_PathFailureZ_clone(orig_conv);
19156         int64_t ret_ref = tag_ptr(ret_copy, true);
19157         return ret_ref;
19158 }
19159
19160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19161         void* o_ptr = untag_ptr(o);
19162         CHECK_ACCESS(o_ptr);
19163         LDKCOption_PathFailureZ o_conv = *(LDKCOption_PathFailureZ*)(o_ptr);
19164         o_conv = COption_PathFailureZ_clone((LDKCOption_PathFailureZ*)untag_ptr(o));
19165         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
19166         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_ok(o_conv);
19167         return tag_ptr(ret_conv, true);
19168 }
19169
19170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19171         void* e_ptr = untag_ptr(e);
19172         CHECK_ACCESS(e_ptr);
19173         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19174         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19175         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
19176         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_err(e_conv);
19177         return tag_ptr(ret_conv, true);
19178 }
19179
19180 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19181         LDKCResult_COption_PathFailureZDecodeErrorZ* o_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(o);
19182         jboolean ret_conv = CResult_COption_PathFailureZDecodeErrorZ_is_ok(o_conv);
19183         return ret_conv;
19184 }
19185
19186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19187         if (!ptr_is_owned(_res)) return;
19188         void* _res_ptr = untag_ptr(_res);
19189         CHECK_ACCESS(_res_ptr);
19190         LDKCResult_COption_PathFailureZDecodeErrorZ _res_conv = *(LDKCResult_COption_PathFailureZDecodeErrorZ*)(_res_ptr);
19191         FREE(untag_ptr(_res));
19192         CResult_COption_PathFailureZDecodeErrorZ_free(_res_conv);
19193 }
19194
19195 static inline uint64_t CResult_COption_PathFailureZDecodeErrorZ_clone_ptr(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR arg) {
19196         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
19197         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone(arg);
19198         return tag_ptr(ret_conv, true);
19199 }
19200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19201         LDKCResult_COption_PathFailureZDecodeErrorZ* arg_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(arg);
19202         int64_t ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone_ptr(arg_conv);
19203         return ret_conv;
19204 }
19205
19206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1PathFailureZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19207         LDKCResult_COption_PathFailureZDecodeErrorZ* orig_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(orig);
19208         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
19209         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone(orig_conv);
19210         return tag_ptr(ret_conv, true);
19211 }
19212
19213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19214         void* o_ptr = untag_ptr(o);
19215         CHECK_ACCESS(o_ptr);
19216         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
19217         o_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(o));
19218         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
19219         *ret_copy = COption_ClosureReasonZ_some(o_conv);
19220         int64_t ret_ref = tag_ptr(ret_copy, true);
19221         return ret_ref;
19222 }
19223
19224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
19225         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
19226         *ret_copy = COption_ClosureReasonZ_none();
19227         int64_t ret_ref = tag_ptr(ret_copy, true);
19228         return ret_ref;
19229 }
19230
19231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19232         if (!ptr_is_owned(_res)) return;
19233         void* _res_ptr = untag_ptr(_res);
19234         CHECK_ACCESS(_res_ptr);
19235         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
19236         FREE(untag_ptr(_res));
19237         COption_ClosureReasonZ_free(_res_conv);
19238 }
19239
19240 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
19241         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
19242         *ret_copy = COption_ClosureReasonZ_clone(arg);
19243         int64_t ret_ref = tag_ptr(ret_copy, true);
19244         return ret_ref;
19245 }
19246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19247         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(arg);
19248         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
19249         return ret_conv;
19250 }
19251
19252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19253         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(orig);
19254         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
19255         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
19256         int64_t ret_ref = tag_ptr(ret_copy, true);
19257         return ret_ref;
19258 }
19259
19260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19261         void* o_ptr = untag_ptr(o);
19262         CHECK_ACCESS(o_ptr);
19263         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
19264         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)untag_ptr(o));
19265         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19266         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
19267         return tag_ptr(ret_conv, true);
19268 }
19269
19270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19271         void* e_ptr = untag_ptr(e);
19272         CHECK_ACCESS(e_ptr);
19273         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19274         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19275         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19276         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
19277         return tag_ptr(ret_conv, true);
19278 }
19279
19280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19281         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(o);
19282         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
19283         return ret_conv;
19284 }
19285
19286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19287         if (!ptr_is_owned(_res)) return;
19288         void* _res_ptr = untag_ptr(_res);
19289         CHECK_ACCESS(_res_ptr);
19290         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
19291         FREE(untag_ptr(_res));
19292         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
19293 }
19294
19295 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
19296         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19297         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
19298         return tag_ptr(ret_conv, true);
19299 }
19300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19301         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(arg);
19302         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
19303         return ret_conv;
19304 }
19305
19306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19307         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(orig);
19308         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19309         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
19310         return tag_ptr(ret_conv, true);
19311 }
19312
19313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19314         void* o_ptr = untag_ptr(o);
19315         CHECK_ACCESS(o_ptr);
19316         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
19317         o_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(o));
19318         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
19319         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
19320         int64_t ret_ref = tag_ptr(ret_copy, true);
19321         return ret_ref;
19322 }
19323
19324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1none(JNIEnv *env, jclass clz) {
19325         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
19326         *ret_copy = COption_HTLCDestinationZ_none();
19327         int64_t ret_ref = tag_ptr(ret_copy, true);
19328         return ret_ref;
19329 }
19330
19331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19332         if (!ptr_is_owned(_res)) return;
19333         void* _res_ptr = untag_ptr(_res);
19334         CHECK_ACCESS(_res_ptr);
19335         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
19336         FREE(untag_ptr(_res));
19337         COption_HTLCDestinationZ_free(_res_conv);
19338 }
19339
19340 static inline uint64_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
19341         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
19342         *ret_copy = COption_HTLCDestinationZ_clone(arg);
19343         int64_t ret_ref = tag_ptr(ret_copy, true);
19344         return ret_ref;
19345 }
19346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19347         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(arg);
19348         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
19349         return ret_conv;
19350 }
19351
19352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19353         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(orig);
19354         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
19355         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
19356         int64_t ret_ref = tag_ptr(ret_copy, true);
19357         return ret_ref;
19358 }
19359
19360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19361         void* o_ptr = untag_ptr(o);
19362         CHECK_ACCESS(o_ptr);
19363         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
19364         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)untag_ptr(o));
19365         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
19366         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
19367         return tag_ptr(ret_conv, true);
19368 }
19369
19370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19371         void* e_ptr = untag_ptr(e);
19372         CHECK_ACCESS(e_ptr);
19373         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19374         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19375         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
19376         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
19377         return tag_ptr(ret_conv, true);
19378 }
19379
19380 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19381         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(o);
19382         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
19383         return ret_conv;
19384 }
19385
19386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19387         if (!ptr_is_owned(_res)) return;
19388         void* _res_ptr = untag_ptr(_res);
19389         CHECK_ACCESS(_res_ptr);
19390         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
19391         FREE(untag_ptr(_res));
19392         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
19393 }
19394
19395 static inline uint64_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
19396         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
19397         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
19398         return tag_ptr(ret_conv, true);
19399 }
19400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19401         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(arg);
19402         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
19403         return ret_conv;
19404 }
19405
19406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19407         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(orig);
19408         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
19409         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
19410         return tag_ptr(ret_conv, true);
19411 }
19412
19413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
19414         LDKPaymentFailureReason o_conv = LDKPaymentFailureReason_from_java(env, o);
19415         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
19416         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_ok(o_conv);
19417         return tag_ptr(ret_conv, true);
19418 }
19419
19420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19421         void* e_ptr = untag_ptr(e);
19422         CHECK_ACCESS(e_ptr);
19423         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19424         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19425         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
19426         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_err(e_conv);
19427         return tag_ptr(ret_conv, true);
19428 }
19429
19430 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19431         LDKCResult_PaymentFailureReasonDecodeErrorZ* o_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(o);
19432         jboolean ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_is_ok(o_conv);
19433         return ret_conv;
19434 }
19435
19436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19437         if (!ptr_is_owned(_res)) return;
19438         void* _res_ptr = untag_ptr(_res);
19439         CHECK_ACCESS(_res_ptr);
19440         LDKCResult_PaymentFailureReasonDecodeErrorZ _res_conv = *(LDKCResult_PaymentFailureReasonDecodeErrorZ*)(_res_ptr);
19441         FREE(untag_ptr(_res));
19442         CResult_PaymentFailureReasonDecodeErrorZ_free(_res_conv);
19443 }
19444
19445 static inline uint64_t CResult_PaymentFailureReasonDecodeErrorZ_clone_ptr(LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR arg) {
19446         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
19447         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_clone(arg);
19448         return tag_ptr(ret_conv, true);
19449 }
19450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19451         LDKCResult_PaymentFailureReasonDecodeErrorZ* arg_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(arg);
19452         int64_t ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_clone_ptr(arg_conv);
19453         return ret_conv;
19454 }
19455
19456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentFailureReasonDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19457         LDKCResult_PaymentFailureReasonDecodeErrorZ* orig_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(orig);
19458         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
19459         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_clone(orig_conv);
19460         return tag_ptr(ret_conv, true);
19461 }
19462
19463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1some(JNIEnv *env, jclass clz, int8_tArray o) {
19464         LDKU128 o_ref;
19465         CHECK((*env)->GetArrayLength(env, o) == 16);
19466         (*env)->GetByteArrayRegion(env, o, 0, 16, o_ref.le_bytes);
19467         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
19468         *ret_copy = COption_u128Z_some(o_ref);
19469         int64_t ret_ref = tag_ptr(ret_copy, true);
19470         return ret_ref;
19471 }
19472
19473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1none(JNIEnv *env, jclass clz) {
19474         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
19475         *ret_copy = COption_u128Z_none();
19476         int64_t ret_ref = tag_ptr(ret_copy, true);
19477         return ret_ref;
19478 }
19479
19480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
19481         if (!ptr_is_owned(_res)) return;
19482         void* _res_ptr = untag_ptr(_res);
19483         CHECK_ACCESS(_res_ptr);
19484         LDKCOption_u128Z _res_conv = *(LDKCOption_u128Z*)(_res_ptr);
19485         FREE(untag_ptr(_res));
19486         COption_u128Z_free(_res_conv);
19487 }
19488
19489 static inline uint64_t COption_u128Z_clone_ptr(LDKCOption_u128Z *NONNULL_PTR arg) {
19490         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
19491         *ret_copy = COption_u128Z_clone(arg);
19492         int64_t ret_ref = tag_ptr(ret_copy, true);
19493         return ret_ref;
19494 }
19495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19496         LDKCOption_u128Z* arg_conv = (LDKCOption_u128Z*)untag_ptr(arg);
19497         int64_t ret_conv = COption_u128Z_clone_ptr(arg_conv);
19498         return ret_conv;
19499 }
19500
19501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19502         LDKCOption_u128Z* orig_conv = (LDKCOption_u128Z*)untag_ptr(orig);
19503         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
19504         *ret_copy = COption_u128Z_clone(orig_conv);
19505         int64_t ret_ref = tag_ptr(ret_copy, true);
19506         return ret_ref;
19507 }
19508
19509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PaymentFailureReasonZ_1some(JNIEnv *env, jclass clz, jclass o) {
19510         LDKPaymentFailureReason o_conv = LDKPaymentFailureReason_from_java(env, o);
19511         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
19512         *ret_copy = COption_PaymentFailureReasonZ_some(o_conv);
19513         int64_t ret_ref = tag_ptr(ret_copy, true);
19514         return ret_ref;
19515 }
19516
19517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PaymentFailureReasonZ_1none(JNIEnv *env, jclass clz) {
19518         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
19519         *ret_copy = COption_PaymentFailureReasonZ_none();
19520         int64_t ret_ref = tag_ptr(ret_copy, true);
19521         return ret_ref;
19522 }
19523
19524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1PaymentFailureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19525         if (!ptr_is_owned(_res)) return;
19526         void* _res_ptr = untag_ptr(_res);
19527         CHECK_ACCESS(_res_ptr);
19528         LDKCOption_PaymentFailureReasonZ _res_conv = *(LDKCOption_PaymentFailureReasonZ*)(_res_ptr);
19529         FREE(untag_ptr(_res));
19530         COption_PaymentFailureReasonZ_free(_res_conv);
19531 }
19532
19533 static inline uint64_t COption_PaymentFailureReasonZ_clone_ptr(LDKCOption_PaymentFailureReasonZ *NONNULL_PTR arg) {
19534         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
19535         *ret_copy = COption_PaymentFailureReasonZ_clone(arg);
19536         int64_t ret_ref = tag_ptr(ret_copy, true);
19537         return ret_ref;
19538 }
19539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PaymentFailureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19540         LDKCOption_PaymentFailureReasonZ* arg_conv = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(arg);
19541         int64_t ret_conv = COption_PaymentFailureReasonZ_clone_ptr(arg_conv);
19542         return ret_conv;
19543 }
19544
19545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1PaymentFailureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19546         LDKCOption_PaymentFailureReasonZ* orig_conv = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(orig);
19547         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
19548         *ret_copy = COption_PaymentFailureReasonZ_clone(orig_conv);
19549         int64_t ret_ref = tag_ptr(ret_copy, true);
19550         return ret_ref;
19551 }
19552
19553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19554         LDKCVec_SpendableOutputDescriptorZ _res_constr;
19555         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19556         if (_res_constr.datalen > 0)
19557                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
19558         else
19559                 _res_constr.data = NULL;
19560         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19561         for (size_t b = 0; b < _res_constr.datalen; b++) {
19562                 int64_t _res_conv_27 = _res_vals[b];
19563                 void* _res_conv_27_ptr = untag_ptr(_res_conv_27);
19564                 CHECK_ACCESS(_res_conv_27_ptr);
19565                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
19566                 FREE(untag_ptr(_res_conv_27));
19567                 _res_constr.data[b] = _res_conv_27_conv;
19568         }
19569         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19570         CVec_SpendableOutputDescriptorZ_free(_res_constr);
19571 }
19572
19573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19574         void* o_ptr = untag_ptr(o);
19575         CHECK_ACCESS(o_ptr);
19576         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
19577         o_conv = Event_clone((LDKEvent*)untag_ptr(o));
19578         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
19579         *ret_copy = COption_EventZ_some(o_conv);
19580         int64_t ret_ref = tag_ptr(ret_copy, true);
19581         return ret_ref;
19582 }
19583
19584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
19585         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
19586         *ret_copy = COption_EventZ_none();
19587         int64_t ret_ref = tag_ptr(ret_copy, true);
19588         return ret_ref;
19589 }
19590
19591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19592         if (!ptr_is_owned(_res)) return;
19593         void* _res_ptr = untag_ptr(_res);
19594         CHECK_ACCESS(_res_ptr);
19595         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
19596         FREE(untag_ptr(_res));
19597         COption_EventZ_free(_res_conv);
19598 }
19599
19600 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
19601         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
19602         *ret_copy = COption_EventZ_clone(arg);
19603         int64_t ret_ref = tag_ptr(ret_copy, true);
19604         return ret_ref;
19605 }
19606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19607         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)untag_ptr(arg);
19608         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
19609         return ret_conv;
19610 }
19611
19612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19613         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)untag_ptr(orig);
19614         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
19615         *ret_copy = COption_EventZ_clone(orig_conv);
19616         int64_t ret_ref = tag_ptr(ret_copy, true);
19617         return ret_ref;
19618 }
19619
19620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19621         void* o_ptr = untag_ptr(o);
19622         CHECK_ACCESS(o_ptr);
19623         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
19624         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)untag_ptr(o));
19625         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19626         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
19627         return tag_ptr(ret_conv, true);
19628 }
19629
19630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19631         void* e_ptr = untag_ptr(e);
19632         CHECK_ACCESS(e_ptr);
19633         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19634         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19635         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19636         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
19637         return tag_ptr(ret_conv, true);
19638 }
19639
19640 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19641         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(o);
19642         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
19643         return ret_conv;
19644 }
19645
19646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19647         if (!ptr_is_owned(_res)) return;
19648         void* _res_ptr = untag_ptr(_res);
19649         CHECK_ACCESS(_res_ptr);
19650         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
19651         FREE(untag_ptr(_res));
19652         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
19653 }
19654
19655 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
19656         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19657         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
19658         return tag_ptr(ret_conv, true);
19659 }
19660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19661         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(arg);
19662         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
19663         return ret_conv;
19664 }
19665
19666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19667         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(orig);
19668         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19669         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
19670         return tag_ptr(ret_conv, true);
19671 }
19672
19673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19674         LDKCVec_MessageSendEventZ _res_constr;
19675         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19676         if (_res_constr.datalen > 0)
19677                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
19678         else
19679                 _res_constr.data = NULL;
19680         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19681         for (size_t s = 0; s < _res_constr.datalen; s++) {
19682                 int64_t _res_conv_18 = _res_vals[s];
19683                 void* _res_conv_18_ptr = untag_ptr(_res_conv_18);
19684                 CHECK_ACCESS(_res_conv_18_ptr);
19685                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
19686                 FREE(untag_ptr(_res_conv_18));
19687                 _res_constr.data[s] = _res_conv_18_conv;
19688         }
19689         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19690         CVec_MessageSendEventZ_free(_res_constr);
19691 }
19692
19693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChainHashZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19694         LDKCVec_ChainHashZ _res_constr;
19695         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19696         if (_res_constr.datalen > 0)
19697                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ChainHashZ Elements");
19698         else
19699                 _res_constr.data = NULL;
19700         for (size_t i = 0; i < _res_constr.datalen; i++) {
19701                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19702                 LDKThirtyTwoBytes _res_conv_8_ref;
19703                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
19704                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
19705                 _res_constr.data[i] = _res_conv_8_ref;
19706         }
19707         CVec_ChainHashZ_free(_res_constr);
19708 }
19709
19710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19711         LDKPublicKey o_ref;
19712         CHECK((*env)->GetArrayLength(env, o) == 33);
19713         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
19714         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19715         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
19716         return tag_ptr(ret_conv, true);
19717 }
19718
19719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19720         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
19721         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19722         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
19723         return tag_ptr(ret_conv, true);
19724 }
19725
19726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19727         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(o);
19728         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
19729         return ret_conv;
19730 }
19731
19732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19733         if (!ptr_is_owned(_res)) return;
19734         void* _res_ptr = untag_ptr(_res);
19735         CHECK_ACCESS(_res_ptr);
19736         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
19737         FREE(untag_ptr(_res));
19738         CResult_PublicKeyErrorZ_free(_res_conv);
19739 }
19740
19741 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
19742         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19743         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
19744         return tag_ptr(ret_conv, true);
19745 }
19746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19747         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(arg);
19748         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
19749         return ret_conv;
19750 }
19751
19752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19753         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(orig);
19754         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19755         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
19756         return tag_ptr(ret_conv, true);
19757 }
19758
19759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19760         LDKNodeId o_conv;
19761         o_conv.inner = untag_ptr(o);
19762         o_conv.is_owned = ptr_is_owned(o);
19763         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19764         o_conv = NodeId_clone(&o_conv);
19765         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19766         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
19767         return tag_ptr(ret_conv, true);
19768 }
19769
19770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19771         void* e_ptr = untag_ptr(e);
19772         CHECK_ACCESS(e_ptr);
19773         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19774         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19775         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19776         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
19777         return tag_ptr(ret_conv, true);
19778 }
19779
19780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19781         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(o);
19782         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
19783         return ret_conv;
19784 }
19785
19786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19787         if (!ptr_is_owned(_res)) return;
19788         void* _res_ptr = untag_ptr(_res);
19789         CHECK_ACCESS(_res_ptr);
19790         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
19791         FREE(untag_ptr(_res));
19792         CResult_NodeIdDecodeErrorZ_free(_res_conv);
19793 }
19794
19795 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
19796         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19797         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
19798         return tag_ptr(ret_conv, true);
19799 }
19800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19801         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(arg);
19802         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
19803         return ret_conv;
19804 }
19805
19806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19807         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(orig);
19808         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19809         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
19810         return tag_ptr(ret_conv, true);
19811 }
19812
19813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19814         void* o_ptr = untag_ptr(o);
19815         CHECK_ACCESS(o_ptr);
19816         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
19817         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(o));
19818         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19819         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
19820         return tag_ptr(ret_conv, true);
19821 }
19822
19823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19824         void* e_ptr = untag_ptr(e);
19825         CHECK_ACCESS(e_ptr);
19826         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19827         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19828         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19829         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
19830         return tag_ptr(ret_conv, true);
19831 }
19832
19833 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19834         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(o);
19835         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
19836         return ret_conv;
19837 }
19838
19839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19840         if (!ptr_is_owned(_res)) return;
19841         void* _res_ptr = untag_ptr(_res);
19842         CHECK_ACCESS(_res_ptr);
19843         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
19844         FREE(untag_ptr(_res));
19845         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
19846 }
19847
19848 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
19849         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19850         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
19851         return tag_ptr(ret_conv, true);
19852 }
19853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19854         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(arg);
19855         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
19856         return ret_conv;
19857 }
19858
19859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19860         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(orig);
19861         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19862         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
19863         return tag_ptr(ret_conv, true);
19864 }
19865
19866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1UtxoLookupZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19867         void* o_ptr = untag_ptr(o);
19868         CHECK_ACCESS(o_ptr);
19869         LDKUtxoLookup o_conv = *(LDKUtxoLookup*)(o_ptr);
19870         if (o_conv.free == LDKUtxoLookup_JCalls_free) {
19871                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19872                 LDKUtxoLookup_JCalls_cloned(&o_conv);
19873         }
19874         LDKCOption_UtxoLookupZ *ret_copy = MALLOC(sizeof(LDKCOption_UtxoLookupZ), "LDKCOption_UtxoLookupZ");
19875         *ret_copy = COption_UtxoLookupZ_some(o_conv);
19876         int64_t ret_ref = tag_ptr(ret_copy, true);
19877         return ret_ref;
19878 }
19879
19880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1UtxoLookupZ_1none(JNIEnv *env, jclass clz) {
19881         LDKCOption_UtxoLookupZ *ret_copy = MALLOC(sizeof(LDKCOption_UtxoLookupZ), "LDKCOption_UtxoLookupZ");
19882         *ret_copy = COption_UtxoLookupZ_none();
19883         int64_t ret_ref = tag_ptr(ret_copy, true);
19884         return ret_ref;
19885 }
19886
19887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1UtxoLookupZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19888         if (!ptr_is_owned(_res)) return;
19889         void* _res_ptr = untag_ptr(_res);
19890         CHECK_ACCESS(_res_ptr);
19891         LDKCOption_UtxoLookupZ _res_conv = *(LDKCOption_UtxoLookupZ*)(_res_ptr);
19892         FREE(untag_ptr(_res));
19893         COption_UtxoLookupZ_free(_res_conv);
19894 }
19895
19896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
19897         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19898         *ret_conv = CResult_boolLightningErrorZ_ok(o);
19899         return tag_ptr(ret_conv, true);
19900 }
19901
19902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19903         LDKLightningError e_conv;
19904         e_conv.inner = untag_ptr(e);
19905         e_conv.is_owned = ptr_is_owned(e);
19906         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19907         e_conv = LightningError_clone(&e_conv);
19908         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19909         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
19910         return tag_ptr(ret_conv, true);
19911 }
19912
19913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19914         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(o);
19915         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
19916         return ret_conv;
19917 }
19918
19919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19920         if (!ptr_is_owned(_res)) return;
19921         void* _res_ptr = untag_ptr(_res);
19922         CHECK_ACCESS(_res_ptr);
19923         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
19924         FREE(untag_ptr(_res));
19925         CResult_boolLightningErrorZ_free(_res_conv);
19926 }
19927
19928 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
19929         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19930         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
19931         return tag_ptr(ret_conv, true);
19932 }
19933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19934         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(arg);
19935         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
19936         return ret_conv;
19937 }
19938
19939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19940         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(orig);
19941         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19942         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
19943         return tag_ptr(ret_conv, true);
19944 }
19945
19946 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
19947         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19948         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
19949         return tag_ptr(ret_conv, true);
19950 }
19951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19952         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(arg);
19953         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
19954         return ret_conv;
19955 }
19956
19957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19958         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(orig);
19959         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19960         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
19961         return tag_ptr(ret_conv, true);
19962 }
19963
19964 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) {
19965         LDKChannelAnnouncement a_conv;
19966         a_conv.inner = untag_ptr(a);
19967         a_conv.is_owned = ptr_is_owned(a);
19968         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19969         a_conv = ChannelAnnouncement_clone(&a_conv);
19970         LDKChannelUpdate b_conv;
19971         b_conv.inner = untag_ptr(b);
19972         b_conv.is_owned = ptr_is_owned(b);
19973         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19974         b_conv = ChannelUpdate_clone(&b_conv);
19975         LDKChannelUpdate c_conv;
19976         c_conv.inner = untag_ptr(c);
19977         c_conv.is_owned = ptr_is_owned(c);
19978         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
19979         c_conv = ChannelUpdate_clone(&c_conv);
19980         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19981         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
19982         return tag_ptr(ret_conv, true);
19983 }
19984
19985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19986         if (!ptr_is_owned(_res)) return;
19987         void* _res_ptr = untag_ptr(_res);
19988         CHECK_ACCESS(_res_ptr);
19989         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
19990         FREE(untag_ptr(_res));
19991         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
19992 }
19993
19994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19995         void* o_ptr = untag_ptr(o);
19996         CHECK_ACCESS(o_ptr);
19997         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(o_ptr);
19998         o_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(o));
19999         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
20000         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o_conv);
20001         int64_t ret_ref = tag_ptr(ret_copy, true);
20002         return ret_ref;
20003 }
20004
20005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1none(JNIEnv *env, jclass clz) {
20006         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
20007         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none();
20008         int64_t ret_ref = tag_ptr(ret_copy, true);
20009         return ret_ref;
20010 }
20011
20012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20013         if (!ptr_is_owned(_res)) return;
20014         void* _res_ptr = untag_ptr(_res);
20015         CHECK_ACCESS(_res_ptr);
20016         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(_res_ptr);
20017         FREE(untag_ptr(_res));
20018         COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_conv);
20019 }
20020
20021 static inline uint64_t COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR arg) {
20022         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
20023         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(arg);
20024         int64_t ret_ref = tag_ptr(ret_copy, true);
20025         return ret_ref;
20026 }
20027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20028         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* arg_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(arg);
20029         int64_t ret_conv = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(arg_conv);
20030         return ret_conv;
20031 }
20032
20033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20034         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* orig_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(orig);
20035         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
20036         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig_conv);
20037         int64_t ret_ref = tag_ptr(ret_copy, true);
20038         return ret_ref;
20039 }
20040
20041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
20042         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20043         *ret_conv = CResult_NoneLightningErrorZ_ok();
20044         return tag_ptr(ret_conv, true);
20045 }
20046
20047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20048         LDKLightningError e_conv;
20049         e_conv.inner = untag_ptr(e);
20050         e_conv.is_owned = ptr_is_owned(e);
20051         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20052         e_conv = LightningError_clone(&e_conv);
20053         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20054         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
20055         return tag_ptr(ret_conv, true);
20056 }
20057
20058 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20059         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(o);
20060         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
20061         return ret_conv;
20062 }
20063
20064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20065         if (!ptr_is_owned(_res)) return;
20066         void* _res_ptr = untag_ptr(_res);
20067         CHECK_ACCESS(_res_ptr);
20068         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
20069         FREE(untag_ptr(_res));
20070         CResult_NoneLightningErrorZ_free(_res_conv);
20071 }
20072
20073 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
20074         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20075         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
20076         return tag_ptr(ret_conv, true);
20077 }
20078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20079         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(arg);
20080         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
20081         return ret_conv;
20082 }
20083
20084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20085         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(orig);
20086         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20087         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
20088         return tag_ptr(ret_conv, true);
20089 }
20090
20091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20092         LDKChannelUpdateInfo o_conv;
20093         o_conv.inner = untag_ptr(o);
20094         o_conv.is_owned = ptr_is_owned(o);
20095         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20096         o_conv = ChannelUpdateInfo_clone(&o_conv);
20097         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20098         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
20099         return tag_ptr(ret_conv, true);
20100 }
20101
20102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20103         void* e_ptr = untag_ptr(e);
20104         CHECK_ACCESS(e_ptr);
20105         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20106         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20107         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20108         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
20109         return tag_ptr(ret_conv, true);
20110 }
20111
20112 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20113         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(o);
20114         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
20115         return ret_conv;
20116 }
20117
20118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20119         if (!ptr_is_owned(_res)) return;
20120         void* _res_ptr = untag_ptr(_res);
20121         CHECK_ACCESS(_res_ptr);
20122         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
20123         FREE(untag_ptr(_res));
20124         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
20125 }
20126
20127 static inline uint64_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
20128         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20129         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
20130         return tag_ptr(ret_conv, true);
20131 }
20132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20133         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(arg);
20134         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
20135         return ret_conv;
20136 }
20137
20138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20139         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(orig);
20140         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20141         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
20142         return tag_ptr(ret_conv, true);
20143 }
20144
20145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20146         LDKChannelInfo o_conv;
20147         o_conv.inner = untag_ptr(o);
20148         o_conv.is_owned = ptr_is_owned(o);
20149         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20150         o_conv = ChannelInfo_clone(&o_conv);
20151         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20152         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
20153         return tag_ptr(ret_conv, true);
20154 }
20155
20156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20157         void* e_ptr = untag_ptr(e);
20158         CHECK_ACCESS(e_ptr);
20159         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20160         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20161         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20162         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
20163         return tag_ptr(ret_conv, true);
20164 }
20165
20166 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20167         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(o);
20168         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
20169         return ret_conv;
20170 }
20171
20172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20173         if (!ptr_is_owned(_res)) return;
20174         void* _res_ptr = untag_ptr(_res);
20175         CHECK_ACCESS(_res_ptr);
20176         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
20177         FREE(untag_ptr(_res));
20178         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
20179 }
20180
20181 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
20182         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20183         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
20184         return tag_ptr(ret_conv, true);
20185 }
20186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20187         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(arg);
20188         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
20189         return ret_conv;
20190 }
20191
20192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20193         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(orig);
20194         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20195         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
20196         return tag_ptr(ret_conv, true);
20197 }
20198
20199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20200         LDKRoutingFees o_conv;
20201         o_conv.inner = untag_ptr(o);
20202         o_conv.is_owned = ptr_is_owned(o);
20203         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20204         o_conv = RoutingFees_clone(&o_conv);
20205         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20206         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
20207         return tag_ptr(ret_conv, true);
20208 }
20209
20210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20211         void* e_ptr = untag_ptr(e);
20212         CHECK_ACCESS(e_ptr);
20213         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20214         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20215         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20216         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
20217         return tag_ptr(ret_conv, true);
20218 }
20219
20220 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20221         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(o);
20222         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
20223         return ret_conv;
20224 }
20225
20226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20227         if (!ptr_is_owned(_res)) return;
20228         void* _res_ptr = untag_ptr(_res);
20229         CHECK_ACCESS(_res_ptr);
20230         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
20231         FREE(untag_ptr(_res));
20232         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
20233 }
20234
20235 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
20236         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20237         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
20238         return tag_ptr(ret_conv, true);
20239 }
20240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20241         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(arg);
20242         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
20243         return ret_conv;
20244 }
20245
20246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20247         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(orig);
20248         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20249         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
20250         return tag_ptr(ret_conv, true);
20251 }
20252
20253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20254         LDKCVec_NetAddressZ _res_constr;
20255         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20256         if (_res_constr.datalen > 0)
20257                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20258         else
20259                 _res_constr.data = NULL;
20260         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20261         for (size_t m = 0; m < _res_constr.datalen; m++) {
20262                 int64_t _res_conv_12 = _res_vals[m];
20263                 void* _res_conv_12_ptr = untag_ptr(_res_conv_12);
20264                 CHECK_ACCESS(_res_conv_12_ptr);
20265                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
20266                 FREE(untag_ptr(_res_conv_12));
20267                 _res_constr.data[m] = _res_conv_12_conv;
20268         }
20269         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20270         CVec_NetAddressZ_free(_res_constr);
20271 }
20272
20273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20274         LDKNodeAnnouncementInfo o_conv;
20275         o_conv.inner = untag_ptr(o);
20276         o_conv.is_owned = ptr_is_owned(o);
20277         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20278         o_conv = NodeAnnouncementInfo_clone(&o_conv);
20279         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20280         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
20281         return tag_ptr(ret_conv, true);
20282 }
20283
20284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20285         void* e_ptr = untag_ptr(e);
20286         CHECK_ACCESS(e_ptr);
20287         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20288         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20289         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20290         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
20291         return tag_ptr(ret_conv, true);
20292 }
20293
20294 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20295         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(o);
20296         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
20297         return ret_conv;
20298 }
20299
20300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20301         if (!ptr_is_owned(_res)) return;
20302         void* _res_ptr = untag_ptr(_res);
20303         CHECK_ACCESS(_res_ptr);
20304         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
20305         FREE(untag_ptr(_res));
20306         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
20307 }
20308
20309 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
20310         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20311         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
20312         return tag_ptr(ret_conv, true);
20313 }
20314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20315         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(arg);
20316         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
20317         return ret_conv;
20318 }
20319
20320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20321         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(orig);
20322         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20323         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
20324         return tag_ptr(ret_conv, true);
20325 }
20326
20327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20328         LDKNodeAlias o_conv;
20329         o_conv.inner = untag_ptr(o);
20330         o_conv.is_owned = ptr_is_owned(o);
20331         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20332         o_conv = NodeAlias_clone(&o_conv);
20333         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20334         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
20335         return tag_ptr(ret_conv, true);
20336 }
20337
20338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20339         void* e_ptr = untag_ptr(e);
20340         CHECK_ACCESS(e_ptr);
20341         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20342         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20343         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20344         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
20345         return tag_ptr(ret_conv, true);
20346 }
20347
20348 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20349         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(o);
20350         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
20351         return ret_conv;
20352 }
20353
20354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20355         if (!ptr_is_owned(_res)) return;
20356         void* _res_ptr = untag_ptr(_res);
20357         CHECK_ACCESS(_res_ptr);
20358         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
20359         FREE(untag_ptr(_res));
20360         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
20361 }
20362
20363 static inline uint64_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
20364         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20365         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
20366         return tag_ptr(ret_conv, true);
20367 }
20368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20369         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(arg);
20370         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
20371         return ret_conv;
20372 }
20373
20374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20375         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(orig);
20376         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20377         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
20378         return tag_ptr(ret_conv, true);
20379 }
20380
20381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20382         LDKNodeInfo o_conv;
20383         o_conv.inner = untag_ptr(o);
20384         o_conv.is_owned = ptr_is_owned(o);
20385         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20386         o_conv = NodeInfo_clone(&o_conv);
20387         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20388         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
20389         return tag_ptr(ret_conv, true);
20390 }
20391
20392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20393         void* e_ptr = untag_ptr(e);
20394         CHECK_ACCESS(e_ptr);
20395         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20396         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20397         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20398         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
20399         return tag_ptr(ret_conv, true);
20400 }
20401
20402 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20403         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(o);
20404         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
20405         return ret_conv;
20406 }
20407
20408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20409         if (!ptr_is_owned(_res)) return;
20410         void* _res_ptr = untag_ptr(_res);
20411         CHECK_ACCESS(_res_ptr);
20412         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
20413         FREE(untag_ptr(_res));
20414         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
20415 }
20416
20417 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
20418         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20419         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
20420         return tag_ptr(ret_conv, true);
20421 }
20422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20423         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(arg);
20424         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
20425         return ret_conv;
20426 }
20427
20428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20429         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(orig);
20430         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20431         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
20432         return tag_ptr(ret_conv, true);
20433 }
20434
20435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20436         LDKNetworkGraph o_conv;
20437         o_conv.inner = untag_ptr(o);
20438         o_conv.is_owned = ptr_is_owned(o);
20439         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20440         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
20441         
20442         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20443         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
20444         return tag_ptr(ret_conv, true);
20445 }
20446
20447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20448         void* e_ptr = untag_ptr(e);
20449         CHECK_ACCESS(e_ptr);
20450         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20451         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20452         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20453         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
20454         return tag_ptr(ret_conv, true);
20455 }
20456
20457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20458         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(o);
20459         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
20460         return ret_conv;
20461 }
20462
20463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20464         if (!ptr_is_owned(_res)) return;
20465         void* _res_ptr = untag_ptr(_res);
20466         CHECK_ACCESS(_res_ptr);
20467         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
20468         FREE(untag_ptr(_res));
20469         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
20470 }
20471
20472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
20473         LDKCVec_NetAddressZ o_constr;
20474         o_constr.datalen = (*env)->GetArrayLength(env, o);
20475         if (o_constr.datalen > 0)
20476                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20477         else
20478                 o_constr.data = NULL;
20479         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
20480         for (size_t m = 0; m < o_constr.datalen; m++) {
20481                 int64_t o_conv_12 = o_vals[m];
20482                 void* o_conv_12_ptr = untag_ptr(o_conv_12);
20483                 CHECK_ACCESS(o_conv_12_ptr);
20484                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
20485                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o_conv_12));
20486                 o_constr.data[m] = o_conv_12_conv;
20487         }
20488         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
20489         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20490         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
20491         int64_t ret_ref = tag_ptr(ret_copy, true);
20492         return ret_ref;
20493 }
20494
20495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
20496         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20497         *ret_copy = COption_CVec_NetAddressZZ_none();
20498         int64_t ret_ref = tag_ptr(ret_copy, true);
20499         return ret_ref;
20500 }
20501
20502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_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         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
20507         FREE(untag_ptr(_res));
20508         COption_CVec_NetAddressZZ_free(_res_conv);
20509 }
20510
20511 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
20512         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20513         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
20514         int64_t ret_ref = tag_ptr(ret_copy, true);
20515         return ret_ref;
20516 }
20517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20518         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(arg);
20519         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
20520         return ret_conv;
20521 }
20522
20523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20524         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(orig);
20525         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20526         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
20527         int64_t ret_ref = tag_ptr(ret_copy, true);
20528         return ret_ref;
20529 }
20530
20531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20532         LDKDelayedPaymentOutputDescriptor o_conv;
20533         o_conv.inner = untag_ptr(o);
20534         o_conv.is_owned = ptr_is_owned(o);
20535         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20536         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
20537         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
20538         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
20539         return tag_ptr(ret_conv, true);
20540 }
20541
20542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20543         void* e_ptr = untag_ptr(e);
20544         CHECK_ACCESS(e_ptr);
20545         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20546         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20547         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
20548         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
20549         return tag_ptr(ret_conv, true);
20550 }
20551
20552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20553         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
20554         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
20555         return ret_conv;
20556 }
20557
20558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20559         if (!ptr_is_owned(_res)) return;
20560         void* _res_ptr = untag_ptr(_res);
20561         CHECK_ACCESS(_res_ptr);
20562         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
20563         FREE(untag_ptr(_res));
20564         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
20565 }
20566
20567 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
20568         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
20569         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
20570         return tag_ptr(ret_conv, true);
20571 }
20572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20573         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
20574         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
20575         return ret_conv;
20576 }
20577
20578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20579         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
20580         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
20581         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
20582         return tag_ptr(ret_conv, true);
20583 }
20584
20585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20586         LDKStaticPaymentOutputDescriptor o_conv;
20587         o_conv.inner = untag_ptr(o);
20588         o_conv.is_owned = ptr_is_owned(o);
20589         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20590         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
20591         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
20592         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
20593         return tag_ptr(ret_conv, true);
20594 }
20595
20596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20597         void* e_ptr = untag_ptr(e);
20598         CHECK_ACCESS(e_ptr);
20599         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20600         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20601         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
20602         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
20603         return tag_ptr(ret_conv, true);
20604 }
20605
20606 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20607         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
20608         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
20609         return ret_conv;
20610 }
20611
20612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20613         if (!ptr_is_owned(_res)) return;
20614         void* _res_ptr = untag_ptr(_res);
20615         CHECK_ACCESS(_res_ptr);
20616         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
20617         FREE(untag_ptr(_res));
20618         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
20619 }
20620
20621 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
20622         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
20623         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
20624         return tag_ptr(ret_conv, true);
20625 }
20626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20627         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
20628         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
20629         return ret_conv;
20630 }
20631
20632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20633         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
20634         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
20635         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
20636         return tag_ptr(ret_conv, true);
20637 }
20638
20639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20640         void* o_ptr = untag_ptr(o);
20641         CHECK_ACCESS(o_ptr);
20642         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
20643         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(o));
20644         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20645         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
20646         return tag_ptr(ret_conv, true);
20647 }
20648
20649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20650         void* e_ptr = untag_ptr(e);
20651         CHECK_ACCESS(e_ptr);
20652         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20653         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20654         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20655         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
20656         return tag_ptr(ret_conv, true);
20657 }
20658
20659 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20660         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(o);
20661         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
20662         return ret_conv;
20663 }
20664
20665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20666         if (!ptr_is_owned(_res)) return;
20667         void* _res_ptr = untag_ptr(_res);
20668         CHECK_ACCESS(_res_ptr);
20669         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
20670         FREE(untag_ptr(_res));
20671         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
20672 }
20673
20674 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
20675         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20676         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
20677         return tag_ptr(ret_conv, true);
20678 }
20679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20680         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
20681         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
20682         return ret_conv;
20683 }
20684
20685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20686         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
20687         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20688         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
20689         return tag_ptr(ret_conv, true);
20690 }
20691
20692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20693         LDKCVec_PaymentPreimageZ _res_constr;
20694         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20695         if (_res_constr.datalen > 0)
20696                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
20697         else
20698                 _res_constr.data = NULL;
20699         for (size_t i = 0; i < _res_constr.datalen; i++) {
20700                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20701                 LDKThirtyTwoBytes _res_conv_8_ref;
20702                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
20703                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
20704                 _res_constr.data[i] = _res_conv_8_ref;
20705         }
20706         CVec_PaymentPreimageZ_free(_res_constr);
20707 }
20708
20709 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
20710         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
20711         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
20712         return tag_ptr(ret_conv, true);
20713 }
20714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20715         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(arg);
20716         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
20717         return ret_conv;
20718 }
20719
20720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20721         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(orig);
20722         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
20723         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
20724         return tag_ptr(ret_conv, true);
20725 }
20726
20727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
20728         LDKSignature a_ref;
20729         CHECK((*env)->GetArrayLength(env, a) == 64);
20730         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
20731         LDKCVec_SignatureZ b_constr;
20732         b_constr.datalen = (*env)->GetArrayLength(env, b);
20733         if (b_constr.datalen > 0)
20734                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
20735         else
20736                 b_constr.data = NULL;
20737         for (size_t i = 0; i < b_constr.datalen; i++) {
20738                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
20739                 LDKSignature b_conv_8_ref;
20740                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
20741                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
20742                 b_constr.data[i] = b_conv_8_ref;
20743         }
20744         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
20745         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
20746         return tag_ptr(ret_conv, true);
20747 }
20748
20749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_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         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
20754         FREE(untag_ptr(_res));
20755         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
20756 }
20757
20758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20759         void* o_ptr = untag_ptr(o);
20760         CHECK_ACCESS(o_ptr);
20761         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
20762         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(o));
20763         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
20764         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
20765         return tag_ptr(ret_conv, true);
20766 }
20767
20768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
20769         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
20770         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
20771         return tag_ptr(ret_conv, true);
20772 }
20773
20774 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20775         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(o);
20776         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
20777         return ret_conv;
20778 }
20779
20780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20781         if (!ptr_is_owned(_res)) return;
20782         void* _res_ptr = untag_ptr(_res);
20783         CHECK_ACCESS(_res_ptr);
20784         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
20785         FREE(untag_ptr(_res));
20786         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
20787 }
20788
20789 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
20790         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
20791         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
20792         return tag_ptr(ret_conv, true);
20793 }
20794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20795         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(arg);
20796         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
20797         return ret_conv;
20798 }
20799
20800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20801         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(orig);
20802         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
20803         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
20804         return tag_ptr(ret_conv, true);
20805 }
20806
20807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20808         LDKSignature o_ref;
20809         CHECK((*env)->GetArrayLength(env, o) == 64);
20810         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
20811         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20812         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
20813         return tag_ptr(ret_conv, true);
20814 }
20815
20816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
20817         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20818         *ret_conv = CResult_SignatureNoneZ_err();
20819         return tag_ptr(ret_conv, true);
20820 }
20821
20822 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20823         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(o);
20824         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
20825         return ret_conv;
20826 }
20827
20828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20829         if (!ptr_is_owned(_res)) return;
20830         void* _res_ptr = untag_ptr(_res);
20831         CHECK_ACCESS(_res_ptr);
20832         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
20833         FREE(untag_ptr(_res));
20834         CResult_SignatureNoneZ_free(_res_conv);
20835 }
20836
20837 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
20838         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20839         *ret_conv = CResult_SignatureNoneZ_clone(arg);
20840         return tag_ptr(ret_conv, true);
20841 }
20842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20843         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(arg);
20844         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
20845         return ret_conv;
20846 }
20847
20848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20849         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(orig);
20850         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20851         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
20852         return tag_ptr(ret_conv, true);
20853 }
20854
20855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20856         LDKPublicKey o_ref;
20857         CHECK((*env)->GetArrayLength(env, o) == 33);
20858         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
20859         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20860         *ret_conv = CResult_PublicKeyNoneZ_ok(o_ref);
20861         return tag_ptr(ret_conv, true);
20862 }
20863
20864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1err(JNIEnv *env, jclass clz) {
20865         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20866         *ret_conv = CResult_PublicKeyNoneZ_err();
20867         return tag_ptr(ret_conv, true);
20868 }
20869
20870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20871         LDKCResult_PublicKeyNoneZ* o_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(o);
20872         jboolean ret_conv = CResult_PublicKeyNoneZ_is_ok(o_conv);
20873         return ret_conv;
20874 }
20875
20876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20877         if (!ptr_is_owned(_res)) return;
20878         void* _res_ptr = untag_ptr(_res);
20879         CHECK_ACCESS(_res_ptr);
20880         LDKCResult_PublicKeyNoneZ _res_conv = *(LDKCResult_PublicKeyNoneZ*)(_res_ptr);
20881         FREE(untag_ptr(_res));
20882         CResult_PublicKeyNoneZ_free(_res_conv);
20883 }
20884
20885 static inline uint64_t CResult_PublicKeyNoneZ_clone_ptr(LDKCResult_PublicKeyNoneZ *NONNULL_PTR arg) {
20886         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20887         *ret_conv = CResult_PublicKeyNoneZ_clone(arg);
20888         return tag_ptr(ret_conv, true);
20889 }
20890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20891         LDKCResult_PublicKeyNoneZ* arg_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(arg);
20892         int64_t ret_conv = CResult_PublicKeyNoneZ_clone_ptr(arg_conv);
20893         return ret_conv;
20894 }
20895
20896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20897         LDKCResult_PublicKeyNoneZ* orig_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(orig);
20898         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20899         *ret_conv = CResult_PublicKeyNoneZ_clone(orig_conv);
20900         return tag_ptr(ret_conv, true);
20901 }
20902
20903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20904         void* o_ptr = untag_ptr(o);
20905         CHECK_ACCESS(o_ptr);
20906         LDKBigEndianScalar o_conv = *(LDKBigEndianScalar*)(o_ptr);
20907         // WARNING: we may need a move here but no clone is available for LDKBigEndianScalar
20908         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20909         *ret_copy = COption_ScalarZ_some(o_conv);
20910         int64_t ret_ref = tag_ptr(ret_copy, true);
20911         return ret_ref;
20912 }
20913
20914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1none(JNIEnv *env, jclass clz) {
20915         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20916         *ret_copy = COption_ScalarZ_none();
20917         int64_t ret_ref = tag_ptr(ret_copy, true);
20918         return ret_ref;
20919 }
20920
20921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20922         if (!ptr_is_owned(_res)) return;
20923         void* _res_ptr = untag_ptr(_res);
20924         CHECK_ACCESS(_res_ptr);
20925         LDKCOption_ScalarZ _res_conv = *(LDKCOption_ScalarZ*)(_res_ptr);
20926         FREE(untag_ptr(_res));
20927         COption_ScalarZ_free(_res_conv);
20928 }
20929
20930 static inline uint64_t COption_ScalarZ_clone_ptr(LDKCOption_ScalarZ *NONNULL_PTR arg) {
20931         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20932         *ret_copy = COption_ScalarZ_clone(arg);
20933         int64_t ret_ref = tag_ptr(ret_copy, true);
20934         return ret_ref;
20935 }
20936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20937         LDKCOption_ScalarZ* arg_conv = (LDKCOption_ScalarZ*)untag_ptr(arg);
20938         int64_t ret_conv = COption_ScalarZ_clone_ptr(arg_conv);
20939         return ret_conv;
20940 }
20941
20942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20943         LDKCOption_ScalarZ* orig_conv = (LDKCOption_ScalarZ*)untag_ptr(orig);
20944         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20945         *ret_copy = COption_ScalarZ_clone(orig_conv);
20946         int64_t ret_ref = tag_ptr(ret_copy, true);
20947         return ret_ref;
20948 }
20949
20950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20951         LDKThirtyTwoBytes o_ref;
20952         CHECK((*env)->GetArrayLength(env, o) == 32);
20953         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20954         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20955         *ret_conv = CResult_SharedSecretNoneZ_ok(o_ref);
20956         return tag_ptr(ret_conv, true);
20957 }
20958
20959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1err(JNIEnv *env, jclass clz) {
20960         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20961         *ret_conv = CResult_SharedSecretNoneZ_err();
20962         return tag_ptr(ret_conv, true);
20963 }
20964
20965 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20966         LDKCResult_SharedSecretNoneZ* o_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(o);
20967         jboolean ret_conv = CResult_SharedSecretNoneZ_is_ok(o_conv);
20968         return ret_conv;
20969 }
20970
20971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20972         if (!ptr_is_owned(_res)) return;
20973         void* _res_ptr = untag_ptr(_res);
20974         CHECK_ACCESS(_res_ptr);
20975         LDKCResult_SharedSecretNoneZ _res_conv = *(LDKCResult_SharedSecretNoneZ*)(_res_ptr);
20976         FREE(untag_ptr(_res));
20977         CResult_SharedSecretNoneZ_free(_res_conv);
20978 }
20979
20980 static inline uint64_t CResult_SharedSecretNoneZ_clone_ptr(LDKCResult_SharedSecretNoneZ *NONNULL_PTR arg) {
20981         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20982         *ret_conv = CResult_SharedSecretNoneZ_clone(arg);
20983         return tag_ptr(ret_conv, true);
20984 }
20985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20986         LDKCResult_SharedSecretNoneZ* arg_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(arg);
20987         int64_t ret_conv = CResult_SharedSecretNoneZ_clone_ptr(arg_conv);
20988         return ret_conv;
20989 }
20990
20991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20992         LDKCResult_SharedSecretNoneZ* orig_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(orig);
20993         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20994         *ret_conv = CResult_SharedSecretNoneZ_clone(orig_conv);
20995         return tag_ptr(ret_conv, true);
20996 }
20997
20998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1U5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20999         LDKCVec_U5Z _res_constr;
21000         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21001         if (_res_constr.datalen > 0)
21002                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
21003         else
21004                 _res_constr.data = NULL;
21005         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
21006         for (size_t h = 0; h < _res_constr.datalen; h++) {
21007                 int8_t _res_conv_7 = _res_vals[h];
21008                 
21009                 _res_constr.data[h] = (LDKU5){ ._0 = _res_conv_7 };
21010         }
21011         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
21012         CVec_U5Z_free(_res_constr);
21013 }
21014
21015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21016         LDKRecoverableSignature o_ref;
21017         CHECK((*env)->GetArrayLength(env, o) == 68);
21018         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
21019         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21020         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
21021         return tag_ptr(ret_conv, true);
21022 }
21023
21024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
21025         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21026         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
21027         return tag_ptr(ret_conv, true);
21028 }
21029
21030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21031         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
21032         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
21033         return ret_conv;
21034 }
21035
21036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21037         if (!ptr_is_owned(_res)) return;
21038         void* _res_ptr = untag_ptr(_res);
21039         CHECK_ACCESS(_res_ptr);
21040         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
21041         FREE(untag_ptr(_res));
21042         CResult_RecoverableSignatureNoneZ_free(_res_conv);
21043 }
21044
21045 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
21046         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21047         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
21048         return tag_ptr(ret_conv, true);
21049 }
21050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21051         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
21052         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
21053         return ret_conv;
21054 }
21055
21056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21057         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
21058         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21059         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
21060         return tag_ptr(ret_conv, true);
21061 }
21062
21063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21064         void* o_ptr = untag_ptr(o);
21065         CHECK_ACCESS(o_ptr);
21066         LDKWriteableEcdsaChannelSigner o_conv = *(LDKWriteableEcdsaChannelSigner*)(o_ptr);
21067         if (o_conv.free == LDKWriteableEcdsaChannelSigner_JCalls_free) {
21068                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21069                 LDKWriteableEcdsaChannelSigner_JCalls_cloned(&o_conv);
21070         }
21071         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21072         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(o_conv);
21073         return tag_ptr(ret_conv, true);
21074 }
21075
21076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21077         void* e_ptr = untag_ptr(e);
21078         CHECK_ACCESS(e_ptr);
21079         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21080         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21081         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21082         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e_conv);
21083         return tag_ptr(ret_conv, true);
21084 }
21085
21086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21087         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* o_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(o);
21088         jboolean ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(o_conv);
21089         return ret_conv;
21090 }
21091
21092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21093         if (!ptr_is_owned(_res)) return;
21094         void* _res_ptr = untag_ptr(_res);
21095         CHECK_ACCESS(_res_ptr);
21096         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ _res_conv = *(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)(_res_ptr);
21097         FREE(untag_ptr(_res));
21098         CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(_res_conv);
21099 }
21100
21101 static inline uint64_t CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR arg) {
21102         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21103         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(arg);
21104         return tag_ptr(ret_conv, true);
21105 }
21106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21107         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* arg_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(arg);
21108         int64_t ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(arg_conv);
21109         return ret_conv;
21110 }
21111
21112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21113         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* orig_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(orig);
21114         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21115         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(orig_conv);
21116         return tag_ptr(ret_conv, true);
21117 }
21118
21119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21120         LDKCVec_CVec_u8ZZ _res_constr;
21121         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21122         if (_res_constr.datalen > 0)
21123                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
21124         else
21125                 _res_constr.data = NULL;
21126         for (size_t i = 0; i < _res_constr.datalen; i++) {
21127                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21128                 LDKCVec_u8Z _res_conv_8_ref;
21129                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
21130                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
21131                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
21132                 _res_constr.data[i] = _res_conv_8_ref;
21133         }
21134         CVec_CVec_u8ZZ_free(_res_constr);
21135 }
21136
21137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
21138         LDKCVec_CVec_u8ZZ o_constr;
21139         o_constr.datalen = (*env)->GetArrayLength(env, o);
21140         if (o_constr.datalen > 0)
21141                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
21142         else
21143                 o_constr.data = NULL;
21144         for (size_t i = 0; i < o_constr.datalen; i++) {
21145                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
21146                 LDKCVec_u8Z o_conv_8_ref;
21147                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
21148                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
21149                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
21150                 o_constr.data[i] = o_conv_8_ref;
21151         }
21152         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21153         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
21154         return tag_ptr(ret_conv, true);
21155 }
21156
21157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
21158         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21159         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
21160         return tag_ptr(ret_conv, true);
21161 }
21162
21163 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21164         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
21165         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
21166         return ret_conv;
21167 }
21168
21169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21170         if (!ptr_is_owned(_res)) return;
21171         void* _res_ptr = untag_ptr(_res);
21172         CHECK_ACCESS(_res_ptr);
21173         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
21174         FREE(untag_ptr(_res));
21175         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
21176 }
21177
21178 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
21179         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21180         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
21181         return tag_ptr(ret_conv, true);
21182 }
21183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21184         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
21185         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
21186         return ret_conv;
21187 }
21188
21189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21190         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
21191         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21192         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
21193         return tag_ptr(ret_conv, true);
21194 }
21195
21196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21197         LDKInMemorySigner o_conv;
21198         o_conv.inner = untag_ptr(o);
21199         o_conv.is_owned = ptr_is_owned(o);
21200         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21201         o_conv = InMemorySigner_clone(&o_conv);
21202         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21203         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
21204         return tag_ptr(ret_conv, true);
21205 }
21206
21207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21208         void* e_ptr = untag_ptr(e);
21209         CHECK_ACCESS(e_ptr);
21210         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21211         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21212         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21213         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
21214         return tag_ptr(ret_conv, true);
21215 }
21216
21217 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21218         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
21219         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
21220         return ret_conv;
21221 }
21222
21223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21224         if (!ptr_is_owned(_res)) return;
21225         void* _res_ptr = untag_ptr(_res);
21226         CHECK_ACCESS(_res_ptr);
21227         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
21228         FREE(untag_ptr(_res));
21229         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
21230 }
21231
21232 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
21233         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21234         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
21235         return tag_ptr(ret_conv, true);
21236 }
21237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21238         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
21239         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
21240         return ret_conv;
21241 }
21242
21243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21244         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
21245         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21246         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
21247         return tag_ptr(ret_conv, true);
21248 }
21249
21250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21251         LDKCVec_TxOutZ _res_constr;
21252         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21253         if (_res_constr.datalen > 0)
21254                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
21255         else
21256                 _res_constr.data = NULL;
21257         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21258         for (size_t h = 0; h < _res_constr.datalen; h++) {
21259                 int64_t _res_conv_7 = _res_vals[h];
21260                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
21261                 CHECK_ACCESS(_res_conv_7_ptr);
21262                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
21263                 FREE(untag_ptr(_res_conv_7));
21264                 _res_constr.data[h] = _res_conv_7_conv;
21265         }
21266         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21267         CVec_TxOutZ_free(_res_constr);
21268 }
21269
21270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21271         LDKTransaction o_ref;
21272         o_ref.datalen = (*env)->GetArrayLength(env, o);
21273         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
21274         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
21275         o_ref.data_is_owned = true;
21276         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21277         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
21278         return tag_ptr(ret_conv, true);
21279 }
21280
21281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
21282         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21283         *ret_conv = CResult_TransactionNoneZ_err();
21284         return tag_ptr(ret_conv, true);
21285 }
21286
21287 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21288         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
21289         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
21290         return ret_conv;
21291 }
21292
21293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21294         if (!ptr_is_owned(_res)) return;
21295         void* _res_ptr = untag_ptr(_res);
21296         CHECK_ACCESS(_res_ptr);
21297         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
21298         FREE(untag_ptr(_res));
21299         CResult_TransactionNoneZ_free(_res_conv);
21300 }
21301
21302 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
21303         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21304         *ret_conv = CResult_TransactionNoneZ_clone(arg);
21305         return tag_ptr(ret_conv, true);
21306 }
21307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21308         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
21309         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
21310         return ret_conv;
21311 }
21312
21313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21314         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
21315         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21316         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
21317         return tag_ptr(ret_conv, true);
21318 }
21319
21320 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
21321         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
21322         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
21323         return tag_ptr(ret_conv, true);
21324 }
21325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21326         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(arg);
21327         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
21328         return ret_conv;
21329 }
21330
21331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21332         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(orig);
21333         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
21334         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
21335         return tag_ptr(ret_conv, true);
21336 }
21337
21338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21339         LDKThirtyTwoBytes a_ref;
21340         CHECK((*env)->GetArrayLength(env, a) == 32);
21341         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21342         LDKChannelMonitor b_conv;
21343         b_conv.inner = untag_ptr(b);
21344         b_conv.is_owned = ptr_is_owned(b);
21345         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21346         b_conv = ChannelMonitor_clone(&b_conv);
21347         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
21348         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
21349         return tag_ptr(ret_conv, true);
21350 }
21351
21352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21353         if (!ptr_is_owned(_res)) return;
21354         void* _res_ptr = untag_ptr(_res);
21355         CHECK_ACCESS(_res_ptr);
21356         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
21357         FREE(untag_ptr(_res));
21358         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
21359 }
21360
21361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21362         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
21363         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21364         if (_res_constr.datalen > 0)
21365                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
21366         else
21367                 _res_constr.data = NULL;
21368         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21369         for (size_t j = 0; j < _res_constr.datalen; j++) {
21370                 int64_t _res_conv_35 = _res_vals[j];
21371                 void* _res_conv_35_ptr = untag_ptr(_res_conv_35);
21372                 CHECK_ACCESS(_res_conv_35_ptr);
21373                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
21374                 FREE(untag_ptr(_res_conv_35));
21375                 _res_constr.data[j] = _res_conv_35_conv;
21376         }
21377         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21378         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
21379 }
21380
21381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
21382         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
21383         o_constr.datalen = (*env)->GetArrayLength(env, o);
21384         if (o_constr.datalen > 0)
21385                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
21386         else
21387                 o_constr.data = NULL;
21388         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
21389         for (size_t j = 0; j < o_constr.datalen; j++) {
21390                 int64_t o_conv_35 = o_vals[j];
21391                 void* o_conv_35_ptr = untag_ptr(o_conv_35);
21392                 CHECK_ACCESS(o_conv_35_ptr);
21393                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
21394                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o_conv_35));
21395                 o_constr.data[j] = o_conv_35_conv;
21396         }
21397         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
21398         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21399         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
21400         return tag_ptr(ret_conv, true);
21401 }
21402
21403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21404         LDKIOError e_conv = LDKIOError_from_java(env, e);
21405         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21406         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
21407         return tag_ptr(ret_conv, true);
21408 }
21409
21410 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21411         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(o);
21412         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
21413         return ret_conv;
21414 }
21415
21416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21417         if (!ptr_is_owned(_res)) return;
21418         void* _res_ptr = untag_ptr(_res);
21419         CHECK_ACCESS(_res_ptr);
21420         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
21421         FREE(untag_ptr(_res));
21422         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
21423 }
21424
21425 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
21426         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21427         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
21428         return tag_ptr(ret_conv, true);
21429 }
21430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21431         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(arg);
21432         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
21433         return ret_conv;
21434 }
21435
21436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21437         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(orig);
21438         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21439         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
21440         return tag_ptr(ret_conv, true);
21441 }
21442
21443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
21444         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21445         *ret_copy = COption_u16Z_some(o);
21446         int64_t ret_ref = tag_ptr(ret_copy, true);
21447         return ret_ref;
21448 }
21449
21450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
21451         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21452         *ret_copy = COption_u16Z_none();
21453         int64_t ret_ref = tag_ptr(ret_copy, true);
21454         return ret_ref;
21455 }
21456
21457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
21458         if (!ptr_is_owned(_res)) return;
21459         void* _res_ptr = untag_ptr(_res);
21460         CHECK_ACCESS(_res_ptr);
21461         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
21462         FREE(untag_ptr(_res));
21463         COption_u16Z_free(_res_conv);
21464 }
21465
21466 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
21467         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21468         *ret_copy = COption_u16Z_clone(arg);
21469         int64_t ret_ref = tag_ptr(ret_copy, true);
21470         return ret_ref;
21471 }
21472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21473         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
21474         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
21475         return ret_conv;
21476 }
21477
21478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21479         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
21480         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21481         *ret_copy = COption_u16Z_clone(orig_conv);
21482         int64_t ret_ref = tag_ptr(ret_copy, true);
21483         return ret_ref;
21484 }
21485
21486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21487         LDKThirtyTwoBytes o_ref;
21488         CHECK((*env)->GetArrayLength(env, o) == 32);
21489         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21490         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21491         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
21492         return tag_ptr(ret_conv, true);
21493 }
21494
21495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21496         void* e_ptr = untag_ptr(e);
21497         CHECK_ACCESS(e_ptr);
21498         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21499         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21500         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21501         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
21502         return tag_ptr(ret_conv, true);
21503 }
21504
21505 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21506         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(o);
21507         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
21508         return ret_conv;
21509 }
21510
21511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21512         if (!ptr_is_owned(_res)) return;
21513         void* _res_ptr = untag_ptr(_res);
21514         CHECK_ACCESS(_res_ptr);
21515         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
21516         FREE(untag_ptr(_res));
21517         CResult__u832APIErrorZ_free(_res_conv);
21518 }
21519
21520 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
21521         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21522         *ret_conv = CResult__u832APIErrorZ_clone(arg);
21523         return tag_ptr(ret_conv, true);
21524 }
21525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21526         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(arg);
21527         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
21528         return ret_conv;
21529 }
21530
21531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21532         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(orig);
21533         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21534         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
21535         return tag_ptr(ret_conv, true);
21536 }
21537
21538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RecentPaymentDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21539         LDKCVec_RecentPaymentDetailsZ _res_constr;
21540         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21541         if (_res_constr.datalen > 0)
21542                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRecentPaymentDetails), "LDKCVec_RecentPaymentDetailsZ Elements");
21543         else
21544                 _res_constr.data = NULL;
21545         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21546         for (size_t w = 0; w < _res_constr.datalen; w++) {
21547                 int64_t _res_conv_22 = _res_vals[w];
21548                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
21549                 CHECK_ACCESS(_res_conv_22_ptr);
21550                 LDKRecentPaymentDetails _res_conv_22_conv = *(LDKRecentPaymentDetails*)(_res_conv_22_ptr);
21551                 FREE(untag_ptr(_res_conv_22));
21552                 _res_constr.data[w] = _res_conv_22_conv;
21553         }
21554         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21555         CVec_RecentPaymentDetailsZ_free(_res_constr);
21556 }
21557
21558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
21559         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21560         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
21561         return tag_ptr(ret_conv, true);
21562 }
21563
21564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21565         void* e_ptr = untag_ptr(e);
21566         CHECK_ACCESS(e_ptr);
21567         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21568         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21569         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21570         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
21571         return tag_ptr(ret_conv, true);
21572 }
21573
21574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21575         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
21576         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
21577         return ret_conv;
21578 }
21579
21580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21581         if (!ptr_is_owned(_res)) return;
21582         void* _res_ptr = untag_ptr(_res);
21583         CHECK_ACCESS(_res_ptr);
21584         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
21585         FREE(untag_ptr(_res));
21586         CResult_NonePaymentSendFailureZ_free(_res_conv);
21587 }
21588
21589 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
21590         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21591         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
21592         return tag_ptr(ret_conv, true);
21593 }
21594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21595         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
21596         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
21597         return ret_conv;
21598 }
21599
21600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21601         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
21602         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21603         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
21604         return tag_ptr(ret_conv, true);
21605 }
21606
21607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1ok(JNIEnv *env, jclass clz) {
21608         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21609         *ret_conv = CResult_NoneRetryableSendFailureZ_ok();
21610         return tag_ptr(ret_conv, true);
21611 }
21612
21613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1err(JNIEnv *env, jclass clz, jclass e) {
21614         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_java(env, e);
21615         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21616         *ret_conv = CResult_NoneRetryableSendFailureZ_err(e_conv);
21617         return tag_ptr(ret_conv, true);
21618 }
21619
21620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21621         LDKCResult_NoneRetryableSendFailureZ* o_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(o);
21622         jboolean ret_conv = CResult_NoneRetryableSendFailureZ_is_ok(o_conv);
21623         return ret_conv;
21624 }
21625
21626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21627         if (!ptr_is_owned(_res)) return;
21628         void* _res_ptr = untag_ptr(_res);
21629         CHECK_ACCESS(_res_ptr);
21630         LDKCResult_NoneRetryableSendFailureZ _res_conv = *(LDKCResult_NoneRetryableSendFailureZ*)(_res_ptr);
21631         FREE(untag_ptr(_res));
21632         CResult_NoneRetryableSendFailureZ_free(_res_conv);
21633 }
21634
21635 static inline uint64_t CResult_NoneRetryableSendFailureZ_clone_ptr(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR arg) {
21636         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21637         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(arg);
21638         return tag_ptr(ret_conv, true);
21639 }
21640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21641         LDKCResult_NoneRetryableSendFailureZ* arg_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(arg);
21642         int64_t ret_conv = CResult_NoneRetryableSendFailureZ_clone_ptr(arg_conv);
21643         return ret_conv;
21644 }
21645
21646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21647         LDKCResult_NoneRetryableSendFailureZ* orig_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(orig);
21648         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21649         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(orig_conv);
21650         return tag_ptr(ret_conv, true);
21651 }
21652
21653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21654         LDKThirtyTwoBytes o_ref;
21655         CHECK((*env)->GetArrayLength(env, o) == 32);
21656         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21657         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21658         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
21659         return tag_ptr(ret_conv, true);
21660 }
21661
21662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21663         void* e_ptr = untag_ptr(e);
21664         CHECK_ACCESS(e_ptr);
21665         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21666         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21667         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21668         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
21669         return tag_ptr(ret_conv, true);
21670 }
21671
21672 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21673         LDKCResult_PaymentHashPaymentSendFailureZ* o_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(o);
21674         jboolean ret_conv = CResult_PaymentHashPaymentSendFailureZ_is_ok(o_conv);
21675         return ret_conv;
21676 }
21677
21678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_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_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(_res_ptr);
21683         FREE(untag_ptr(_res));
21684         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
21685 }
21686
21687 static inline uint64_t CResult_PaymentHashPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR arg) {
21688         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21689         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(arg);
21690         return tag_ptr(ret_conv, true);
21691 }
21692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21693         LDKCResult_PaymentHashPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(arg);
21694         int64_t ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone_ptr(arg_conv);
21695         return ret_conv;
21696 }
21697
21698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21699         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(orig);
21700         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21701         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
21702         return tag_ptr(ret_conv, true);
21703 }
21704
21705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21706         LDKThirtyTwoBytes o_ref;
21707         CHECK((*env)->GetArrayLength(env, o) == 32);
21708         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21709         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21710         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_ok(o_ref);
21711         return tag_ptr(ret_conv, true);
21712 }
21713
21714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1err(JNIEnv *env, jclass clz, jclass e) {
21715         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_java(env, e);
21716         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21717         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_err(e_conv);
21718         return tag_ptr(ret_conv, true);
21719 }
21720
21721 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21722         LDKCResult_PaymentHashRetryableSendFailureZ* o_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(o);
21723         jboolean ret_conv = CResult_PaymentHashRetryableSendFailureZ_is_ok(o_conv);
21724         return ret_conv;
21725 }
21726
21727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21728         if (!ptr_is_owned(_res)) return;
21729         void* _res_ptr = untag_ptr(_res);
21730         CHECK_ACCESS(_res_ptr);
21731         LDKCResult_PaymentHashRetryableSendFailureZ _res_conv = *(LDKCResult_PaymentHashRetryableSendFailureZ*)(_res_ptr);
21732         FREE(untag_ptr(_res));
21733         CResult_PaymentHashRetryableSendFailureZ_free(_res_conv);
21734 }
21735
21736 static inline uint64_t CResult_PaymentHashRetryableSendFailureZ_clone_ptr(LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR arg) {
21737         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21738         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone(arg);
21739         return tag_ptr(ret_conv, true);
21740 }
21741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21742         LDKCResult_PaymentHashRetryableSendFailureZ* arg_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(arg);
21743         int64_t ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone_ptr(arg_conv);
21744         return ret_conv;
21745 }
21746
21747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21748         LDKCResult_PaymentHashRetryableSendFailureZ* orig_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(orig);
21749         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21750         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone(orig_conv);
21751         return tag_ptr(ret_conv, true);
21752 }
21753
21754 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
21755         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21756         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
21757         return tag_ptr(ret_conv, true);
21758 }
21759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21760         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(arg);
21761         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
21762         return ret_conv;
21763 }
21764
21765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21766         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(orig);
21767         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21768         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
21769         return tag_ptr(ret_conv, true);
21770 }
21771
21772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21773         LDKThirtyTwoBytes a_ref;
21774         CHECK((*env)->GetArrayLength(env, a) == 32);
21775         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21776         LDKThirtyTwoBytes b_ref;
21777         CHECK((*env)->GetArrayLength(env, b) == 32);
21778         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21779         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21780         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
21781         return tag_ptr(ret_conv, true);
21782 }
21783
21784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21785         if (!ptr_is_owned(_res)) return;
21786         void* _res_ptr = untag_ptr(_res);
21787         CHECK_ACCESS(_res_ptr);
21788         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
21789         FREE(untag_ptr(_res));
21790         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
21791 }
21792
21793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21794         void* o_ptr = untag_ptr(o);
21795         CHECK_ACCESS(o_ptr);
21796         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
21797         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(o));
21798         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21799         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
21800         return tag_ptr(ret_conv, true);
21801 }
21802
21803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21804         void* e_ptr = untag_ptr(e);
21805         CHECK_ACCESS(e_ptr);
21806         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21807         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21808         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21809         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
21810         return tag_ptr(ret_conv, true);
21811 }
21812
21813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21814         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(o);
21815         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
21816         return ret_conv;
21817 }
21818
21819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21820         if (!ptr_is_owned(_res)) return;
21821         void* _res_ptr = untag_ptr(_res);
21822         CHECK_ACCESS(_res_ptr);
21823         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
21824         FREE(untag_ptr(_res));
21825         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
21826 }
21827
21828 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
21829         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21830         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
21831         return tag_ptr(ret_conv, true);
21832 }
21833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21834         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(arg);
21835         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
21836         return ret_conv;
21837 }
21838
21839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21840         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(orig);
21841         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21842         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
21843         return tag_ptr(ret_conv, true);
21844 }
21845
21846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21847         LDKCVec_ThirtyTwoBytesZ _res_constr;
21848         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21849         if (_res_constr.datalen > 0)
21850                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
21851         else
21852                 _res_constr.data = NULL;
21853         for (size_t i = 0; i < _res_constr.datalen; i++) {
21854                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21855                 LDKThirtyTwoBytes _res_conv_8_ref;
21856                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
21857                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
21858                 _res_constr.data[i] = _res_conv_8_ref;
21859         }
21860         CVec_ThirtyTwoBytesZ_free(_res_constr);
21861 }
21862
21863 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
21864         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21865         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
21866         return tag_ptr(ret_conv, true);
21867 }
21868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21869         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(arg);
21870         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
21871         return ret_conv;
21872 }
21873
21874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21875         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(orig);
21876         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21877         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
21878         return tag_ptr(ret_conv, true);
21879 }
21880
21881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21882         LDKThirtyTwoBytes a_ref;
21883         CHECK((*env)->GetArrayLength(env, a) == 32);
21884         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21885         LDKThirtyTwoBytes b_ref;
21886         CHECK((*env)->GetArrayLength(env, b) == 32);
21887         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21888         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21889         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
21890         return tag_ptr(ret_conv, true);
21891 }
21892
21893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21894         if (!ptr_is_owned(_res)) return;
21895         void* _res_ptr = untag_ptr(_res);
21896         CHECK_ACCESS(_res_ptr);
21897         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
21898         FREE(untag_ptr(_res));
21899         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
21900 }
21901
21902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21903         void* o_ptr = untag_ptr(o);
21904         CHECK_ACCESS(o_ptr);
21905         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21906         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21907         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21908         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
21909         return tag_ptr(ret_conv, true);
21910 }
21911
21912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
21913         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21914         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
21915         return tag_ptr(ret_conv, true);
21916 }
21917
21918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21919         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(o);
21920         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
21921         return ret_conv;
21922 }
21923
21924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21925         if (!ptr_is_owned(_res)) return;
21926         void* _res_ptr = untag_ptr(_res);
21927         CHECK_ACCESS(_res_ptr);
21928         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
21929         FREE(untag_ptr(_res));
21930         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
21931 }
21932
21933 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
21934         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21935         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
21936         return tag_ptr(ret_conv, true);
21937 }
21938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21939         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(arg);
21940         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
21941         return ret_conv;
21942 }
21943
21944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21945         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(orig);
21946         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21947         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
21948         return tag_ptr(ret_conv, true);
21949 }
21950
21951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21952         void* o_ptr = untag_ptr(o);
21953         CHECK_ACCESS(o_ptr);
21954         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21955         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21956         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21957         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
21958         return tag_ptr(ret_conv, true);
21959 }
21960
21961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21962         void* e_ptr = untag_ptr(e);
21963         CHECK_ACCESS(e_ptr);
21964         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21965         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21966         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21967         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
21968         return tag_ptr(ret_conv, true);
21969 }
21970
21971 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21972         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(o);
21973         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
21974         return ret_conv;
21975 }
21976
21977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21978         if (!ptr_is_owned(_res)) return;
21979         void* _res_ptr = untag_ptr(_res);
21980         CHECK_ACCESS(_res_ptr);
21981         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
21982         FREE(untag_ptr(_res));
21983         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
21984 }
21985
21986 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
21987         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21988         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
21989         return tag_ptr(ret_conv, true);
21990 }
21991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21992         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(arg);
21993         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
21994         return ret_conv;
21995 }
21996
21997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21998         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(orig);
21999         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
22000         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
22001         return tag_ptr(ret_conv, true);
22002 }
22003
22004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22005         LDKThirtyTwoBytes o_ref;
22006         CHECK((*env)->GetArrayLength(env, o) == 32);
22007         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22008         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22009         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
22010         return tag_ptr(ret_conv, true);
22011 }
22012
22013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
22014         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22015         *ret_conv = CResult_PaymentSecretNoneZ_err();
22016         return tag_ptr(ret_conv, true);
22017 }
22018
22019 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22020         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(o);
22021         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
22022         return ret_conv;
22023 }
22024
22025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22026         if (!ptr_is_owned(_res)) return;
22027         void* _res_ptr = untag_ptr(_res);
22028         CHECK_ACCESS(_res_ptr);
22029         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
22030         FREE(untag_ptr(_res));
22031         CResult_PaymentSecretNoneZ_free(_res_conv);
22032 }
22033
22034 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
22035         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22036         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
22037         return tag_ptr(ret_conv, true);
22038 }
22039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22040         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(arg);
22041         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
22042         return ret_conv;
22043 }
22044
22045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22046         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(orig);
22047         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22048         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
22049         return tag_ptr(ret_conv, true);
22050 }
22051
22052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22053         LDKThirtyTwoBytes o_ref;
22054         CHECK((*env)->GetArrayLength(env, o) == 32);
22055         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22056         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22057         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
22058         return tag_ptr(ret_conv, true);
22059 }
22060
22061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22062         void* e_ptr = untag_ptr(e);
22063         CHECK_ACCESS(e_ptr);
22064         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
22065         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
22066         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22067         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
22068         return tag_ptr(ret_conv, true);
22069 }
22070
22071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22072         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(o);
22073         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
22074         return ret_conv;
22075 }
22076
22077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22078         if (!ptr_is_owned(_res)) return;
22079         void* _res_ptr = untag_ptr(_res);
22080         CHECK_ACCESS(_res_ptr);
22081         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
22082         FREE(untag_ptr(_res));
22083         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
22084 }
22085
22086 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
22087         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22088         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
22089         return tag_ptr(ret_conv, true);
22090 }
22091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22092         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(arg);
22093         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
22094         return ret_conv;
22095 }
22096
22097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22098         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(orig);
22099         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22100         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
22101         return tag_ptr(ret_conv, true);
22102 }
22103
22104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22105         LDKThirtyTwoBytes o_ref;
22106         CHECK((*env)->GetArrayLength(env, o) == 32);
22107         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22108         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22109         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
22110         return tag_ptr(ret_conv, true);
22111 }
22112
22113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22114         void* e_ptr = untag_ptr(e);
22115         CHECK_ACCESS(e_ptr);
22116         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
22117         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
22118         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22119         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
22120         return tag_ptr(ret_conv, true);
22121 }
22122
22123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22124         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(o);
22125         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
22126         return ret_conv;
22127 }
22128
22129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22130         if (!ptr_is_owned(_res)) return;
22131         void* _res_ptr = untag_ptr(_res);
22132         CHECK_ACCESS(_res_ptr);
22133         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
22134         FREE(untag_ptr(_res));
22135         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
22136 }
22137
22138 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
22139         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22140         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
22141         return tag_ptr(ret_conv, true);
22142 }
22143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22144         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(arg);
22145         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
22146         return ret_conv;
22147 }
22148
22149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22150         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(orig);
22151         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22152         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
22153         return tag_ptr(ret_conv, true);
22154 }
22155
22156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22157         LDKCounterpartyForwardingInfo o_conv;
22158         o_conv.inner = untag_ptr(o);
22159         o_conv.is_owned = ptr_is_owned(o);
22160         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22161         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
22162         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22163         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
22164         return tag_ptr(ret_conv, true);
22165 }
22166
22167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22168         void* e_ptr = untag_ptr(e);
22169         CHECK_ACCESS(e_ptr);
22170         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22171         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22172         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22173         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
22174         return tag_ptr(ret_conv, true);
22175 }
22176
22177 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22178         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
22179         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
22180         return ret_conv;
22181 }
22182
22183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22184         if (!ptr_is_owned(_res)) return;
22185         void* _res_ptr = untag_ptr(_res);
22186         CHECK_ACCESS(_res_ptr);
22187         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
22188         FREE(untag_ptr(_res));
22189         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
22190 }
22191
22192 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
22193         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22194         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
22195         return tag_ptr(ret_conv, true);
22196 }
22197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22198         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
22199         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
22200         return ret_conv;
22201 }
22202
22203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22204         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
22205         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22206         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
22207         return tag_ptr(ret_conv, true);
22208 }
22209
22210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22211         LDKChannelCounterparty o_conv;
22212         o_conv.inner = untag_ptr(o);
22213         o_conv.is_owned = ptr_is_owned(o);
22214         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22215         o_conv = ChannelCounterparty_clone(&o_conv);
22216         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22217         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
22218         return tag_ptr(ret_conv, true);
22219 }
22220
22221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22222         void* e_ptr = untag_ptr(e);
22223         CHECK_ACCESS(e_ptr);
22224         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22225         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22226         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22227         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
22228         return tag_ptr(ret_conv, true);
22229 }
22230
22231 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22232         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
22233         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
22234         return ret_conv;
22235 }
22236
22237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22238         if (!ptr_is_owned(_res)) return;
22239         void* _res_ptr = untag_ptr(_res);
22240         CHECK_ACCESS(_res_ptr);
22241         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
22242         FREE(untag_ptr(_res));
22243         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
22244 }
22245
22246 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
22247         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22248         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
22249         return tag_ptr(ret_conv, true);
22250 }
22251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22252         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
22253         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
22254         return ret_conv;
22255 }
22256
22257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22258         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
22259         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22260         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
22261         return tag_ptr(ret_conv, true);
22262 }
22263
22264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22265         LDKChannelDetails o_conv;
22266         o_conv.inner = untag_ptr(o);
22267         o_conv.is_owned = ptr_is_owned(o);
22268         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22269         o_conv = ChannelDetails_clone(&o_conv);
22270         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22271         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
22272         return tag_ptr(ret_conv, true);
22273 }
22274
22275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22276         void* e_ptr = untag_ptr(e);
22277         CHECK_ACCESS(e_ptr);
22278         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22279         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22280         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22281         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
22282         return tag_ptr(ret_conv, true);
22283 }
22284
22285 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22286         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
22287         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
22288         return ret_conv;
22289 }
22290
22291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22292         if (!ptr_is_owned(_res)) return;
22293         void* _res_ptr = untag_ptr(_res);
22294         CHECK_ACCESS(_res_ptr);
22295         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
22296         FREE(untag_ptr(_res));
22297         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
22298 }
22299
22300 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
22301         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22302         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
22303         return tag_ptr(ret_conv, true);
22304 }
22305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22306         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
22307         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
22308         return ret_conv;
22309 }
22310
22311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22312         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
22313         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22314         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
22315         return tag_ptr(ret_conv, true);
22316 }
22317
22318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22319         LDKPhantomRouteHints o_conv;
22320         o_conv.inner = untag_ptr(o);
22321         o_conv.is_owned = ptr_is_owned(o);
22322         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22323         o_conv = PhantomRouteHints_clone(&o_conv);
22324         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22325         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
22326         return tag_ptr(ret_conv, true);
22327 }
22328
22329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22330         void* e_ptr = untag_ptr(e);
22331         CHECK_ACCESS(e_ptr);
22332         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22333         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22334         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22335         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
22336         return tag_ptr(ret_conv, true);
22337 }
22338
22339 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22340         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
22341         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
22342         return ret_conv;
22343 }
22344
22345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22346         if (!ptr_is_owned(_res)) return;
22347         void* _res_ptr = untag_ptr(_res);
22348         CHECK_ACCESS(_res_ptr);
22349         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
22350         FREE(untag_ptr(_res));
22351         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
22352 }
22353
22354 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
22355         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22356         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
22357         return tag_ptr(ret_conv, true);
22358 }
22359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22360         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
22361         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
22362         return ret_conv;
22363 }
22364
22365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22366         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
22367         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22368         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
22369         return tag_ptr(ret_conv, true);
22370 }
22371
22372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22373         LDKCVec_ChannelMonitorZ _res_constr;
22374         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22375         if (_res_constr.datalen > 0)
22376                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
22377         else
22378                 _res_constr.data = NULL;
22379         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22380         for (size_t q = 0; q < _res_constr.datalen; q++) {
22381                 int64_t _res_conv_16 = _res_vals[q];
22382                 LDKChannelMonitor _res_conv_16_conv;
22383                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
22384                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
22385                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
22386                 _res_constr.data[q] = _res_conv_16_conv;
22387         }
22388         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22389         CVec_ChannelMonitorZ_free(_res_constr);
22390 }
22391
22392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
22393         LDKThirtyTwoBytes a_ref;
22394         CHECK((*env)->GetArrayLength(env, a) == 32);
22395         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22396         LDKChannelManager b_conv;
22397         b_conv.inner = untag_ptr(b);
22398         b_conv.is_owned = ptr_is_owned(b);
22399         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22400         // WARNING: we need a move here but no clone is available for LDKChannelManager
22401         
22402         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
22403         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
22404         return tag_ptr(ret_conv, true);
22405 }
22406
22407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22408         if (!ptr_is_owned(_res)) return;
22409         void* _res_ptr = untag_ptr(_res);
22410         CHECK_ACCESS(_res_ptr);
22411         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
22412         FREE(untag_ptr(_res));
22413         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
22414 }
22415
22416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22417         void* o_ptr = untag_ptr(o);
22418         CHECK_ACCESS(o_ptr);
22419         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
22420         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
22421         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
22422         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
22423         return tag_ptr(ret_conv, true);
22424 }
22425
22426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22427         void* e_ptr = untag_ptr(e);
22428         CHECK_ACCESS(e_ptr);
22429         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22430         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22431         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
22432         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
22433         return tag_ptr(ret_conv, true);
22434 }
22435
22436 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22437         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(o);
22438         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
22439         return ret_conv;
22440 }
22441
22442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22443         if (!ptr_is_owned(_res)) return;
22444         void* _res_ptr = untag_ptr(_res);
22445         CHECK_ACCESS(_res_ptr);
22446         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
22447         FREE(untag_ptr(_res));
22448         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
22449 }
22450
22451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22452         LDKChannelConfig o_conv;
22453         o_conv.inner = untag_ptr(o);
22454         o_conv.is_owned = ptr_is_owned(o);
22455         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22456         o_conv = ChannelConfig_clone(&o_conv);
22457         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22458         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
22459         return tag_ptr(ret_conv, true);
22460 }
22461
22462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22463         void* e_ptr = untag_ptr(e);
22464         CHECK_ACCESS(e_ptr);
22465         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22466         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22467         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22468         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
22469         return tag_ptr(ret_conv, true);
22470 }
22471
22472 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22473         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
22474         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
22475         return ret_conv;
22476 }
22477
22478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22479         if (!ptr_is_owned(_res)) return;
22480         void* _res_ptr = untag_ptr(_res);
22481         CHECK_ACCESS(_res_ptr);
22482         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
22483         FREE(untag_ptr(_res));
22484         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
22485 }
22486
22487 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
22488         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22489         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
22490         return tag_ptr(ret_conv, true);
22491 }
22492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22493         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
22494         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
22495         return ret_conv;
22496 }
22497
22498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22499         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
22500         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22501         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
22502         return tag_ptr(ret_conv, true);
22503 }
22504
22505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22506         void* o_ptr = untag_ptr(o);
22507         CHECK_ACCESS(o_ptr);
22508         LDKAPIError o_conv = *(LDKAPIError*)(o_ptr);
22509         o_conv = APIError_clone((LDKAPIError*)untag_ptr(o));
22510         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22511         *ret_copy = COption_APIErrorZ_some(o_conv);
22512         int64_t ret_ref = tag_ptr(ret_copy, true);
22513         return ret_ref;
22514 }
22515
22516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1none(JNIEnv *env, jclass clz) {
22517         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22518         *ret_copy = COption_APIErrorZ_none();
22519         int64_t ret_ref = tag_ptr(ret_copy, true);
22520         return ret_ref;
22521 }
22522
22523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22524         if (!ptr_is_owned(_res)) return;
22525         void* _res_ptr = untag_ptr(_res);
22526         CHECK_ACCESS(_res_ptr);
22527         LDKCOption_APIErrorZ _res_conv = *(LDKCOption_APIErrorZ*)(_res_ptr);
22528         FREE(untag_ptr(_res));
22529         COption_APIErrorZ_free(_res_conv);
22530 }
22531
22532 static inline uint64_t COption_APIErrorZ_clone_ptr(LDKCOption_APIErrorZ *NONNULL_PTR arg) {
22533         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22534         *ret_copy = COption_APIErrorZ_clone(arg);
22535         int64_t ret_ref = tag_ptr(ret_copy, true);
22536         return ret_ref;
22537 }
22538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22539         LDKCOption_APIErrorZ* arg_conv = (LDKCOption_APIErrorZ*)untag_ptr(arg);
22540         int64_t ret_conv = COption_APIErrorZ_clone_ptr(arg_conv);
22541         return ret_conv;
22542 }
22543
22544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22545         LDKCOption_APIErrorZ* orig_conv = (LDKCOption_APIErrorZ*)untag_ptr(orig);
22546         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22547         *ret_copy = COption_APIErrorZ_clone(orig_conv);
22548         int64_t ret_ref = tag_ptr(ret_copy, true);
22549         return ret_ref;
22550 }
22551
22552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22553         void* o_ptr = untag_ptr(o);
22554         CHECK_ACCESS(o_ptr);
22555         LDKCOption_APIErrorZ o_conv = *(LDKCOption_APIErrorZ*)(o_ptr);
22556         o_conv = COption_APIErrorZ_clone((LDKCOption_APIErrorZ*)untag_ptr(o));
22557         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22558         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_ok(o_conv);
22559         return tag_ptr(ret_conv, true);
22560 }
22561
22562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22563         void* e_ptr = untag_ptr(e);
22564         CHECK_ACCESS(e_ptr);
22565         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22566         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22567         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22568         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_err(e_conv);
22569         return tag_ptr(ret_conv, true);
22570 }
22571
22572 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22573         LDKCResult_COption_APIErrorZDecodeErrorZ* o_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(o);
22574         jboolean ret_conv = CResult_COption_APIErrorZDecodeErrorZ_is_ok(o_conv);
22575         return ret_conv;
22576 }
22577
22578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22579         if (!ptr_is_owned(_res)) return;
22580         void* _res_ptr = untag_ptr(_res);
22581         CHECK_ACCESS(_res_ptr);
22582         LDKCResult_COption_APIErrorZDecodeErrorZ _res_conv = *(LDKCResult_COption_APIErrorZDecodeErrorZ*)(_res_ptr);
22583         FREE(untag_ptr(_res));
22584         CResult_COption_APIErrorZDecodeErrorZ_free(_res_conv);
22585 }
22586
22587 static inline uint64_t CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR arg) {
22588         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22589         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(arg);
22590         return tag_ptr(ret_conv, true);
22591 }
22592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22593         LDKCResult_COption_APIErrorZDecodeErrorZ* arg_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(arg);
22594         int64_t ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(arg_conv);
22595         return ret_conv;
22596 }
22597
22598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22599         LDKCResult_COption_APIErrorZDecodeErrorZ* orig_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(orig);
22600         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22601         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(orig_conv);
22602         return tag_ptr(ret_conv, true);
22603 }
22604
22605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22606         LDKUntrustedString o_conv;
22607         o_conv.inner = untag_ptr(o);
22608         o_conv.is_owned = ptr_is_owned(o);
22609         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22610         o_conv = UntrustedString_clone(&o_conv);
22611         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22612         *ret_conv = CResult_UntrustedStringDecodeErrorZ_ok(o_conv);
22613         return tag_ptr(ret_conv, true);
22614 }
22615
22616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22617         void* e_ptr = untag_ptr(e);
22618         CHECK_ACCESS(e_ptr);
22619         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22620         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22621         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22622         *ret_conv = CResult_UntrustedStringDecodeErrorZ_err(e_conv);
22623         return tag_ptr(ret_conv, true);
22624 }
22625
22626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22627         LDKCResult_UntrustedStringDecodeErrorZ* o_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(o);
22628         jboolean ret_conv = CResult_UntrustedStringDecodeErrorZ_is_ok(o_conv);
22629         return ret_conv;
22630 }
22631
22632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22633         if (!ptr_is_owned(_res)) return;
22634         void* _res_ptr = untag_ptr(_res);
22635         CHECK_ACCESS(_res_ptr);
22636         LDKCResult_UntrustedStringDecodeErrorZ _res_conv = *(LDKCResult_UntrustedStringDecodeErrorZ*)(_res_ptr);
22637         FREE(untag_ptr(_res));
22638         CResult_UntrustedStringDecodeErrorZ_free(_res_conv);
22639 }
22640
22641 static inline uint64_t CResult_UntrustedStringDecodeErrorZ_clone_ptr(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR arg) {
22642         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22643         *ret_conv = CResult_UntrustedStringDecodeErrorZ_clone(arg);
22644         return tag_ptr(ret_conv, true);
22645 }
22646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22647         LDKCResult_UntrustedStringDecodeErrorZ* arg_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(arg);
22648         int64_t ret_conv = CResult_UntrustedStringDecodeErrorZ_clone_ptr(arg_conv);
22649         return ret_conv;
22650 }
22651
22652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22653         LDKCResult_UntrustedStringDecodeErrorZ* orig_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(orig);
22654         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22655         *ret_conv = CResult_UntrustedStringDecodeErrorZ_clone(orig_conv);
22656         return tag_ptr(ret_conv, true);
22657 }
22658
22659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22660         LDKOutPoint o_conv;
22661         o_conv.inner = untag_ptr(o);
22662         o_conv.is_owned = ptr_is_owned(o);
22663         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22664         o_conv = OutPoint_clone(&o_conv);
22665         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22666         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
22667         return tag_ptr(ret_conv, true);
22668 }
22669
22670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22671         void* e_ptr = untag_ptr(e);
22672         CHECK_ACCESS(e_ptr);
22673         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22674         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22675         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22676         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
22677         return tag_ptr(ret_conv, true);
22678 }
22679
22680 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22681         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
22682         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
22683         return ret_conv;
22684 }
22685
22686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22687         if (!ptr_is_owned(_res)) return;
22688         void* _res_ptr = untag_ptr(_res);
22689         CHECK_ACCESS(_res_ptr);
22690         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
22691         FREE(untag_ptr(_res));
22692         CResult_OutPointDecodeErrorZ_free(_res_conv);
22693 }
22694
22695 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
22696         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22697         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
22698         return tag_ptr(ret_conv, true);
22699 }
22700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22701         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
22702         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
22703         return ret_conv;
22704 }
22705
22706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22707         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
22708         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22709         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
22710         return tag_ptr(ret_conv, true);
22711 }
22712
22713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22714         void* o_ptr = untag_ptr(o);
22715         CHECK_ACCESS(o_ptr);
22716         LDKType o_conv = *(LDKType*)(o_ptr);
22717         if (o_conv.free == LDKType_JCalls_free) {
22718                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22719                 LDKType_JCalls_cloned(&o_conv);
22720         }
22721         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22722         *ret_copy = COption_TypeZ_some(o_conv);
22723         int64_t ret_ref = tag_ptr(ret_copy, true);
22724         return ret_ref;
22725 }
22726
22727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
22728         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22729         *ret_copy = COption_TypeZ_none();
22730         int64_t ret_ref = tag_ptr(ret_copy, true);
22731         return ret_ref;
22732 }
22733
22734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22735         if (!ptr_is_owned(_res)) return;
22736         void* _res_ptr = untag_ptr(_res);
22737         CHECK_ACCESS(_res_ptr);
22738         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
22739         FREE(untag_ptr(_res));
22740         COption_TypeZ_free(_res_conv);
22741 }
22742
22743 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
22744         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22745         *ret_copy = COption_TypeZ_clone(arg);
22746         int64_t ret_ref = tag_ptr(ret_copy, true);
22747         return ret_ref;
22748 }
22749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22750         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
22751         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
22752         return ret_conv;
22753 }
22754
22755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22756         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
22757         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22758         *ret_copy = COption_TypeZ_clone(orig_conv);
22759         int64_t ret_ref = tag_ptr(ret_copy, true);
22760         return ret_ref;
22761 }
22762
22763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22764         void* o_ptr = untag_ptr(o);
22765         CHECK_ACCESS(o_ptr);
22766         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
22767         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
22768         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22769         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
22770         return tag_ptr(ret_conv, true);
22771 }
22772
22773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22774         void* e_ptr = untag_ptr(e);
22775         CHECK_ACCESS(e_ptr);
22776         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22777         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22778         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22779         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
22780         return tag_ptr(ret_conv, true);
22781 }
22782
22783 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22784         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
22785         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
22786         return ret_conv;
22787 }
22788
22789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22790         if (!ptr_is_owned(_res)) return;
22791         void* _res_ptr = untag_ptr(_res);
22792         CHECK_ACCESS(_res_ptr);
22793         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
22794         FREE(untag_ptr(_res));
22795         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
22796 }
22797
22798 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
22799         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22800         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
22801         return tag_ptr(ret_conv, true);
22802 }
22803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22804         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
22805         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
22806         return ret_conv;
22807 }
22808
22809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22810         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
22811         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22812         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
22813         return tag_ptr(ret_conv, true);
22814 }
22815
22816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22817         LDKThirtyTwoBytes o_ref;
22818         CHECK((*env)->GetArrayLength(env, o) == 32);
22819         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22820         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22821         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
22822         return tag_ptr(ret_conv, true);
22823 }
22824
22825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22826         void* e_ptr = untag_ptr(e);
22827         CHECK_ACCESS(e_ptr);
22828         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
22829         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
22830         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22831         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
22832         return tag_ptr(ret_conv, true);
22833 }
22834
22835 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22836         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(o);
22837         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
22838         return ret_conv;
22839 }
22840
22841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22842         if (!ptr_is_owned(_res)) return;
22843         void* _res_ptr = untag_ptr(_res);
22844         CHECK_ACCESS(_res_ptr);
22845         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
22846         FREE(untag_ptr(_res));
22847         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
22848 }
22849
22850 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
22851         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22852         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
22853         return tag_ptr(ret_conv, true);
22854 }
22855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22856         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(arg);
22857         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
22858         return ret_conv;
22859 }
22860
22861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22862         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(orig);
22863         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22864         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
22865         return tag_ptr(ret_conv, true);
22866 }
22867
22868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1ok(JNIEnv *env, jclass clz) {
22869         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22870         *ret_conv = CResult_NonePaymentErrorZ_ok();
22871         return tag_ptr(ret_conv, true);
22872 }
22873
22874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22875         void* e_ptr = untag_ptr(e);
22876         CHECK_ACCESS(e_ptr);
22877         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
22878         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
22879         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22880         *ret_conv = CResult_NonePaymentErrorZ_err(e_conv);
22881         return tag_ptr(ret_conv, true);
22882 }
22883
22884 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22885         LDKCResult_NonePaymentErrorZ* o_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(o);
22886         jboolean ret_conv = CResult_NonePaymentErrorZ_is_ok(o_conv);
22887         return ret_conv;
22888 }
22889
22890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22891         if (!ptr_is_owned(_res)) return;
22892         void* _res_ptr = untag_ptr(_res);
22893         CHECK_ACCESS(_res_ptr);
22894         LDKCResult_NonePaymentErrorZ _res_conv = *(LDKCResult_NonePaymentErrorZ*)(_res_ptr);
22895         FREE(untag_ptr(_res));
22896         CResult_NonePaymentErrorZ_free(_res_conv);
22897 }
22898
22899 static inline uint64_t CResult_NonePaymentErrorZ_clone_ptr(LDKCResult_NonePaymentErrorZ *NONNULL_PTR arg) {
22900         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22901         *ret_conv = CResult_NonePaymentErrorZ_clone(arg);
22902         return tag_ptr(ret_conv, true);
22903 }
22904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22905         LDKCResult_NonePaymentErrorZ* arg_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(arg);
22906         int64_t ret_conv = CResult_NonePaymentErrorZ_clone_ptr(arg_conv);
22907         return ret_conv;
22908 }
22909
22910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22911         LDKCResult_NonePaymentErrorZ* orig_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(orig);
22912         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22913         *ret_conv = CResult_NonePaymentErrorZ_clone(orig_conv);
22914         return tag_ptr(ret_conv, true);
22915 }
22916
22917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
22918         LDKStr o_conv = java_to_owned_str(env, o);
22919         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22920         *ret_conv = CResult_StringErrorZ_ok(o_conv);
22921         return tag_ptr(ret_conv, true);
22922 }
22923
22924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
22925         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
22926         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22927         *ret_conv = CResult_StringErrorZ_err(e_conv);
22928         return tag_ptr(ret_conv, true);
22929 }
22930
22931 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22932         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)untag_ptr(o);
22933         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
22934         return ret_conv;
22935 }
22936
22937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22938         if (!ptr_is_owned(_res)) return;
22939         void* _res_ptr = untag_ptr(_res);
22940         CHECK_ACCESS(_res_ptr);
22941         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
22942         FREE(untag_ptr(_res));
22943         CResult_StringErrorZ_free(_res_conv);
22944 }
22945
22946 static inline uint64_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
22947         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22948         *ret_conv = CResult_StringErrorZ_clone(arg);
22949         return tag_ptr(ret_conv, true);
22950 }
22951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22952         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)untag_ptr(arg);
22953         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
22954         return ret_conv;
22955 }
22956
22957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22958         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)untag_ptr(orig);
22959         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22960         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
22961         return tag_ptr(ret_conv, true);
22962 }
22963
22964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22965         LDKChannelMonitorUpdate o_conv;
22966         o_conv.inner = untag_ptr(o);
22967         o_conv.is_owned = ptr_is_owned(o);
22968         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22969         o_conv = ChannelMonitorUpdate_clone(&o_conv);
22970         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22971         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
22972         return tag_ptr(ret_conv, true);
22973 }
22974
22975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22976         void* e_ptr = untag_ptr(e);
22977         CHECK_ACCESS(e_ptr);
22978         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22979         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22980         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22981         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
22982         return tag_ptr(ret_conv, true);
22983 }
22984
22985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22986         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
22987         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
22988         return ret_conv;
22989 }
22990
22991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22992         if (!ptr_is_owned(_res)) return;
22993         void* _res_ptr = untag_ptr(_res);
22994         CHECK_ACCESS(_res_ptr);
22995         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
22996         FREE(untag_ptr(_res));
22997         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
22998 }
22999
23000 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
23001         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
23002         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
23003         return tag_ptr(ret_conv, true);
23004 }
23005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23006         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
23007         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
23008         return ret_conv;
23009 }
23010
23011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23012         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
23013         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
23014         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
23015         return tag_ptr(ret_conv, true);
23016 }
23017
23018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23019         void* o_ptr = untag_ptr(o);
23020         CHECK_ACCESS(o_ptr);
23021         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
23022         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
23023         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23024         *ret_copy = COption_MonitorEventZ_some(o_conv);
23025         int64_t ret_ref = tag_ptr(ret_copy, true);
23026         return ret_ref;
23027 }
23028
23029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
23030         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23031         *ret_copy = COption_MonitorEventZ_none();
23032         int64_t ret_ref = tag_ptr(ret_copy, true);
23033         return ret_ref;
23034 }
23035
23036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23037         if (!ptr_is_owned(_res)) return;
23038         void* _res_ptr = untag_ptr(_res);
23039         CHECK_ACCESS(_res_ptr);
23040         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
23041         FREE(untag_ptr(_res));
23042         COption_MonitorEventZ_free(_res_conv);
23043 }
23044
23045 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
23046         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23047         *ret_copy = COption_MonitorEventZ_clone(arg);
23048         int64_t ret_ref = tag_ptr(ret_copy, true);
23049         return ret_ref;
23050 }
23051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23052         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
23053         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
23054         return ret_conv;
23055 }
23056
23057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23058         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
23059         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23060         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
23061         int64_t ret_ref = tag_ptr(ret_copy, true);
23062         return ret_ref;
23063 }
23064
23065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23066         void* o_ptr = untag_ptr(o);
23067         CHECK_ACCESS(o_ptr);
23068         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
23069         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
23070         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23071         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
23072         return tag_ptr(ret_conv, true);
23073 }
23074
23075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23076         void* e_ptr = untag_ptr(e);
23077         CHECK_ACCESS(e_ptr);
23078         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23079         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23080         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23081         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
23082         return tag_ptr(ret_conv, true);
23083 }
23084
23085 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23086         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
23087         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
23088         return ret_conv;
23089 }
23090
23091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23092         if (!ptr_is_owned(_res)) return;
23093         void* _res_ptr = untag_ptr(_res);
23094         CHECK_ACCESS(_res_ptr);
23095         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
23096         FREE(untag_ptr(_res));
23097         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
23098 }
23099
23100 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
23101         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23102         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
23103         return tag_ptr(ret_conv, true);
23104 }
23105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23106         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
23107         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
23108         return ret_conv;
23109 }
23110
23111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23112         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
23113         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23114         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
23115         return tag_ptr(ret_conv, true);
23116 }
23117
23118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23119         LDKHTLCUpdate o_conv;
23120         o_conv.inner = untag_ptr(o);
23121         o_conv.is_owned = ptr_is_owned(o);
23122         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23123         o_conv = HTLCUpdate_clone(&o_conv);
23124         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23125         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
23126         return tag_ptr(ret_conv, true);
23127 }
23128
23129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23130         void* e_ptr = untag_ptr(e);
23131         CHECK_ACCESS(e_ptr);
23132         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23133         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23134         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23135         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
23136         return tag_ptr(ret_conv, true);
23137 }
23138
23139 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23140         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
23141         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
23142         return ret_conv;
23143 }
23144
23145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23146         if (!ptr_is_owned(_res)) return;
23147         void* _res_ptr = untag_ptr(_res);
23148         CHECK_ACCESS(_res_ptr);
23149         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
23150         FREE(untag_ptr(_res));
23151         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
23152 }
23153
23154 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
23155         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23156         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
23157         return tag_ptr(ret_conv, true);
23158 }
23159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23160         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
23161         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
23162         return ret_conv;
23163 }
23164
23165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23166         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
23167         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23168         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
23169         return tag_ptr(ret_conv, true);
23170 }
23171
23172 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
23173         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23174         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
23175         return tag_ptr(ret_conv, true);
23176 }
23177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23178         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(arg);
23179         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
23180         return ret_conv;
23181 }
23182
23183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23184         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(orig);
23185         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23186         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
23187         return tag_ptr(ret_conv, true);
23188 }
23189
23190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
23191         LDKOutPoint a_conv;
23192         a_conv.inner = untag_ptr(a);
23193         a_conv.is_owned = ptr_is_owned(a);
23194         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23195         a_conv = OutPoint_clone(&a_conv);
23196         LDKCVec_u8Z b_ref;
23197         b_ref.datalen = (*env)->GetArrayLength(env, b);
23198         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
23199         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
23200         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23201         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
23202         return tag_ptr(ret_conv, true);
23203 }
23204
23205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23206         if (!ptr_is_owned(_res)) return;
23207         void* _res_ptr = untag_ptr(_res);
23208         CHECK_ACCESS(_res_ptr);
23209         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
23210         FREE(untag_ptr(_res));
23211         C2Tuple_OutPointScriptZ_free(_res_conv);
23212 }
23213
23214 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
23215         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
23216         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
23217         return tag_ptr(ret_conv, true);
23218 }
23219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23220         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(arg);
23221         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
23222         return ret_conv;
23223 }
23224
23225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23226         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(orig);
23227         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
23228         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
23229         return tag_ptr(ret_conv, true);
23230 }
23231
23232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
23233         LDKCVec_u8Z b_ref;
23234         b_ref.datalen = (*env)->GetArrayLength(env, b);
23235         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
23236         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
23237         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
23238         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
23239         return tag_ptr(ret_conv, true);
23240 }
23241
23242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23243         if (!ptr_is_owned(_res)) return;
23244         void* _res_ptr = untag_ptr(_res);
23245         CHECK_ACCESS(_res_ptr);
23246         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
23247         FREE(untag_ptr(_res));
23248         C2Tuple_u32ScriptZ_free(_res_conv);
23249 }
23250
23251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23252         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
23253         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23254         if (_res_constr.datalen > 0)
23255                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
23256         else
23257                 _res_constr.data = NULL;
23258         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23259         for (size_t v = 0; v < _res_constr.datalen; v++) {
23260                 int64_t _res_conv_21 = _res_vals[v];
23261                 void* _res_conv_21_ptr = untag_ptr(_res_conv_21);
23262                 CHECK_ACCESS(_res_conv_21_ptr);
23263                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
23264                 FREE(untag_ptr(_res_conv_21));
23265                 _res_constr.data[v] = _res_conv_21_conv;
23266         }
23267         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23268         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
23269 }
23270
23271 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
23272         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23273         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
23274         return tag_ptr(ret_conv, true);
23275 }
23276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23277         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(arg);
23278         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
23279         return ret_conv;
23280 }
23281
23282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23283         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(orig);
23284         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23285         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
23286         return tag_ptr(ret_conv, true);
23287 }
23288
23289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
23290         LDKThirtyTwoBytes a_ref;
23291         CHECK((*env)->GetArrayLength(env, a) == 32);
23292         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23293         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
23294         b_constr.datalen = (*env)->GetArrayLength(env, b);
23295         if (b_constr.datalen > 0)
23296                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
23297         else
23298                 b_constr.data = NULL;
23299         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
23300         for (size_t v = 0; v < b_constr.datalen; v++) {
23301                 int64_t b_conv_21 = b_vals[v];
23302                 void* b_conv_21_ptr = untag_ptr(b_conv_21);
23303                 CHECK_ACCESS(b_conv_21_ptr);
23304                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
23305                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)untag_ptr(b_conv_21));
23306                 b_constr.data[v] = b_conv_21_conv;
23307         }
23308         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
23309         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23310         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
23311         return tag_ptr(ret_conv, true);
23312 }
23313
23314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23315         if (!ptr_is_owned(_res)) return;
23316         void* _res_ptr = untag_ptr(_res);
23317         CHECK_ACCESS(_res_ptr);
23318         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
23319         FREE(untag_ptr(_res));
23320         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
23321 }
23322
23323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23324         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
23325         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23326         if (_res_constr.datalen > 0)
23327                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
23328         else
23329                 _res_constr.data = NULL;
23330         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23331         for (size_t o = 0; o < _res_constr.datalen; o++) {
23332                 int64_t _res_conv_40 = _res_vals[o];
23333                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
23334                 CHECK_ACCESS(_res_conv_40_ptr);
23335                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
23336                 FREE(untag_ptr(_res_conv_40));
23337                 _res_constr.data[o] = _res_conv_40_conv;
23338         }
23339         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23340         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
23341 }
23342
23343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23344         LDKCVec_EventZ _res_constr;
23345         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23346         if (_res_constr.datalen > 0)
23347                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
23348         else
23349                 _res_constr.data = NULL;
23350         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23351         for (size_t h = 0; h < _res_constr.datalen; h++) {
23352                 int64_t _res_conv_7 = _res_vals[h];
23353                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
23354                 CHECK_ACCESS(_res_conv_7_ptr);
23355                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
23356                 FREE(untag_ptr(_res_conv_7));
23357                 _res_constr.data[h] = _res_conv_7_conv;
23358         }
23359         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23360         CVec_EventZ_free(_res_constr);
23361 }
23362
23363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
23364         LDKCVec_TransactionZ _res_constr;
23365         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23366         if (_res_constr.datalen > 0)
23367                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
23368         else
23369                 _res_constr.data = NULL;
23370         for (size_t i = 0; i < _res_constr.datalen; i++) {
23371                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
23372                 LDKTransaction _res_conv_8_ref;
23373                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
23374                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
23375                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
23376                 _res_conv_8_ref.data_is_owned = true;
23377                 _res_constr.data[i] = _res_conv_8_ref;
23378         }
23379         CVec_TransactionZ_free(_res_constr);
23380 }
23381
23382 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
23383         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
23384         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
23385         return tag_ptr(ret_conv, true);
23386 }
23387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23388         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
23389         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
23390         return ret_conv;
23391 }
23392
23393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23394         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
23395         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
23396         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
23397         return tag_ptr(ret_conv, true);
23398 }
23399
23400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
23401         void* b_ptr = untag_ptr(b);
23402         CHECK_ACCESS(b_ptr);
23403         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
23404         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
23405         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
23406         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
23407         return tag_ptr(ret_conv, true);
23408 }
23409
23410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23411         if (!ptr_is_owned(_res)) return;
23412         void* _res_ptr = untag_ptr(_res);
23413         CHECK_ACCESS(_res_ptr);
23414         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
23415         FREE(untag_ptr(_res));
23416         C2Tuple_u32TxOutZ_free(_res_conv);
23417 }
23418
23419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23420         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
23421         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23422         if (_res_constr.datalen > 0)
23423                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
23424         else
23425                 _res_constr.data = NULL;
23426         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23427         for (size_t u = 0; u < _res_constr.datalen; u++) {
23428                 int64_t _res_conv_20 = _res_vals[u];
23429                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
23430                 CHECK_ACCESS(_res_conv_20_ptr);
23431                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
23432                 FREE(untag_ptr(_res_conv_20));
23433                 _res_constr.data[u] = _res_conv_20_conv;
23434         }
23435         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23436         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
23437 }
23438
23439 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
23440         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23441         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
23442         return tag_ptr(ret_conv, true);
23443 }
23444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23445         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
23446         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
23447         return ret_conv;
23448 }
23449
23450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23451         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
23452         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23453         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
23454         return tag_ptr(ret_conv, true);
23455 }
23456
23457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
23458         LDKThirtyTwoBytes a_ref;
23459         CHECK((*env)->GetArrayLength(env, a) == 32);
23460         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23461         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
23462         b_constr.datalen = (*env)->GetArrayLength(env, b);
23463         if (b_constr.datalen > 0)
23464                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
23465         else
23466                 b_constr.data = NULL;
23467         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
23468         for (size_t u = 0; u < b_constr.datalen; u++) {
23469                 int64_t b_conv_20 = b_vals[u];
23470                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
23471                 CHECK_ACCESS(b_conv_20_ptr);
23472                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
23473                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
23474                 b_constr.data[u] = b_conv_20_conv;
23475         }
23476         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
23477         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23478         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
23479         return tag_ptr(ret_conv, true);
23480 }
23481
23482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23483         if (!ptr_is_owned(_res)) return;
23484         void* _res_ptr = untag_ptr(_res);
23485         CHECK_ACCESS(_res_ptr);
23486         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
23487         FREE(untag_ptr(_res));
23488         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
23489 }
23490
23491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23492         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
23493         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23494         if (_res_constr.datalen > 0)
23495                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
23496         else
23497                 _res_constr.data = NULL;
23498         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23499         for (size_t n = 0; n < _res_constr.datalen; n++) {
23500                 int64_t _res_conv_39 = _res_vals[n];
23501                 void* _res_conv_39_ptr = untag_ptr(_res_conv_39);
23502                 CHECK_ACCESS(_res_conv_39_ptr);
23503                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
23504                 FREE(untag_ptr(_res_conv_39));
23505                 _res_constr.data[n] = _res_conv_39_conv;
23506         }
23507         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23508         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
23509 }
23510
23511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23512         LDKCVec_BalanceZ _res_constr;
23513         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23514         if (_res_constr.datalen > 0)
23515                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
23516         else
23517                 _res_constr.data = NULL;
23518         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23519         for (size_t j = 0; j < _res_constr.datalen; j++) {
23520                 int64_t _res_conv_9 = _res_vals[j];
23521                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
23522                 CHECK_ACCESS(_res_conv_9_ptr);
23523                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
23524                 FREE(untag_ptr(_res_conv_9));
23525                 _res_constr.data[j] = _res_conv_9_conv;
23526         }
23527         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23528         CVec_BalanceZ_free(_res_constr);
23529 }
23530
23531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23532         void* o_ptr = untag_ptr(o);
23533         CHECK_ACCESS(o_ptr);
23534         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
23535         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o));
23536         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23537         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
23538         return tag_ptr(ret_conv, true);
23539 }
23540
23541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23542         void* e_ptr = untag_ptr(e);
23543         CHECK_ACCESS(e_ptr);
23544         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23545         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23546         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23547         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
23548         return tag_ptr(ret_conv, true);
23549 }
23550
23551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23552         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(o);
23553         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
23554         return ret_conv;
23555 }
23556
23557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23558         if (!ptr_is_owned(_res)) return;
23559         void* _res_ptr = untag_ptr(_res);
23560         CHECK_ACCESS(_res_ptr);
23561         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
23562         FREE(untag_ptr(_res));
23563         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
23564 }
23565
23566 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
23567         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23568         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
23569         return tag_ptr(ret_conv, true);
23570 }
23571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23572         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
23573         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
23574         return ret_conv;
23575 }
23576
23577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23578         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
23579         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23580         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
23581         return tag_ptr(ret_conv, true);
23582 }
23583
23584 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
23585         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
23586         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
23587         return tag_ptr(ret_conv, true);
23588 }
23589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23590         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
23591         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
23592         return ret_conv;
23593 }
23594
23595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23596         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
23597         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
23598         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
23599         return tag_ptr(ret_conv, true);
23600 }
23601
23602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
23603         LDKPublicKey a_ref;
23604         CHECK((*env)->GetArrayLength(env, a) == 33);
23605         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
23606         void* b_ptr = untag_ptr(b);
23607         CHECK_ACCESS(b_ptr);
23608         LDKType b_conv = *(LDKType*)(b_ptr);
23609         if (b_conv.free == LDKType_JCalls_free) {
23610                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23611                 LDKType_JCalls_cloned(&b_conv);
23612         }
23613         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
23614         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
23615         return tag_ptr(ret_conv, true);
23616 }
23617
23618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23619         if (!ptr_is_owned(_res)) return;
23620         void* _res_ptr = untag_ptr(_res);
23621         CHECK_ACCESS(_res_ptr);
23622         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
23623         FREE(untag_ptr(_res));
23624         C2Tuple_PublicKeyTypeZ_free(_res_conv);
23625 }
23626
23627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23628         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
23629         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23630         if (_res_constr.datalen > 0)
23631                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
23632         else
23633                 _res_constr.data = NULL;
23634         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23635         for (size_t z = 0; z < _res_constr.datalen; z++) {
23636                 int64_t _res_conv_25 = _res_vals[z];
23637                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
23638                 CHECK_ACCESS(_res_conv_25_ptr);
23639                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
23640                 FREE(untag_ptr(_res_conv_25));
23641                 _res_constr.data[z] = _res_conv_25_conv;
23642         }
23643         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23644         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
23645 }
23646
23647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23648         void* o_ptr = untag_ptr(o);
23649         CHECK_ACCESS(o_ptr);
23650         LDKCustomOnionMessageContents o_conv = *(LDKCustomOnionMessageContents*)(o_ptr);
23651         if (o_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
23652                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23653                 LDKCustomOnionMessageContents_JCalls_cloned(&o_conv);
23654         }
23655         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23656         *ret_copy = COption_CustomOnionMessageContentsZ_some(o_conv);
23657         int64_t ret_ref = tag_ptr(ret_copy, true);
23658         return ret_ref;
23659 }
23660
23661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1none(JNIEnv *env, jclass clz) {
23662         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23663         *ret_copy = COption_CustomOnionMessageContentsZ_none();
23664         int64_t ret_ref = tag_ptr(ret_copy, true);
23665         return ret_ref;
23666 }
23667
23668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23669         if (!ptr_is_owned(_res)) return;
23670         void* _res_ptr = untag_ptr(_res);
23671         CHECK_ACCESS(_res_ptr);
23672         LDKCOption_CustomOnionMessageContentsZ _res_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(_res_ptr);
23673         FREE(untag_ptr(_res));
23674         COption_CustomOnionMessageContentsZ_free(_res_conv);
23675 }
23676
23677 static inline uint64_t COption_CustomOnionMessageContentsZ_clone_ptr(LDKCOption_CustomOnionMessageContentsZ *NONNULL_PTR arg) {
23678         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23679         *ret_copy = COption_CustomOnionMessageContentsZ_clone(arg);
23680         int64_t ret_ref = tag_ptr(ret_copy, true);
23681         return ret_ref;
23682 }
23683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23684         LDKCOption_CustomOnionMessageContentsZ* arg_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(arg);
23685         int64_t ret_conv = COption_CustomOnionMessageContentsZ_clone_ptr(arg_conv);
23686         return ret_conv;
23687 }
23688
23689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23690         LDKCOption_CustomOnionMessageContentsZ* orig_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(orig);
23691         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23692         *ret_copy = COption_CustomOnionMessageContentsZ_clone(orig_conv);
23693         int64_t ret_ref = tag_ptr(ret_copy, true);
23694         return ret_ref;
23695 }
23696
23697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23698         void* o_ptr = untag_ptr(o);
23699         CHECK_ACCESS(o_ptr);
23700         LDKCOption_CustomOnionMessageContentsZ o_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(o_ptr);
23701         o_conv = COption_CustomOnionMessageContentsZ_clone((LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(o));
23702         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23703         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(o_conv);
23704         return tag_ptr(ret_conv, true);
23705 }
23706
23707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23708         void* e_ptr = untag_ptr(e);
23709         CHECK_ACCESS(e_ptr);
23710         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23711         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23712         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23713         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e_conv);
23714         return tag_ptr(ret_conv, true);
23715 }
23716
23717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23718         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* o_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(o);
23719         jboolean ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(o_conv);
23720         return ret_conv;
23721 }
23722
23723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23724         if (!ptr_is_owned(_res)) return;
23725         void* _res_ptr = untag_ptr(_res);
23726         CHECK_ACCESS(_res_ptr);
23727         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ _res_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(_res_ptr);
23728         FREE(untag_ptr(_res));
23729         CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(_res_conv);
23730 }
23731
23732 static inline uint64_t CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR arg) {
23733         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23734         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(arg);
23735         return tag_ptr(ret_conv, true);
23736 }
23737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23738         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* arg_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(arg);
23739         int64_t ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(arg_conv);
23740         return ret_conv;
23741 }
23742
23743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23744         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* orig_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(orig);
23745         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23746         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(orig_conv);
23747         return tag_ptr(ret_conv, true);
23748 }
23749
23750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23751         void* o_ptr = untag_ptr(o);
23752         CHECK_ACCESS(o_ptr);
23753         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
23754         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
23755         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23756         *ret_copy = COption_NetAddressZ_some(o_conv);
23757         int64_t ret_ref = tag_ptr(ret_copy, true);
23758         return ret_ref;
23759 }
23760
23761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
23762         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23763         *ret_copy = COption_NetAddressZ_none();
23764         int64_t ret_ref = tag_ptr(ret_copy, true);
23765         return ret_ref;
23766 }
23767
23768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23769         if (!ptr_is_owned(_res)) return;
23770         void* _res_ptr = untag_ptr(_res);
23771         CHECK_ACCESS(_res_ptr);
23772         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
23773         FREE(untag_ptr(_res));
23774         COption_NetAddressZ_free(_res_conv);
23775 }
23776
23777 static inline uint64_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
23778         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23779         *ret_copy = COption_NetAddressZ_clone(arg);
23780         int64_t ret_ref = tag_ptr(ret_copy, true);
23781         return ret_ref;
23782 }
23783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23784         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)untag_ptr(arg);
23785         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
23786         return ret_conv;
23787 }
23788
23789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23790         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)untag_ptr(orig);
23791         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23792         *ret_copy = COption_NetAddressZ_clone(orig_conv);
23793         int64_t ret_ref = tag_ptr(ret_copy, true);
23794         return ret_ref;
23795 }
23796
23797 static inline uint64_t C2Tuple_PublicKeyCOption_NetAddressZZ_clone_ptr(LDKC2Tuple_PublicKeyCOption_NetAddressZZ *NONNULL_PTR arg) {
23798         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23799         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone(arg);
23800         return tag_ptr(ret_conv, true);
23801 }
23802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23803         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* arg_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(arg);
23804         int64_t ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone_ptr(arg_conv);
23805         return ret_conv;
23806 }
23807
23808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23809         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* orig_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(orig);
23810         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23811         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone(orig_conv);
23812         return tag_ptr(ret_conv, true);
23813 }
23814
23815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
23816         LDKPublicKey a_ref;
23817         CHECK((*env)->GetArrayLength(env, a) == 33);
23818         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
23819         void* b_ptr = untag_ptr(b);
23820         CHECK_ACCESS(b_ptr);
23821         LDKCOption_NetAddressZ b_conv = *(LDKCOption_NetAddressZ*)(b_ptr);
23822         b_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(b));
23823         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23824         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_new(a_ref, b_conv);
23825         return tag_ptr(ret_conv, true);
23826 }
23827
23828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23829         if (!ptr_is_owned(_res)) return;
23830         void* _res_ptr = untag_ptr(_res);
23831         CHECK_ACCESS(_res_ptr);
23832         LDKC2Tuple_PublicKeyCOption_NetAddressZZ _res_conv = *(LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)(_res_ptr);
23833         FREE(untag_ptr(_res));
23834         C2Tuple_PublicKeyCOption_NetAddressZZ_free(_res_conv);
23835 }
23836
23837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyCOption_1NetAddressZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23838         LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ _res_constr;
23839         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23840         if (_res_constr.datalen > 0)
23841                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ Elements");
23842         else
23843                 _res_constr.data = NULL;
23844         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23845         for (size_t o = 0; o < _res_constr.datalen; o++) {
23846                 int64_t _res_conv_40 = _res_vals[o];
23847                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
23848                 CHECK_ACCESS(_res_conv_40_ptr);
23849                 LDKC2Tuple_PublicKeyCOption_NetAddressZZ _res_conv_40_conv = *(LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)(_res_conv_40_ptr);
23850                 FREE(untag_ptr(_res_conv_40));
23851                 _res_constr.data[o] = _res_conv_40_conv;
23852         }
23853         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23854         CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(_res_constr);
23855 }
23856
23857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
23858         LDKCVec_u8Z o_ref;
23859         o_ref.datalen = (*env)->GetArrayLength(env, o);
23860         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
23861         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
23862         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23863         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
23864         return tag_ptr(ret_conv, true);
23865 }
23866
23867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23868         LDKPeerHandleError e_conv;
23869         e_conv.inner = untag_ptr(e);
23870         e_conv.is_owned = ptr_is_owned(e);
23871         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23872         e_conv = PeerHandleError_clone(&e_conv);
23873         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23874         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
23875         return tag_ptr(ret_conv, true);
23876 }
23877
23878 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23879         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
23880         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
23881         return ret_conv;
23882 }
23883
23884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23885         if (!ptr_is_owned(_res)) return;
23886         void* _res_ptr = untag_ptr(_res);
23887         CHECK_ACCESS(_res_ptr);
23888         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
23889         FREE(untag_ptr(_res));
23890         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
23891 }
23892
23893 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
23894         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23895         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
23896         return tag_ptr(ret_conv, true);
23897 }
23898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23899         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
23900         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
23901         return ret_conv;
23902 }
23903
23904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23905         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
23906         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23907         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
23908         return tag_ptr(ret_conv, true);
23909 }
23910
23911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
23912         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23913         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
23914         return tag_ptr(ret_conv, true);
23915 }
23916
23917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23918         LDKPeerHandleError e_conv;
23919         e_conv.inner = untag_ptr(e);
23920         e_conv.is_owned = ptr_is_owned(e);
23921         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23922         e_conv = PeerHandleError_clone(&e_conv);
23923         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23924         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
23925         return tag_ptr(ret_conv, true);
23926 }
23927
23928 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23929         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
23930         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
23931         return ret_conv;
23932 }
23933
23934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23935         if (!ptr_is_owned(_res)) return;
23936         void* _res_ptr = untag_ptr(_res);
23937         CHECK_ACCESS(_res_ptr);
23938         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
23939         FREE(untag_ptr(_res));
23940         CResult_NonePeerHandleErrorZ_free(_res_conv);
23941 }
23942
23943 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
23944         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23945         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
23946         return tag_ptr(ret_conv, true);
23947 }
23948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23949         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
23950         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
23951         return ret_conv;
23952 }
23953
23954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23955         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
23956         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23957         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
23958         return tag_ptr(ret_conv, true);
23959 }
23960
23961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
23962         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23963         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
23964         return tag_ptr(ret_conv, true);
23965 }
23966
23967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23968         LDKPeerHandleError e_conv;
23969         e_conv.inner = untag_ptr(e);
23970         e_conv.is_owned = ptr_is_owned(e);
23971         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23972         e_conv = PeerHandleError_clone(&e_conv);
23973         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23974         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
23975         return tag_ptr(ret_conv, true);
23976 }
23977
23978 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23979         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
23980         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
23981         return ret_conv;
23982 }
23983
23984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23985         if (!ptr_is_owned(_res)) return;
23986         void* _res_ptr = untag_ptr(_res);
23987         CHECK_ACCESS(_res_ptr);
23988         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
23989         FREE(untag_ptr(_res));
23990         CResult_boolPeerHandleErrorZ_free(_res_conv);
23991 }
23992
23993 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
23994         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23995         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
23996         return tag_ptr(ret_conv, true);
23997 }
23998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23999         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
24000         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
24001         return ret_conv;
24002 }
24003
24004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24005         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
24006         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
24007         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
24008         return tag_ptr(ret_conv, true);
24009 }
24010
24011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24012         void* o_ptr = untag_ptr(o);
24013         CHECK_ACCESS(o_ptr);
24014         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
24015         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
24016         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24017         *ret_conv = CResult_TxOutUtxoLookupErrorZ_ok(o_conv);
24018         return tag_ptr(ret_conv, true);
24019 }
24020
24021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24022         LDKUtxoLookupError e_conv = LDKUtxoLookupError_from_java(env, e);
24023         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24024         *ret_conv = CResult_TxOutUtxoLookupErrorZ_err(e_conv);
24025         return tag_ptr(ret_conv, true);
24026 }
24027
24028 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24029         LDKCResult_TxOutUtxoLookupErrorZ* o_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(o);
24030         jboolean ret_conv = CResult_TxOutUtxoLookupErrorZ_is_ok(o_conv);
24031         return ret_conv;
24032 }
24033
24034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24035         if (!ptr_is_owned(_res)) return;
24036         void* _res_ptr = untag_ptr(_res);
24037         CHECK_ACCESS(_res_ptr);
24038         LDKCResult_TxOutUtxoLookupErrorZ _res_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(_res_ptr);
24039         FREE(untag_ptr(_res));
24040         CResult_TxOutUtxoLookupErrorZ_free(_res_conv);
24041 }
24042
24043 static inline uint64_t CResult_TxOutUtxoLookupErrorZ_clone_ptr(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR arg) {
24044         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24045         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(arg);
24046         return tag_ptr(ret_conv, true);
24047 }
24048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24049         LDKCResult_TxOutUtxoLookupErrorZ* arg_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(arg);
24050         int64_t ret_conv = CResult_TxOutUtxoLookupErrorZ_clone_ptr(arg_conv);
24051         return ret_conv;
24052 }
24053
24054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24055         LDKCResult_TxOutUtxoLookupErrorZ* orig_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(orig);
24056         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24057         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(orig_conv);
24058         return tag_ptr(ret_conv, true);
24059 }
24060
24061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1ok(JNIEnv *env, jclass clz) {
24062         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
24063         *ret_conv = CResult_NoneSendErrorZ_ok();
24064         return tag_ptr(ret_conv, true);
24065 }
24066
24067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24068         void* e_ptr = untag_ptr(e);
24069         CHECK_ACCESS(e_ptr);
24070         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
24071         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
24072         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
24073         *ret_conv = CResult_NoneSendErrorZ_err(e_conv);
24074         return tag_ptr(ret_conv, true);
24075 }
24076
24077 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24078         LDKCResult_NoneSendErrorZ* o_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(o);
24079         jboolean ret_conv = CResult_NoneSendErrorZ_is_ok(o_conv);
24080         return ret_conv;
24081 }
24082
24083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24084         if (!ptr_is_owned(_res)) return;
24085         void* _res_ptr = untag_ptr(_res);
24086         CHECK_ACCESS(_res_ptr);
24087         LDKCResult_NoneSendErrorZ _res_conv = *(LDKCResult_NoneSendErrorZ*)(_res_ptr);
24088         FREE(untag_ptr(_res));
24089         CResult_NoneSendErrorZ_free(_res_conv);
24090 }
24091
24092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24093         LDKBlindedPath o_conv;
24094         o_conv.inner = untag_ptr(o);
24095         o_conv.is_owned = ptr_is_owned(o);
24096         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24097         o_conv = BlindedPath_clone(&o_conv);
24098         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24099         *ret_conv = CResult_BlindedPathNoneZ_ok(o_conv);
24100         return tag_ptr(ret_conv, true);
24101 }
24102
24103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1err(JNIEnv *env, jclass clz) {
24104         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24105         *ret_conv = CResult_BlindedPathNoneZ_err();
24106         return tag_ptr(ret_conv, true);
24107 }
24108
24109 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24110         LDKCResult_BlindedPathNoneZ* o_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(o);
24111         jboolean ret_conv = CResult_BlindedPathNoneZ_is_ok(o_conv);
24112         return ret_conv;
24113 }
24114
24115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24116         if (!ptr_is_owned(_res)) return;
24117         void* _res_ptr = untag_ptr(_res);
24118         CHECK_ACCESS(_res_ptr);
24119         LDKCResult_BlindedPathNoneZ _res_conv = *(LDKCResult_BlindedPathNoneZ*)(_res_ptr);
24120         FREE(untag_ptr(_res));
24121         CResult_BlindedPathNoneZ_free(_res_conv);
24122 }
24123
24124 static inline uint64_t CResult_BlindedPathNoneZ_clone_ptr(LDKCResult_BlindedPathNoneZ *NONNULL_PTR arg) {
24125         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24126         *ret_conv = CResult_BlindedPathNoneZ_clone(arg);
24127         return tag_ptr(ret_conv, true);
24128 }
24129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24130         LDKCResult_BlindedPathNoneZ* arg_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(arg);
24131         int64_t ret_conv = CResult_BlindedPathNoneZ_clone_ptr(arg_conv);
24132         return ret_conv;
24133 }
24134
24135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24136         LDKCResult_BlindedPathNoneZ* orig_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(orig);
24137         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24138         *ret_conv = CResult_BlindedPathNoneZ_clone(orig_conv);
24139         return tag_ptr(ret_conv, true);
24140 }
24141
24142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24143         LDKBlindedPath o_conv;
24144         o_conv.inner = untag_ptr(o);
24145         o_conv.is_owned = ptr_is_owned(o);
24146         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24147         o_conv = BlindedPath_clone(&o_conv);
24148         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24149         *ret_conv = CResult_BlindedPathDecodeErrorZ_ok(o_conv);
24150         return tag_ptr(ret_conv, true);
24151 }
24152
24153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24154         void* e_ptr = untag_ptr(e);
24155         CHECK_ACCESS(e_ptr);
24156         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24157         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24158         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24159         *ret_conv = CResult_BlindedPathDecodeErrorZ_err(e_conv);
24160         return tag_ptr(ret_conv, true);
24161 }
24162
24163 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24164         LDKCResult_BlindedPathDecodeErrorZ* o_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(o);
24165         jboolean ret_conv = CResult_BlindedPathDecodeErrorZ_is_ok(o_conv);
24166         return ret_conv;
24167 }
24168
24169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24170         if (!ptr_is_owned(_res)) return;
24171         void* _res_ptr = untag_ptr(_res);
24172         CHECK_ACCESS(_res_ptr);
24173         LDKCResult_BlindedPathDecodeErrorZ _res_conv = *(LDKCResult_BlindedPathDecodeErrorZ*)(_res_ptr);
24174         FREE(untag_ptr(_res));
24175         CResult_BlindedPathDecodeErrorZ_free(_res_conv);
24176 }
24177
24178 static inline uint64_t CResult_BlindedPathDecodeErrorZ_clone_ptr(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR arg) {
24179         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24180         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(arg);
24181         return tag_ptr(ret_conv, true);
24182 }
24183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24184         LDKCResult_BlindedPathDecodeErrorZ* arg_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(arg);
24185         int64_t ret_conv = CResult_BlindedPathDecodeErrorZ_clone_ptr(arg_conv);
24186         return ret_conv;
24187 }
24188
24189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24190         LDKCResult_BlindedPathDecodeErrorZ* orig_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(orig);
24191         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24192         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(orig_conv);
24193         return tag_ptr(ret_conv, true);
24194 }
24195
24196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24197         LDKBlindedHop o_conv;
24198         o_conv.inner = untag_ptr(o);
24199         o_conv.is_owned = ptr_is_owned(o);
24200         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24201         o_conv = BlindedHop_clone(&o_conv);
24202         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24203         *ret_conv = CResult_BlindedHopDecodeErrorZ_ok(o_conv);
24204         return tag_ptr(ret_conv, true);
24205 }
24206
24207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24208         void* e_ptr = untag_ptr(e);
24209         CHECK_ACCESS(e_ptr);
24210         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24211         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24212         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24213         *ret_conv = CResult_BlindedHopDecodeErrorZ_err(e_conv);
24214         return tag_ptr(ret_conv, true);
24215 }
24216
24217 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24218         LDKCResult_BlindedHopDecodeErrorZ* o_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(o);
24219         jboolean ret_conv = CResult_BlindedHopDecodeErrorZ_is_ok(o_conv);
24220         return ret_conv;
24221 }
24222
24223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24224         if (!ptr_is_owned(_res)) return;
24225         void* _res_ptr = untag_ptr(_res);
24226         CHECK_ACCESS(_res_ptr);
24227         LDKCResult_BlindedHopDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopDecodeErrorZ*)(_res_ptr);
24228         FREE(untag_ptr(_res));
24229         CResult_BlindedHopDecodeErrorZ_free(_res_conv);
24230 }
24231
24232 static inline uint64_t CResult_BlindedHopDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR arg) {
24233         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24234         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(arg);
24235         return tag_ptr(ret_conv, true);
24236 }
24237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24238         LDKCResult_BlindedHopDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(arg);
24239         int64_t ret_conv = CResult_BlindedHopDecodeErrorZ_clone_ptr(arg_conv);
24240         return ret_conv;
24241 }
24242
24243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24244         LDKCResult_BlindedHopDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(orig);
24245         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24246         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(orig_conv);
24247         return tag_ptr(ret_conv, true);
24248 }
24249
24250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
24251         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
24252         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24253         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
24254         return tag_ptr(ret_conv, true);
24255 }
24256
24257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24258         void* e_ptr = untag_ptr(e);
24259         CHECK_ACCESS(e_ptr);
24260         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
24261         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
24262         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24263         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
24264         return tag_ptr(ret_conv, true);
24265 }
24266
24267 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24268         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(o);
24269         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
24270         return ret_conv;
24271 }
24272
24273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24274         if (!ptr_is_owned(_res)) return;
24275         void* _res_ptr = untag_ptr(_res);
24276         CHECK_ACCESS(_res_ptr);
24277         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
24278         FREE(untag_ptr(_res));
24279         CResult_SiPrefixParseErrorZ_free(_res_conv);
24280 }
24281
24282 static inline uint64_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
24283         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24284         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
24285         return tag_ptr(ret_conv, true);
24286 }
24287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24288         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(arg);
24289         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
24290         return ret_conv;
24291 }
24292
24293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24294         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(orig);
24295         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24296         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
24297         return tag_ptr(ret_conv, true);
24298 }
24299
24300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24301         LDKInvoice o_conv;
24302         o_conv.inner = untag_ptr(o);
24303         o_conv.is_owned = ptr_is_owned(o);
24304         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24305         o_conv = Invoice_clone(&o_conv);
24306         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24307         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
24308         return tag_ptr(ret_conv, true);
24309 }
24310
24311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24312         void* e_ptr = untag_ptr(e);
24313         CHECK_ACCESS(e_ptr);
24314         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
24315         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
24316         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24317         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
24318         return tag_ptr(ret_conv, true);
24319 }
24320
24321 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24322         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
24323         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
24324         return ret_conv;
24325 }
24326
24327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24328         if (!ptr_is_owned(_res)) return;
24329         void* _res_ptr = untag_ptr(_res);
24330         CHECK_ACCESS(_res_ptr);
24331         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
24332         FREE(untag_ptr(_res));
24333         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
24334 }
24335
24336 static inline uint64_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
24337         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24338         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
24339         return tag_ptr(ret_conv, true);
24340 }
24341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24342         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
24343         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
24344         return ret_conv;
24345 }
24346
24347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24348         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
24349         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24350         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
24351         return tag_ptr(ret_conv, true);
24352 }
24353
24354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24355         LDKSignedRawInvoice o_conv;
24356         o_conv.inner = untag_ptr(o);
24357         o_conv.is_owned = ptr_is_owned(o);
24358         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24359         o_conv = SignedRawInvoice_clone(&o_conv);
24360         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24361         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
24362         return tag_ptr(ret_conv, true);
24363 }
24364
24365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24366         void* e_ptr = untag_ptr(e);
24367         CHECK_ACCESS(e_ptr);
24368         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
24369         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
24370         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24371         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
24372         return tag_ptr(ret_conv, true);
24373 }
24374
24375 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24376         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(o);
24377         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
24378         return ret_conv;
24379 }
24380
24381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24382         if (!ptr_is_owned(_res)) return;
24383         void* _res_ptr = untag_ptr(_res);
24384         CHECK_ACCESS(_res_ptr);
24385         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
24386         FREE(untag_ptr(_res));
24387         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
24388 }
24389
24390 static inline uint64_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
24391         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24392         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
24393         return tag_ptr(ret_conv, true);
24394 }
24395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24396         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(arg);
24397         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
24398         return ret_conv;
24399 }
24400
24401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24402         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(orig);
24403         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24404         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
24405         return tag_ptr(ret_conv, true);
24406 }
24407
24408 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
24409         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24410         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
24411         return tag_ptr(ret_conv, true);
24412 }
24413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24414         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(arg);
24415         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
24416         return ret_conv;
24417 }
24418
24419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24420         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(orig);
24421         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24422         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
24423         return tag_ptr(ret_conv, true);
24424 }
24425
24426 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) {
24427         LDKRawInvoice a_conv;
24428         a_conv.inner = untag_ptr(a);
24429         a_conv.is_owned = ptr_is_owned(a);
24430         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24431         a_conv = RawInvoice_clone(&a_conv);
24432         LDKThirtyTwoBytes b_ref;
24433         CHECK((*env)->GetArrayLength(env, b) == 32);
24434         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
24435         LDKInvoiceSignature c_conv;
24436         c_conv.inner = untag_ptr(c);
24437         c_conv.is_owned = ptr_is_owned(c);
24438         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
24439         c_conv = InvoiceSignature_clone(&c_conv);
24440         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24441         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
24442         return tag_ptr(ret_conv, true);
24443 }
24444
24445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24446         if (!ptr_is_owned(_res)) return;
24447         void* _res_ptr = untag_ptr(_res);
24448         CHECK_ACCESS(_res_ptr);
24449         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
24450         FREE(untag_ptr(_res));
24451         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
24452 }
24453
24454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24455         LDKPayeePubKey o_conv;
24456         o_conv.inner = untag_ptr(o);
24457         o_conv.is_owned = ptr_is_owned(o);
24458         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24459         o_conv = PayeePubKey_clone(&o_conv);
24460         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24461         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
24462         return tag_ptr(ret_conv, true);
24463 }
24464
24465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24466         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
24467         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24468         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
24469         return tag_ptr(ret_conv, true);
24470 }
24471
24472 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24473         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(o);
24474         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
24475         return ret_conv;
24476 }
24477
24478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24479         if (!ptr_is_owned(_res)) return;
24480         void* _res_ptr = untag_ptr(_res);
24481         CHECK_ACCESS(_res_ptr);
24482         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
24483         FREE(untag_ptr(_res));
24484         CResult_PayeePubKeyErrorZ_free(_res_conv);
24485 }
24486
24487 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
24488         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24489         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
24490         return tag_ptr(ret_conv, true);
24491 }
24492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24493         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(arg);
24494         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
24495         return ret_conv;
24496 }
24497
24498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24499         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(orig);
24500         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24501         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
24502         return tag_ptr(ret_conv, true);
24503 }
24504
24505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24506         LDKCVec_PrivateRouteZ _res_constr;
24507         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24508         if (_res_constr.datalen > 0)
24509                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
24510         else
24511                 _res_constr.data = NULL;
24512         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24513         for (size_t o = 0; o < _res_constr.datalen; o++) {
24514                 int64_t _res_conv_14 = _res_vals[o];
24515                 LDKPrivateRoute _res_conv_14_conv;
24516                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
24517                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
24518                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
24519                 _res_constr.data[o] = _res_conv_14_conv;
24520         }
24521         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24522         CVec_PrivateRouteZ_free(_res_constr);
24523 }
24524
24525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24526         LDKPositiveTimestamp o_conv;
24527         o_conv.inner = untag_ptr(o);
24528         o_conv.is_owned = ptr_is_owned(o);
24529         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24530         o_conv = PositiveTimestamp_clone(&o_conv);
24531         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24532         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
24533         return tag_ptr(ret_conv, true);
24534 }
24535
24536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24537         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
24538         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24539         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
24540         return tag_ptr(ret_conv, true);
24541 }
24542
24543 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24544         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
24545         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
24546         return ret_conv;
24547 }
24548
24549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24550         if (!ptr_is_owned(_res)) return;
24551         void* _res_ptr = untag_ptr(_res);
24552         CHECK_ACCESS(_res_ptr);
24553         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
24554         FREE(untag_ptr(_res));
24555         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
24556 }
24557
24558 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
24559         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24560         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
24561         return tag_ptr(ret_conv, true);
24562 }
24563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24564         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
24565         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
24566         return ret_conv;
24567 }
24568
24569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24570         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
24571         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24572         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
24573         return tag_ptr(ret_conv, true);
24574 }
24575
24576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
24577         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24578         *ret_conv = CResult_NoneSemanticErrorZ_ok();
24579         return tag_ptr(ret_conv, true);
24580 }
24581
24582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24583         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
24584         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24585         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
24586         return tag_ptr(ret_conv, true);
24587 }
24588
24589 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24590         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(o);
24591         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
24592         return ret_conv;
24593 }
24594
24595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24596         if (!ptr_is_owned(_res)) return;
24597         void* _res_ptr = untag_ptr(_res);
24598         CHECK_ACCESS(_res_ptr);
24599         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
24600         FREE(untag_ptr(_res));
24601         CResult_NoneSemanticErrorZ_free(_res_conv);
24602 }
24603
24604 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
24605         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24606         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
24607         return tag_ptr(ret_conv, true);
24608 }
24609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24610         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(arg);
24611         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
24612         return ret_conv;
24613 }
24614
24615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24616         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(orig);
24617         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24618         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
24619         return tag_ptr(ret_conv, true);
24620 }
24621
24622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24623         LDKInvoice o_conv;
24624         o_conv.inner = untag_ptr(o);
24625         o_conv.is_owned = ptr_is_owned(o);
24626         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24627         o_conv = Invoice_clone(&o_conv);
24628         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24629         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
24630         return tag_ptr(ret_conv, true);
24631 }
24632
24633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24634         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
24635         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24636         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
24637         return tag_ptr(ret_conv, true);
24638 }
24639
24640 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24641         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(o);
24642         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
24643         return ret_conv;
24644 }
24645
24646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24647         if (!ptr_is_owned(_res)) return;
24648         void* _res_ptr = untag_ptr(_res);
24649         CHECK_ACCESS(_res_ptr);
24650         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
24651         FREE(untag_ptr(_res));
24652         CResult_InvoiceSemanticErrorZ_free(_res_conv);
24653 }
24654
24655 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
24656         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24657         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
24658         return tag_ptr(ret_conv, true);
24659 }
24660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24661         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(arg);
24662         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
24663         return ret_conv;
24664 }
24665
24666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24667         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(orig);
24668         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24669         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
24670         return tag_ptr(ret_conv, true);
24671 }
24672
24673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1AddressZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
24674         LDKCVec_AddressZ _res_constr;
24675         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24676         if (_res_constr.datalen > 0)
24677                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKStr), "LDKCVec_AddressZ Elements");
24678         else
24679                 _res_constr.data = NULL;
24680         for (size_t i = 0; i < _res_constr.datalen; i++) {
24681                 jstring _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
24682                 LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
24683                 _res_constr.data[i] = dummy;
24684         }
24685         CVec_AddressZ_free(_res_constr);
24686 }
24687
24688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24689         LDKDescription o_conv;
24690         o_conv.inner = untag_ptr(o);
24691         o_conv.is_owned = ptr_is_owned(o);
24692         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24693         o_conv = Description_clone(&o_conv);
24694         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24695         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
24696         return tag_ptr(ret_conv, true);
24697 }
24698
24699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24700         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
24701         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24702         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
24703         return tag_ptr(ret_conv, true);
24704 }
24705
24706 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24707         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
24708         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
24709         return ret_conv;
24710 }
24711
24712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24713         if (!ptr_is_owned(_res)) return;
24714         void* _res_ptr = untag_ptr(_res);
24715         CHECK_ACCESS(_res_ptr);
24716         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
24717         FREE(untag_ptr(_res));
24718         CResult_DescriptionCreationErrorZ_free(_res_conv);
24719 }
24720
24721 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
24722         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24723         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
24724         return tag_ptr(ret_conv, true);
24725 }
24726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24727         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
24728         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
24729         return ret_conv;
24730 }
24731
24732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24733         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
24734         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24735         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
24736         return tag_ptr(ret_conv, true);
24737 }
24738
24739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24740         LDKPrivateRoute o_conv;
24741         o_conv.inner = untag_ptr(o);
24742         o_conv.is_owned = ptr_is_owned(o);
24743         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24744         o_conv = PrivateRoute_clone(&o_conv);
24745         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24746         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
24747         return tag_ptr(ret_conv, true);
24748 }
24749
24750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24751         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
24752         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24753         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
24754         return tag_ptr(ret_conv, true);
24755 }
24756
24757 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24758         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
24759         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
24760         return ret_conv;
24761 }
24762
24763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24764         if (!ptr_is_owned(_res)) return;
24765         void* _res_ptr = untag_ptr(_res);
24766         CHECK_ACCESS(_res_ptr);
24767         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
24768         FREE(untag_ptr(_res));
24769         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
24770 }
24771
24772 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
24773         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24774         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
24775         return tag_ptr(ret_conv, true);
24776 }
24777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24778         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
24779         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
24780         return ret_conv;
24781 }
24782
24783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24784         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
24785         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24786         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
24787         return tag_ptr(ret_conv, true);
24788 }
24789
24790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24791         void* o_ptr = untag_ptr(o);
24792         CHECK_ACCESS(o_ptr);
24793         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
24794         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
24795         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24796         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
24797         return tag_ptr(ret_conv, true);
24798 }
24799
24800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24801         void* e_ptr = untag_ptr(e);
24802         CHECK_ACCESS(e_ptr);
24803         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24804         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24805         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24806         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
24807         return tag_ptr(ret_conv, true);
24808 }
24809
24810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24811         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(o);
24812         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
24813         return ret_conv;
24814 }
24815
24816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24817         if (!ptr_is_owned(_res)) return;
24818         void* _res_ptr = untag_ptr(_res);
24819         CHECK_ACCESS(_res_ptr);
24820         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
24821         FREE(untag_ptr(_res));
24822         CResult_NetAddressDecodeErrorZ_free(_res_conv);
24823 }
24824
24825 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
24826         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24827         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
24828         return tag_ptr(ret_conv, true);
24829 }
24830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24831         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(arg);
24832         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
24833         return ret_conv;
24834 }
24835
24836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24837         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(orig);
24838         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24839         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
24840         return tag_ptr(ret_conv, true);
24841 }
24842
24843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24844         LDKCVec_UpdateAddHTLCZ _res_constr;
24845         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24846         if (_res_constr.datalen > 0)
24847                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
24848         else
24849                 _res_constr.data = NULL;
24850         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24851         for (size_t p = 0; p < _res_constr.datalen; p++) {
24852                 int64_t _res_conv_15 = _res_vals[p];
24853                 LDKUpdateAddHTLC _res_conv_15_conv;
24854                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
24855                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
24856                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
24857                 _res_constr.data[p] = _res_conv_15_conv;
24858         }
24859         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24860         CVec_UpdateAddHTLCZ_free(_res_constr);
24861 }
24862
24863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24864         LDKCVec_UpdateFulfillHTLCZ _res_constr;
24865         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24866         if (_res_constr.datalen > 0)
24867                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
24868         else
24869                 _res_constr.data = NULL;
24870         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24871         for (size_t t = 0; t < _res_constr.datalen; t++) {
24872                 int64_t _res_conv_19 = _res_vals[t];
24873                 LDKUpdateFulfillHTLC _res_conv_19_conv;
24874                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
24875                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
24876                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
24877                 _res_constr.data[t] = _res_conv_19_conv;
24878         }
24879         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24880         CVec_UpdateFulfillHTLCZ_free(_res_constr);
24881 }
24882
24883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24884         LDKCVec_UpdateFailHTLCZ _res_constr;
24885         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24886         if (_res_constr.datalen > 0)
24887                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
24888         else
24889                 _res_constr.data = NULL;
24890         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24891         for (size_t q = 0; q < _res_constr.datalen; q++) {
24892                 int64_t _res_conv_16 = _res_vals[q];
24893                 LDKUpdateFailHTLC _res_conv_16_conv;
24894                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
24895                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
24896                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
24897                 _res_constr.data[q] = _res_conv_16_conv;
24898         }
24899         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24900         CVec_UpdateFailHTLCZ_free(_res_constr);
24901 }
24902
24903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24904         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
24905         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24906         if (_res_constr.datalen > 0)
24907                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
24908         else
24909                 _res_constr.data = NULL;
24910         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24911         for (size_t z = 0; z < _res_constr.datalen; z++) {
24912                 int64_t _res_conv_25 = _res_vals[z];
24913                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
24914                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
24915                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
24916                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
24917                 _res_constr.data[z] = _res_conv_25_conv;
24918         }
24919         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24920         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
24921 }
24922
24923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24924         LDKAcceptChannel o_conv;
24925         o_conv.inner = untag_ptr(o);
24926         o_conv.is_owned = ptr_is_owned(o);
24927         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24928         o_conv = AcceptChannel_clone(&o_conv);
24929         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24930         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
24931         return tag_ptr(ret_conv, true);
24932 }
24933
24934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24935         void* e_ptr = untag_ptr(e);
24936         CHECK_ACCESS(e_ptr);
24937         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24938         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24939         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24940         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
24941         return tag_ptr(ret_conv, true);
24942 }
24943
24944 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24945         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
24946         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
24947         return ret_conv;
24948 }
24949
24950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24951         if (!ptr_is_owned(_res)) return;
24952         void* _res_ptr = untag_ptr(_res);
24953         CHECK_ACCESS(_res_ptr);
24954         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
24955         FREE(untag_ptr(_res));
24956         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
24957 }
24958
24959 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
24960         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24961         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
24962         return tag_ptr(ret_conv, true);
24963 }
24964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24965         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
24966         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
24967         return ret_conv;
24968 }
24969
24970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24971         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
24972         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24973         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
24974         return tag_ptr(ret_conv, true);
24975 }
24976
24977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24978         LDKAnnouncementSignatures o_conv;
24979         o_conv.inner = untag_ptr(o);
24980         o_conv.is_owned = ptr_is_owned(o);
24981         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24982         o_conv = AnnouncementSignatures_clone(&o_conv);
24983         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24984         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
24985         return tag_ptr(ret_conv, true);
24986 }
24987
24988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24989         void* e_ptr = untag_ptr(e);
24990         CHECK_ACCESS(e_ptr);
24991         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24992         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24993         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24994         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
24995         return tag_ptr(ret_conv, true);
24996 }
24997
24998 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24999         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
25000         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
25001         return ret_conv;
25002 }
25003
25004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25005         if (!ptr_is_owned(_res)) return;
25006         void* _res_ptr = untag_ptr(_res);
25007         CHECK_ACCESS(_res_ptr);
25008         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
25009         FREE(untag_ptr(_res));
25010         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
25011 }
25012
25013 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
25014         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
25015         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
25016         return tag_ptr(ret_conv, true);
25017 }
25018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25019         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
25020         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
25021         return ret_conv;
25022 }
25023
25024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25025         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
25026         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
25027         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
25028         return tag_ptr(ret_conv, true);
25029 }
25030
25031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25032         LDKChannelReestablish o_conv;
25033         o_conv.inner = untag_ptr(o);
25034         o_conv.is_owned = ptr_is_owned(o);
25035         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25036         o_conv = ChannelReestablish_clone(&o_conv);
25037         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25038         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
25039         return tag_ptr(ret_conv, true);
25040 }
25041
25042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25043         void* e_ptr = untag_ptr(e);
25044         CHECK_ACCESS(e_ptr);
25045         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25046         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25047         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25048         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
25049         return tag_ptr(ret_conv, true);
25050 }
25051
25052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25053         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
25054         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
25055         return ret_conv;
25056 }
25057
25058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25059         if (!ptr_is_owned(_res)) return;
25060         void* _res_ptr = untag_ptr(_res);
25061         CHECK_ACCESS(_res_ptr);
25062         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
25063         FREE(untag_ptr(_res));
25064         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
25065 }
25066
25067 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
25068         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25069         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
25070         return tag_ptr(ret_conv, true);
25071 }
25072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25073         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
25074         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
25075         return ret_conv;
25076 }
25077
25078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25079         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
25080         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25081         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
25082         return tag_ptr(ret_conv, true);
25083 }
25084
25085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25086         LDKClosingSigned o_conv;
25087         o_conv.inner = untag_ptr(o);
25088         o_conv.is_owned = ptr_is_owned(o);
25089         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25090         o_conv = ClosingSigned_clone(&o_conv);
25091         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25092         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
25093         return tag_ptr(ret_conv, true);
25094 }
25095
25096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25097         void* e_ptr = untag_ptr(e);
25098         CHECK_ACCESS(e_ptr);
25099         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25100         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25101         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25102         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
25103         return tag_ptr(ret_conv, true);
25104 }
25105
25106 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25107         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
25108         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
25109         return ret_conv;
25110 }
25111
25112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25113         if (!ptr_is_owned(_res)) return;
25114         void* _res_ptr = untag_ptr(_res);
25115         CHECK_ACCESS(_res_ptr);
25116         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
25117         FREE(untag_ptr(_res));
25118         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
25119 }
25120
25121 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
25122         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25123         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
25124         return tag_ptr(ret_conv, true);
25125 }
25126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25127         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
25128         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
25129         return ret_conv;
25130 }
25131
25132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25133         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
25134         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25135         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
25136         return tag_ptr(ret_conv, true);
25137 }
25138
25139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25140         LDKClosingSignedFeeRange o_conv;
25141         o_conv.inner = untag_ptr(o);
25142         o_conv.is_owned = ptr_is_owned(o);
25143         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25144         o_conv = ClosingSignedFeeRange_clone(&o_conv);
25145         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25146         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
25147         return tag_ptr(ret_conv, true);
25148 }
25149
25150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25151         void* e_ptr = untag_ptr(e);
25152         CHECK_ACCESS(e_ptr);
25153         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25154         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25155         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25156         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
25157         return tag_ptr(ret_conv, true);
25158 }
25159
25160 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25161         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
25162         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
25163         return ret_conv;
25164 }
25165
25166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25167         if (!ptr_is_owned(_res)) return;
25168         void* _res_ptr = untag_ptr(_res);
25169         CHECK_ACCESS(_res_ptr);
25170         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
25171         FREE(untag_ptr(_res));
25172         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
25173 }
25174
25175 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
25176         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25177         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
25178         return tag_ptr(ret_conv, true);
25179 }
25180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25181         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
25182         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
25183         return ret_conv;
25184 }
25185
25186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25187         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
25188         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25189         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
25190         return tag_ptr(ret_conv, true);
25191 }
25192
25193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25194         LDKCommitmentSigned o_conv;
25195         o_conv.inner = untag_ptr(o);
25196         o_conv.is_owned = ptr_is_owned(o);
25197         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25198         o_conv = CommitmentSigned_clone(&o_conv);
25199         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25200         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
25201         return tag_ptr(ret_conv, true);
25202 }
25203
25204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25205         void* e_ptr = untag_ptr(e);
25206         CHECK_ACCESS(e_ptr);
25207         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25208         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25209         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25210         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
25211         return tag_ptr(ret_conv, true);
25212 }
25213
25214 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25215         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
25216         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
25217         return ret_conv;
25218 }
25219
25220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25221         if (!ptr_is_owned(_res)) return;
25222         void* _res_ptr = untag_ptr(_res);
25223         CHECK_ACCESS(_res_ptr);
25224         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
25225         FREE(untag_ptr(_res));
25226         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
25227 }
25228
25229 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
25230         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25231         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
25232         return tag_ptr(ret_conv, true);
25233 }
25234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25235         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
25236         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
25237         return ret_conv;
25238 }
25239
25240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25241         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
25242         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25243         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
25244         return tag_ptr(ret_conv, true);
25245 }
25246
25247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25248         LDKFundingCreated o_conv;
25249         o_conv.inner = untag_ptr(o);
25250         o_conv.is_owned = ptr_is_owned(o);
25251         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25252         o_conv = FundingCreated_clone(&o_conv);
25253         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25254         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
25255         return tag_ptr(ret_conv, true);
25256 }
25257
25258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25259         void* e_ptr = untag_ptr(e);
25260         CHECK_ACCESS(e_ptr);
25261         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25262         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25263         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25264         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
25265         return tag_ptr(ret_conv, true);
25266 }
25267
25268 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25269         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
25270         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
25271         return ret_conv;
25272 }
25273
25274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25275         if (!ptr_is_owned(_res)) return;
25276         void* _res_ptr = untag_ptr(_res);
25277         CHECK_ACCESS(_res_ptr);
25278         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
25279         FREE(untag_ptr(_res));
25280         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
25281 }
25282
25283 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
25284         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25285         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
25286         return tag_ptr(ret_conv, true);
25287 }
25288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25289         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
25290         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
25291         return ret_conv;
25292 }
25293
25294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25295         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
25296         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25297         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
25298         return tag_ptr(ret_conv, true);
25299 }
25300
25301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25302         LDKFundingSigned o_conv;
25303         o_conv.inner = untag_ptr(o);
25304         o_conv.is_owned = ptr_is_owned(o);
25305         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25306         o_conv = FundingSigned_clone(&o_conv);
25307         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25308         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
25309         return tag_ptr(ret_conv, true);
25310 }
25311
25312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25313         void* e_ptr = untag_ptr(e);
25314         CHECK_ACCESS(e_ptr);
25315         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25316         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25317         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25318         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
25319         return tag_ptr(ret_conv, true);
25320 }
25321
25322 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25323         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
25324         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
25325         return ret_conv;
25326 }
25327
25328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25329         if (!ptr_is_owned(_res)) return;
25330         void* _res_ptr = untag_ptr(_res);
25331         CHECK_ACCESS(_res_ptr);
25332         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
25333         FREE(untag_ptr(_res));
25334         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
25335 }
25336
25337 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
25338         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25339         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
25340         return tag_ptr(ret_conv, true);
25341 }
25342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25343         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
25344         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
25345         return ret_conv;
25346 }
25347
25348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25349         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
25350         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25351         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
25352         return tag_ptr(ret_conv, true);
25353 }
25354
25355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25356         LDKChannelReady o_conv;
25357         o_conv.inner = untag_ptr(o);
25358         o_conv.is_owned = ptr_is_owned(o);
25359         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25360         o_conv = ChannelReady_clone(&o_conv);
25361         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25362         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
25363         return tag_ptr(ret_conv, true);
25364 }
25365
25366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25367         void* e_ptr = untag_ptr(e);
25368         CHECK_ACCESS(e_ptr);
25369         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25370         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25371         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25372         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
25373         return tag_ptr(ret_conv, true);
25374 }
25375
25376 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25377         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
25378         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
25379         return ret_conv;
25380 }
25381
25382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25383         if (!ptr_is_owned(_res)) return;
25384         void* _res_ptr = untag_ptr(_res);
25385         CHECK_ACCESS(_res_ptr);
25386         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
25387         FREE(untag_ptr(_res));
25388         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
25389 }
25390
25391 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
25392         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25393         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
25394         return tag_ptr(ret_conv, true);
25395 }
25396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25397         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
25398         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
25399         return ret_conv;
25400 }
25401
25402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25403         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
25404         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25405         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
25406         return tag_ptr(ret_conv, true);
25407 }
25408
25409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25410         LDKInit o_conv;
25411         o_conv.inner = untag_ptr(o);
25412         o_conv.is_owned = ptr_is_owned(o);
25413         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25414         o_conv = Init_clone(&o_conv);
25415         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25416         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
25417         return tag_ptr(ret_conv, true);
25418 }
25419
25420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25421         void* e_ptr = untag_ptr(e);
25422         CHECK_ACCESS(e_ptr);
25423         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25424         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25425         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25426         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
25427         return tag_ptr(ret_conv, true);
25428 }
25429
25430 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25431         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
25432         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
25433         return ret_conv;
25434 }
25435
25436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25437         if (!ptr_is_owned(_res)) return;
25438         void* _res_ptr = untag_ptr(_res);
25439         CHECK_ACCESS(_res_ptr);
25440         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
25441         FREE(untag_ptr(_res));
25442         CResult_InitDecodeErrorZ_free(_res_conv);
25443 }
25444
25445 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
25446         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25447         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
25448         return tag_ptr(ret_conv, true);
25449 }
25450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25451         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
25452         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
25453         return ret_conv;
25454 }
25455
25456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25457         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
25458         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25459         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
25460         return tag_ptr(ret_conv, true);
25461 }
25462
25463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25464         LDKOpenChannel o_conv;
25465         o_conv.inner = untag_ptr(o);
25466         o_conv.is_owned = ptr_is_owned(o);
25467         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25468         o_conv = OpenChannel_clone(&o_conv);
25469         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25470         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
25471         return tag_ptr(ret_conv, true);
25472 }
25473
25474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25475         void* e_ptr = untag_ptr(e);
25476         CHECK_ACCESS(e_ptr);
25477         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25478         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25479         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25480         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
25481         return tag_ptr(ret_conv, true);
25482 }
25483
25484 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25485         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
25486         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
25487         return ret_conv;
25488 }
25489
25490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25491         if (!ptr_is_owned(_res)) return;
25492         void* _res_ptr = untag_ptr(_res);
25493         CHECK_ACCESS(_res_ptr);
25494         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
25495         FREE(untag_ptr(_res));
25496         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
25497 }
25498
25499 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
25500         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25501         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
25502         return tag_ptr(ret_conv, true);
25503 }
25504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25505         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
25506         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
25507         return ret_conv;
25508 }
25509
25510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25511         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
25512         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25513         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
25514         return tag_ptr(ret_conv, true);
25515 }
25516
25517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25518         LDKRevokeAndACK o_conv;
25519         o_conv.inner = untag_ptr(o);
25520         o_conv.is_owned = ptr_is_owned(o);
25521         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25522         o_conv = RevokeAndACK_clone(&o_conv);
25523         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25524         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
25525         return tag_ptr(ret_conv, true);
25526 }
25527
25528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25529         void* e_ptr = untag_ptr(e);
25530         CHECK_ACCESS(e_ptr);
25531         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25532         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25533         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25534         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
25535         return tag_ptr(ret_conv, true);
25536 }
25537
25538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25539         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
25540         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
25541         return ret_conv;
25542 }
25543
25544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25545         if (!ptr_is_owned(_res)) return;
25546         void* _res_ptr = untag_ptr(_res);
25547         CHECK_ACCESS(_res_ptr);
25548         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
25549         FREE(untag_ptr(_res));
25550         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
25551 }
25552
25553 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
25554         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25555         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
25556         return tag_ptr(ret_conv, true);
25557 }
25558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25559         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
25560         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
25561         return ret_conv;
25562 }
25563
25564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25565         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
25566         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25567         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
25568         return tag_ptr(ret_conv, true);
25569 }
25570
25571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25572         LDKShutdown o_conv;
25573         o_conv.inner = untag_ptr(o);
25574         o_conv.is_owned = ptr_is_owned(o);
25575         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25576         o_conv = Shutdown_clone(&o_conv);
25577         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25578         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
25579         return tag_ptr(ret_conv, true);
25580 }
25581
25582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25583         void* e_ptr = untag_ptr(e);
25584         CHECK_ACCESS(e_ptr);
25585         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25586         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25587         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25588         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
25589         return tag_ptr(ret_conv, true);
25590 }
25591
25592 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25593         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
25594         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
25595         return ret_conv;
25596 }
25597
25598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25599         if (!ptr_is_owned(_res)) return;
25600         void* _res_ptr = untag_ptr(_res);
25601         CHECK_ACCESS(_res_ptr);
25602         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
25603         FREE(untag_ptr(_res));
25604         CResult_ShutdownDecodeErrorZ_free(_res_conv);
25605 }
25606
25607 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
25608         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25609         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
25610         return tag_ptr(ret_conv, true);
25611 }
25612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25613         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
25614         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
25615         return ret_conv;
25616 }
25617
25618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25619         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
25620         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25621         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
25622         return tag_ptr(ret_conv, true);
25623 }
25624
25625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25626         LDKUpdateFailHTLC o_conv;
25627         o_conv.inner = untag_ptr(o);
25628         o_conv.is_owned = ptr_is_owned(o);
25629         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25630         o_conv = UpdateFailHTLC_clone(&o_conv);
25631         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25632         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
25633         return tag_ptr(ret_conv, true);
25634 }
25635
25636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25637         void* e_ptr = untag_ptr(e);
25638         CHECK_ACCESS(e_ptr);
25639         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25640         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25641         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25642         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
25643         return tag_ptr(ret_conv, true);
25644 }
25645
25646 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25647         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
25648         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
25649         return ret_conv;
25650 }
25651
25652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25653         if (!ptr_is_owned(_res)) return;
25654         void* _res_ptr = untag_ptr(_res);
25655         CHECK_ACCESS(_res_ptr);
25656         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
25657         FREE(untag_ptr(_res));
25658         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
25659 }
25660
25661 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
25662         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25663         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
25664         return tag_ptr(ret_conv, true);
25665 }
25666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25667         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
25668         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
25669         return ret_conv;
25670 }
25671
25672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25673         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
25674         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25675         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
25676         return tag_ptr(ret_conv, true);
25677 }
25678
25679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25680         LDKUpdateFailMalformedHTLC o_conv;
25681         o_conv.inner = untag_ptr(o);
25682         o_conv.is_owned = ptr_is_owned(o);
25683         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25684         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
25685         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25686         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
25687         return tag_ptr(ret_conv, true);
25688 }
25689
25690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25691         void* e_ptr = untag_ptr(e);
25692         CHECK_ACCESS(e_ptr);
25693         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25694         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25695         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25696         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
25697         return tag_ptr(ret_conv, true);
25698 }
25699
25700 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25701         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
25702         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
25703         return ret_conv;
25704 }
25705
25706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25707         if (!ptr_is_owned(_res)) return;
25708         void* _res_ptr = untag_ptr(_res);
25709         CHECK_ACCESS(_res_ptr);
25710         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
25711         FREE(untag_ptr(_res));
25712         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
25713 }
25714
25715 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
25716         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25717         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
25718         return tag_ptr(ret_conv, true);
25719 }
25720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25721         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
25722         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
25723         return ret_conv;
25724 }
25725
25726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25727         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
25728         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25729         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
25730         return tag_ptr(ret_conv, true);
25731 }
25732
25733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25734         LDKUpdateFee o_conv;
25735         o_conv.inner = untag_ptr(o);
25736         o_conv.is_owned = ptr_is_owned(o);
25737         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25738         o_conv = UpdateFee_clone(&o_conv);
25739         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25740         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
25741         return tag_ptr(ret_conv, true);
25742 }
25743
25744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25745         void* e_ptr = untag_ptr(e);
25746         CHECK_ACCESS(e_ptr);
25747         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25748         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25749         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25750         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
25751         return tag_ptr(ret_conv, true);
25752 }
25753
25754 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25755         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
25756         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
25757         return ret_conv;
25758 }
25759
25760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25761         if (!ptr_is_owned(_res)) return;
25762         void* _res_ptr = untag_ptr(_res);
25763         CHECK_ACCESS(_res_ptr);
25764         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
25765         FREE(untag_ptr(_res));
25766         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
25767 }
25768
25769 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
25770         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25771         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
25772         return tag_ptr(ret_conv, true);
25773 }
25774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25775         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
25776         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
25777         return ret_conv;
25778 }
25779
25780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25781         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
25782         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25783         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
25784         return tag_ptr(ret_conv, true);
25785 }
25786
25787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25788         LDKUpdateFulfillHTLC o_conv;
25789         o_conv.inner = untag_ptr(o);
25790         o_conv.is_owned = ptr_is_owned(o);
25791         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25792         o_conv = UpdateFulfillHTLC_clone(&o_conv);
25793         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25794         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
25795         return tag_ptr(ret_conv, true);
25796 }
25797
25798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25799         void* e_ptr = untag_ptr(e);
25800         CHECK_ACCESS(e_ptr);
25801         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25802         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25803         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25804         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
25805         return tag_ptr(ret_conv, true);
25806 }
25807
25808 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25809         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
25810         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
25811         return ret_conv;
25812 }
25813
25814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25815         if (!ptr_is_owned(_res)) return;
25816         void* _res_ptr = untag_ptr(_res);
25817         CHECK_ACCESS(_res_ptr);
25818         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
25819         FREE(untag_ptr(_res));
25820         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
25821 }
25822
25823 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
25824         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25825         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
25826         return tag_ptr(ret_conv, true);
25827 }
25828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25829         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
25830         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
25831         return ret_conv;
25832 }
25833
25834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25835         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
25836         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25837         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
25838         return tag_ptr(ret_conv, true);
25839 }
25840
25841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25842         LDKUpdateAddHTLC o_conv;
25843         o_conv.inner = untag_ptr(o);
25844         o_conv.is_owned = ptr_is_owned(o);
25845         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25846         o_conv = UpdateAddHTLC_clone(&o_conv);
25847         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25848         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
25849         return tag_ptr(ret_conv, true);
25850 }
25851
25852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25853         void* e_ptr = untag_ptr(e);
25854         CHECK_ACCESS(e_ptr);
25855         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25856         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25857         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25858         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
25859         return tag_ptr(ret_conv, true);
25860 }
25861
25862 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25863         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
25864         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
25865         return ret_conv;
25866 }
25867
25868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25869         if (!ptr_is_owned(_res)) return;
25870         void* _res_ptr = untag_ptr(_res);
25871         CHECK_ACCESS(_res_ptr);
25872         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
25873         FREE(untag_ptr(_res));
25874         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
25875 }
25876
25877 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
25878         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25879         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
25880         return tag_ptr(ret_conv, true);
25881 }
25882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25883         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
25884         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
25885         return ret_conv;
25886 }
25887
25888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25889         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
25890         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25891         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
25892         return tag_ptr(ret_conv, true);
25893 }
25894
25895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25896         LDKOnionMessage o_conv;
25897         o_conv.inner = untag_ptr(o);
25898         o_conv.is_owned = ptr_is_owned(o);
25899         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25900         o_conv = OnionMessage_clone(&o_conv);
25901         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25902         *ret_conv = CResult_OnionMessageDecodeErrorZ_ok(o_conv);
25903         return tag_ptr(ret_conv, true);
25904 }
25905
25906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25907         void* e_ptr = untag_ptr(e);
25908         CHECK_ACCESS(e_ptr);
25909         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25910         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25911         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25912         *ret_conv = CResult_OnionMessageDecodeErrorZ_err(e_conv);
25913         return tag_ptr(ret_conv, true);
25914 }
25915
25916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25917         LDKCResult_OnionMessageDecodeErrorZ* o_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(o);
25918         jboolean ret_conv = CResult_OnionMessageDecodeErrorZ_is_ok(o_conv);
25919         return ret_conv;
25920 }
25921
25922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25923         if (!ptr_is_owned(_res)) return;
25924         void* _res_ptr = untag_ptr(_res);
25925         CHECK_ACCESS(_res_ptr);
25926         LDKCResult_OnionMessageDecodeErrorZ _res_conv = *(LDKCResult_OnionMessageDecodeErrorZ*)(_res_ptr);
25927         FREE(untag_ptr(_res));
25928         CResult_OnionMessageDecodeErrorZ_free(_res_conv);
25929 }
25930
25931 static inline uint64_t CResult_OnionMessageDecodeErrorZ_clone_ptr(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR arg) {
25932         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25933         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(arg);
25934         return tag_ptr(ret_conv, true);
25935 }
25936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25937         LDKCResult_OnionMessageDecodeErrorZ* arg_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(arg);
25938         int64_t ret_conv = CResult_OnionMessageDecodeErrorZ_clone_ptr(arg_conv);
25939         return ret_conv;
25940 }
25941
25942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25943         LDKCResult_OnionMessageDecodeErrorZ* orig_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(orig);
25944         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25945         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(orig_conv);
25946         return tag_ptr(ret_conv, true);
25947 }
25948
25949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25950         LDKPing o_conv;
25951         o_conv.inner = untag_ptr(o);
25952         o_conv.is_owned = ptr_is_owned(o);
25953         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25954         o_conv = Ping_clone(&o_conv);
25955         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25956         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
25957         return tag_ptr(ret_conv, true);
25958 }
25959
25960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25961         void* e_ptr = untag_ptr(e);
25962         CHECK_ACCESS(e_ptr);
25963         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25964         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25965         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25966         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
25967         return tag_ptr(ret_conv, true);
25968 }
25969
25970 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25971         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
25972         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
25973         return ret_conv;
25974 }
25975
25976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25977         if (!ptr_is_owned(_res)) return;
25978         void* _res_ptr = untag_ptr(_res);
25979         CHECK_ACCESS(_res_ptr);
25980         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
25981         FREE(untag_ptr(_res));
25982         CResult_PingDecodeErrorZ_free(_res_conv);
25983 }
25984
25985 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
25986         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25987         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
25988         return tag_ptr(ret_conv, true);
25989 }
25990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25991         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
25992         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
25993         return ret_conv;
25994 }
25995
25996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25997         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
25998         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25999         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
26000         return tag_ptr(ret_conv, true);
26001 }
26002
26003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26004         LDKPong o_conv;
26005         o_conv.inner = untag_ptr(o);
26006         o_conv.is_owned = ptr_is_owned(o);
26007         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26008         o_conv = Pong_clone(&o_conv);
26009         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26010         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
26011         return tag_ptr(ret_conv, true);
26012 }
26013
26014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26015         void* e_ptr = untag_ptr(e);
26016         CHECK_ACCESS(e_ptr);
26017         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26018         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26019         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26020         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
26021         return tag_ptr(ret_conv, true);
26022 }
26023
26024 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26025         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
26026         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
26027         return ret_conv;
26028 }
26029
26030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26031         if (!ptr_is_owned(_res)) return;
26032         void* _res_ptr = untag_ptr(_res);
26033         CHECK_ACCESS(_res_ptr);
26034         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
26035         FREE(untag_ptr(_res));
26036         CResult_PongDecodeErrorZ_free(_res_conv);
26037 }
26038
26039 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
26040         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26041         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
26042         return tag_ptr(ret_conv, true);
26043 }
26044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26045         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
26046         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
26047         return ret_conv;
26048 }
26049
26050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26051         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
26052         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26053         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
26054         return tag_ptr(ret_conv, true);
26055 }
26056
26057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26058         LDKUnsignedChannelAnnouncement o_conv;
26059         o_conv.inner = untag_ptr(o);
26060         o_conv.is_owned = ptr_is_owned(o);
26061         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26062         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
26063         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26064         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
26065         return tag_ptr(ret_conv, true);
26066 }
26067
26068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26069         void* e_ptr = untag_ptr(e);
26070         CHECK_ACCESS(e_ptr);
26071         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26072         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26073         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26074         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
26075         return tag_ptr(ret_conv, true);
26076 }
26077
26078 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26079         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
26080         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
26081         return ret_conv;
26082 }
26083
26084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26085         if (!ptr_is_owned(_res)) return;
26086         void* _res_ptr = untag_ptr(_res);
26087         CHECK_ACCESS(_res_ptr);
26088         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
26089         FREE(untag_ptr(_res));
26090         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
26091 }
26092
26093 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26094         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26095         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
26096         return tag_ptr(ret_conv, true);
26097 }
26098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26099         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
26100         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26101         return ret_conv;
26102 }
26103
26104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26105         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
26106         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26107         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
26108         return tag_ptr(ret_conv, true);
26109 }
26110
26111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26112         LDKChannelAnnouncement o_conv;
26113         o_conv.inner = untag_ptr(o);
26114         o_conv.is_owned = ptr_is_owned(o);
26115         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26116         o_conv = ChannelAnnouncement_clone(&o_conv);
26117         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26118         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
26119         return tag_ptr(ret_conv, true);
26120 }
26121
26122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26123         void* e_ptr = untag_ptr(e);
26124         CHECK_ACCESS(e_ptr);
26125         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26126         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26127         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26128         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
26129         return tag_ptr(ret_conv, true);
26130 }
26131
26132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26133         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
26134         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
26135         return ret_conv;
26136 }
26137
26138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26139         if (!ptr_is_owned(_res)) return;
26140         void* _res_ptr = untag_ptr(_res);
26141         CHECK_ACCESS(_res_ptr);
26142         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
26143         FREE(untag_ptr(_res));
26144         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
26145 }
26146
26147 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26148         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26149         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
26150         return tag_ptr(ret_conv, true);
26151 }
26152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26153         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
26154         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26155         return ret_conv;
26156 }
26157
26158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26159         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
26160         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26161         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
26162         return tag_ptr(ret_conv, true);
26163 }
26164
26165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26166         LDKUnsignedChannelUpdate o_conv;
26167         o_conv.inner = untag_ptr(o);
26168         o_conv.is_owned = ptr_is_owned(o);
26169         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26170         o_conv = UnsignedChannelUpdate_clone(&o_conv);
26171         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26172         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
26173         return tag_ptr(ret_conv, true);
26174 }
26175
26176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26177         void* e_ptr = untag_ptr(e);
26178         CHECK_ACCESS(e_ptr);
26179         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26180         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26181         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26182         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
26183         return tag_ptr(ret_conv, true);
26184 }
26185
26186 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26187         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
26188         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
26189         return ret_conv;
26190 }
26191
26192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26193         if (!ptr_is_owned(_res)) return;
26194         void* _res_ptr = untag_ptr(_res);
26195         CHECK_ACCESS(_res_ptr);
26196         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
26197         FREE(untag_ptr(_res));
26198         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
26199 }
26200
26201 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
26202         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26203         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
26204         return tag_ptr(ret_conv, true);
26205 }
26206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26207         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
26208         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
26209         return ret_conv;
26210 }
26211
26212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26213         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
26214         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26215         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
26216         return tag_ptr(ret_conv, true);
26217 }
26218
26219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26220         LDKChannelUpdate o_conv;
26221         o_conv.inner = untag_ptr(o);
26222         o_conv.is_owned = ptr_is_owned(o);
26223         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26224         o_conv = ChannelUpdate_clone(&o_conv);
26225         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26226         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
26227         return tag_ptr(ret_conv, true);
26228 }
26229
26230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26231         void* e_ptr = untag_ptr(e);
26232         CHECK_ACCESS(e_ptr);
26233         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26234         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26235         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26236         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
26237         return tag_ptr(ret_conv, true);
26238 }
26239
26240 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26241         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
26242         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
26243         return ret_conv;
26244 }
26245
26246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26247         if (!ptr_is_owned(_res)) return;
26248         void* _res_ptr = untag_ptr(_res);
26249         CHECK_ACCESS(_res_ptr);
26250         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
26251         FREE(untag_ptr(_res));
26252         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
26253 }
26254
26255 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
26256         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26257         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
26258         return tag_ptr(ret_conv, true);
26259 }
26260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26261         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
26262         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
26263         return ret_conv;
26264 }
26265
26266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26267         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
26268         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26269         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
26270         return tag_ptr(ret_conv, true);
26271 }
26272
26273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26274         LDKErrorMessage o_conv;
26275         o_conv.inner = untag_ptr(o);
26276         o_conv.is_owned = ptr_is_owned(o);
26277         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26278         o_conv = ErrorMessage_clone(&o_conv);
26279         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26280         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
26281         return tag_ptr(ret_conv, true);
26282 }
26283
26284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26285         void* e_ptr = untag_ptr(e);
26286         CHECK_ACCESS(e_ptr);
26287         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26288         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26289         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26290         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
26291         return tag_ptr(ret_conv, true);
26292 }
26293
26294 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26295         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
26296         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
26297         return ret_conv;
26298 }
26299
26300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26301         if (!ptr_is_owned(_res)) return;
26302         void* _res_ptr = untag_ptr(_res);
26303         CHECK_ACCESS(_res_ptr);
26304         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
26305         FREE(untag_ptr(_res));
26306         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
26307 }
26308
26309 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
26310         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26311         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
26312         return tag_ptr(ret_conv, true);
26313 }
26314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26315         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
26316         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
26317         return ret_conv;
26318 }
26319
26320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26321         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
26322         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26323         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
26324         return tag_ptr(ret_conv, true);
26325 }
26326
26327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26328         LDKWarningMessage o_conv;
26329         o_conv.inner = untag_ptr(o);
26330         o_conv.is_owned = ptr_is_owned(o);
26331         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26332         o_conv = WarningMessage_clone(&o_conv);
26333         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26334         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
26335         return tag_ptr(ret_conv, true);
26336 }
26337
26338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26339         void* e_ptr = untag_ptr(e);
26340         CHECK_ACCESS(e_ptr);
26341         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26342         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26343         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26344         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
26345         return tag_ptr(ret_conv, true);
26346 }
26347
26348 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26349         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
26350         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
26351         return ret_conv;
26352 }
26353
26354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26355         if (!ptr_is_owned(_res)) return;
26356         void* _res_ptr = untag_ptr(_res);
26357         CHECK_ACCESS(_res_ptr);
26358         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
26359         FREE(untag_ptr(_res));
26360         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
26361 }
26362
26363 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
26364         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26365         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
26366         return tag_ptr(ret_conv, true);
26367 }
26368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26369         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
26370         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
26371         return ret_conv;
26372 }
26373
26374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26375         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
26376         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26377         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
26378         return tag_ptr(ret_conv, true);
26379 }
26380
26381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26382         LDKUnsignedNodeAnnouncement o_conv;
26383         o_conv.inner = untag_ptr(o);
26384         o_conv.is_owned = ptr_is_owned(o);
26385         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26386         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
26387         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26388         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
26389         return tag_ptr(ret_conv, true);
26390 }
26391
26392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26393         void* e_ptr = untag_ptr(e);
26394         CHECK_ACCESS(e_ptr);
26395         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26396         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26397         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26398         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
26399         return tag_ptr(ret_conv, true);
26400 }
26401
26402 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26403         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
26404         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
26405         return ret_conv;
26406 }
26407
26408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26409         if (!ptr_is_owned(_res)) return;
26410         void* _res_ptr = untag_ptr(_res);
26411         CHECK_ACCESS(_res_ptr);
26412         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
26413         FREE(untag_ptr(_res));
26414         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
26415 }
26416
26417 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26418         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26419         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
26420         return tag_ptr(ret_conv, true);
26421 }
26422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26423         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
26424         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26425         return ret_conv;
26426 }
26427
26428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26429         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
26430         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26431         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
26432         return tag_ptr(ret_conv, true);
26433 }
26434
26435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26436         LDKNodeAnnouncement o_conv;
26437         o_conv.inner = untag_ptr(o);
26438         o_conv.is_owned = ptr_is_owned(o);
26439         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26440         o_conv = NodeAnnouncement_clone(&o_conv);
26441         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26442         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
26443         return tag_ptr(ret_conv, true);
26444 }
26445
26446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26447         void* e_ptr = untag_ptr(e);
26448         CHECK_ACCESS(e_ptr);
26449         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26450         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26451         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26452         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
26453         return tag_ptr(ret_conv, true);
26454 }
26455
26456 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26457         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
26458         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
26459         return ret_conv;
26460 }
26461
26462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26463         if (!ptr_is_owned(_res)) return;
26464         void* _res_ptr = untag_ptr(_res);
26465         CHECK_ACCESS(_res_ptr);
26466         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
26467         FREE(untag_ptr(_res));
26468         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
26469 }
26470
26471 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26472         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26473         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
26474         return tag_ptr(ret_conv, true);
26475 }
26476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26477         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
26478         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26479         return ret_conv;
26480 }
26481
26482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26483         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
26484         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26485         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
26486         return tag_ptr(ret_conv, true);
26487 }
26488
26489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26490         LDKQueryShortChannelIds o_conv;
26491         o_conv.inner = untag_ptr(o);
26492         o_conv.is_owned = ptr_is_owned(o);
26493         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26494         o_conv = QueryShortChannelIds_clone(&o_conv);
26495         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26496         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
26497         return tag_ptr(ret_conv, true);
26498 }
26499
26500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26501         void* e_ptr = untag_ptr(e);
26502         CHECK_ACCESS(e_ptr);
26503         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26504         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26505         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26506         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
26507         return tag_ptr(ret_conv, true);
26508 }
26509
26510 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26511         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
26512         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
26513         return ret_conv;
26514 }
26515
26516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26517         if (!ptr_is_owned(_res)) return;
26518         void* _res_ptr = untag_ptr(_res);
26519         CHECK_ACCESS(_res_ptr);
26520         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
26521         FREE(untag_ptr(_res));
26522         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
26523 }
26524
26525 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
26526         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26527         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
26528         return tag_ptr(ret_conv, true);
26529 }
26530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26531         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
26532         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
26533         return ret_conv;
26534 }
26535
26536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26537         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
26538         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26539         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
26540         return tag_ptr(ret_conv, true);
26541 }
26542
26543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26544         LDKReplyShortChannelIdsEnd o_conv;
26545         o_conv.inner = untag_ptr(o);
26546         o_conv.is_owned = ptr_is_owned(o);
26547         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26548         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
26549         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26550         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
26551         return tag_ptr(ret_conv, true);
26552 }
26553
26554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26555         void* e_ptr = untag_ptr(e);
26556         CHECK_ACCESS(e_ptr);
26557         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26558         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26559         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26560         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
26561         return tag_ptr(ret_conv, true);
26562 }
26563
26564 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26565         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
26566         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
26567         return ret_conv;
26568 }
26569
26570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26571         if (!ptr_is_owned(_res)) return;
26572         void* _res_ptr = untag_ptr(_res);
26573         CHECK_ACCESS(_res_ptr);
26574         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
26575         FREE(untag_ptr(_res));
26576         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
26577 }
26578
26579 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
26580         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26581         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
26582         return tag_ptr(ret_conv, true);
26583 }
26584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26585         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
26586         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
26587         return ret_conv;
26588 }
26589
26590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26591         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
26592         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26593         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
26594         return tag_ptr(ret_conv, true);
26595 }
26596
26597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26598         LDKQueryChannelRange o_conv;
26599         o_conv.inner = untag_ptr(o);
26600         o_conv.is_owned = ptr_is_owned(o);
26601         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26602         o_conv = QueryChannelRange_clone(&o_conv);
26603         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26604         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
26605         return tag_ptr(ret_conv, true);
26606 }
26607
26608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26609         void* e_ptr = untag_ptr(e);
26610         CHECK_ACCESS(e_ptr);
26611         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26612         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26613         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26614         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
26615         return tag_ptr(ret_conv, true);
26616 }
26617
26618 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26619         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
26620         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
26621         return ret_conv;
26622 }
26623
26624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26625         if (!ptr_is_owned(_res)) return;
26626         void* _res_ptr = untag_ptr(_res);
26627         CHECK_ACCESS(_res_ptr);
26628         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
26629         FREE(untag_ptr(_res));
26630         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
26631 }
26632
26633 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
26634         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26635         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
26636         return tag_ptr(ret_conv, true);
26637 }
26638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26639         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
26640         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
26641         return ret_conv;
26642 }
26643
26644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26645         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
26646         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26647         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
26648         return tag_ptr(ret_conv, true);
26649 }
26650
26651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26652         LDKReplyChannelRange o_conv;
26653         o_conv.inner = untag_ptr(o);
26654         o_conv.is_owned = ptr_is_owned(o);
26655         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26656         o_conv = ReplyChannelRange_clone(&o_conv);
26657         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26658         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
26659         return tag_ptr(ret_conv, true);
26660 }
26661
26662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26663         void* e_ptr = untag_ptr(e);
26664         CHECK_ACCESS(e_ptr);
26665         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26666         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26667         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26668         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
26669         return tag_ptr(ret_conv, true);
26670 }
26671
26672 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26673         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
26674         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
26675         return ret_conv;
26676 }
26677
26678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26679         if (!ptr_is_owned(_res)) return;
26680         void* _res_ptr = untag_ptr(_res);
26681         CHECK_ACCESS(_res_ptr);
26682         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
26683         FREE(untag_ptr(_res));
26684         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
26685 }
26686
26687 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
26688         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26689         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
26690         return tag_ptr(ret_conv, true);
26691 }
26692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26693         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
26694         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
26695         return ret_conv;
26696 }
26697
26698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26699         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
26700         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26701         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
26702         return tag_ptr(ret_conv, true);
26703 }
26704
26705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26706         LDKGossipTimestampFilter o_conv;
26707         o_conv.inner = untag_ptr(o);
26708         o_conv.is_owned = ptr_is_owned(o);
26709         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26710         o_conv = GossipTimestampFilter_clone(&o_conv);
26711         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26712         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
26713         return tag_ptr(ret_conv, true);
26714 }
26715
26716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26717         void* e_ptr = untag_ptr(e);
26718         CHECK_ACCESS(e_ptr);
26719         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26720         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26721         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26722         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
26723         return tag_ptr(ret_conv, true);
26724 }
26725
26726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26727         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
26728         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
26729         return ret_conv;
26730 }
26731
26732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26733         if (!ptr_is_owned(_res)) return;
26734         void* _res_ptr = untag_ptr(_res);
26735         CHECK_ACCESS(_res_ptr);
26736         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
26737         FREE(untag_ptr(_res));
26738         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
26739 }
26740
26741 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
26742         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26743         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
26744         return tag_ptr(ret_conv, true);
26745 }
26746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26747         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
26748         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
26749         return ret_conv;
26750 }
26751
26752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26753         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
26754         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26755         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
26756         return tag_ptr(ret_conv, true);
26757 }
26758
26759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26760         LDKCVec_PhantomRouteHintsZ _res_constr;
26761         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26762         if (_res_constr.datalen > 0)
26763                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
26764         else
26765                 _res_constr.data = NULL;
26766         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26767         for (size_t t = 0; t < _res_constr.datalen; t++) {
26768                 int64_t _res_conv_19 = _res_vals[t];
26769                 LDKPhantomRouteHints _res_conv_19_conv;
26770                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
26771                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
26772                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
26773                 _res_constr.data[t] = _res_conv_19_conv;
26774         }
26775         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26776         CVec_PhantomRouteHintsZ_free(_res_constr);
26777 }
26778
26779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26780         LDKInvoice o_conv;
26781         o_conv.inner = untag_ptr(o);
26782         o_conv.is_owned = ptr_is_owned(o);
26783         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26784         o_conv = Invoice_clone(&o_conv);
26785         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26786         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
26787         return tag_ptr(ret_conv, true);
26788 }
26789
26790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26791         void* e_ptr = untag_ptr(e);
26792         CHECK_ACCESS(e_ptr);
26793         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
26794         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
26795         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26796         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
26797         return tag_ptr(ret_conv, true);
26798 }
26799
26800 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26801         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(o);
26802         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
26803         return ret_conv;
26804 }
26805
26806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26807         if (!ptr_is_owned(_res)) return;
26808         void* _res_ptr = untag_ptr(_res);
26809         CHECK_ACCESS(_res_ptr);
26810         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
26811         FREE(untag_ptr(_res));
26812         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
26813 }
26814
26815 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
26816         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26817         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
26818         return tag_ptr(ret_conv, true);
26819 }
26820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26821         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
26822         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
26823         return ret_conv;
26824 }
26825
26826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26827         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
26828         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26829         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
26830         return tag_ptr(ret_conv, true);
26831 }
26832
26833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1FutureZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26834         LDKCVec_FutureZ _res_constr;
26835         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26836         if (_res_constr.datalen > 0)
26837                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKFuture), "LDKCVec_FutureZ Elements");
26838         else
26839                 _res_constr.data = NULL;
26840         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26841         for (size_t i = 0; i < _res_constr.datalen; i++) {
26842                 int64_t _res_conv_8 = _res_vals[i];
26843                 LDKFuture _res_conv_8_conv;
26844                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
26845                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
26846                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
26847                 _res_constr.data[i] = _res_conv_8_conv;
26848         }
26849         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26850         CVec_FutureZ_free(_res_constr);
26851 }
26852
26853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
26854         void* o_ptr = untag_ptr(o);
26855         CHECK_ACCESS(o_ptr);
26856         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
26857         if (o_conv.free == LDKFilter_JCalls_free) {
26858                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26859                 LDKFilter_JCalls_cloned(&o_conv);
26860         }
26861         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
26862         *ret_copy = COption_FilterZ_some(o_conv);
26863         int64_t ret_ref = tag_ptr(ret_copy, true);
26864         return ret_ref;
26865 }
26866
26867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
26868         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
26869         *ret_copy = COption_FilterZ_none();
26870         int64_t ret_ref = tag_ptr(ret_copy, true);
26871         return ret_ref;
26872 }
26873
26874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26875         if (!ptr_is_owned(_res)) return;
26876         void* _res_ptr = untag_ptr(_res);
26877         CHECK_ACCESS(_res_ptr);
26878         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
26879         FREE(untag_ptr(_res));
26880         COption_FilterZ_free(_res_conv);
26881 }
26882
26883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26884         LDKLockedChannelMonitor o_conv;
26885         o_conv.inner = untag_ptr(o);
26886         o_conv.is_owned = ptr_is_owned(o);
26887         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26888         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
26889         
26890         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
26891         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
26892         return tag_ptr(ret_conv, true);
26893 }
26894
26895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
26896         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
26897         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
26898         return tag_ptr(ret_conv, true);
26899 }
26900
26901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26902         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
26903         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
26904         return ret_conv;
26905 }
26906
26907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26908         if (!ptr_is_owned(_res)) return;
26909         void* _res_ptr = untag_ptr(_res);
26910         CHECK_ACCESS(_res_ptr);
26911         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
26912         FREE(untag_ptr(_res));
26913         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
26914 }
26915
26916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26917         LDKCVec_OutPointZ _res_constr;
26918         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26919         if (_res_constr.datalen > 0)
26920                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
26921         else
26922                 _res_constr.data = NULL;
26923         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26924         for (size_t k = 0; k < _res_constr.datalen; k++) {
26925                 int64_t _res_conv_10 = _res_vals[k];
26926                 LDKOutPoint _res_conv_10_conv;
26927                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
26928                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
26929                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
26930                 _res_constr.data[k] = _res_conv_10_conv;
26931         }
26932         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26933         CVec_OutPointZ_free(_res_constr);
26934 }
26935
26936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorUpdateIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26937         LDKCVec_MonitorUpdateIdZ _res_constr;
26938         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26939         if (_res_constr.datalen > 0)
26940                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
26941         else
26942                 _res_constr.data = NULL;
26943         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26944         for (size_t r = 0; r < _res_constr.datalen; r++) {
26945                 int64_t _res_conv_17 = _res_vals[r];
26946                 LDKMonitorUpdateId _res_conv_17_conv;
26947                 _res_conv_17_conv.inner = untag_ptr(_res_conv_17);
26948                 _res_conv_17_conv.is_owned = ptr_is_owned(_res_conv_17);
26949                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_17_conv);
26950                 _res_constr.data[r] = _res_conv_17_conv;
26951         }
26952         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26953         CVec_MonitorUpdateIdZ_free(_res_constr);
26954 }
26955
26956 static inline uint64_t C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR arg) {
26957         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26958         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(arg);
26959         return tag_ptr(ret_conv, true);
26960 }
26961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26962         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(arg);
26963         int64_t ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(arg_conv);
26964         return ret_conv;
26965 }
26966
26967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26968         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(orig);
26969         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26970         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(orig_conv);
26971         return tag_ptr(ret_conv, true);
26972 }
26973
26974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b) {
26975         LDKOutPoint a_conv;
26976         a_conv.inner = untag_ptr(a);
26977         a_conv.is_owned = ptr_is_owned(a);
26978         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26979         a_conv = OutPoint_clone(&a_conv);
26980         LDKCVec_MonitorUpdateIdZ b_constr;
26981         b_constr.datalen = (*env)->GetArrayLength(env, b);
26982         if (b_constr.datalen > 0)
26983                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
26984         else
26985                 b_constr.data = NULL;
26986         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
26987         for (size_t r = 0; r < b_constr.datalen; r++) {
26988                 int64_t b_conv_17 = b_vals[r];
26989                 LDKMonitorUpdateId b_conv_17_conv;
26990                 b_conv_17_conv.inner = untag_ptr(b_conv_17);
26991                 b_conv_17_conv.is_owned = ptr_is_owned(b_conv_17);
26992                 CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv_17_conv);
26993                 b_conv_17_conv = MonitorUpdateId_clone(&b_conv_17_conv);
26994                 b_constr.data[r] = b_conv_17_conv;
26995         }
26996         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
26997         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26998         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(a_conv, b_constr);
26999         return tag_ptr(ret_conv, true);
27000 }
27001
27002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
27003         if (!ptr_is_owned(_res)) return;
27004         void* _res_ptr = untag_ptr(_res);
27005         CHECK_ACCESS(_res_ptr);
27006         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_ptr);
27007         FREE(untag_ptr(_res));
27008         C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(_res_conv);
27009 }
27010
27011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1OutPointCVec_1MonitorUpdateIdZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
27012         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res_constr;
27013         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
27014         if (_res_constr.datalen > 0)
27015                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ Elements");
27016         else
27017                 _res_constr.data = NULL;
27018         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
27019         for (size_t p = 0; p < _res_constr.datalen; p++) {
27020                 int64_t _res_conv_41 = _res_vals[p];
27021                 void* _res_conv_41_ptr = untag_ptr(_res_conv_41);
27022                 CHECK_ACCESS(_res_conv_41_ptr);
27023                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv_41_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_conv_41_ptr);
27024                 FREE(untag_ptr(_res_conv_41));
27025                 _res_constr.data[p] = _res_conv_41_conv;
27026         }
27027         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
27028         CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(_res_constr);
27029 }
27030
27031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
27032         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
27033         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
27034         return tag_ptr(ret_conv, true);
27035 }
27036
27037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
27038         void* e_ptr = untag_ptr(e);
27039         CHECK_ACCESS(e_ptr);
27040         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
27041         e_conv = GraphSyncError_clone((LDKGraphSyncError*)untag_ptr(e));
27042         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
27043         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
27044         return tag_ptr(ret_conv, true);
27045 }
27046
27047 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
27048         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(o);
27049         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
27050         return ret_conv;
27051 }
27052
27053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
27054         if (!ptr_is_owned(_res)) return;
27055         void* _res_ptr = untag_ptr(_res);
27056         CHECK_ACCESS(_res_ptr);
27057         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
27058         FREE(untag_ptr(_res));
27059         CResult_u32GraphSyncErrorZ_free(_res_conv);
27060 }
27061
27062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27063         if (!ptr_is_owned(this_ptr)) return;
27064         void* this_ptr_ptr = untag_ptr(this_ptr);
27065         CHECK_ACCESS(this_ptr_ptr);
27066         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
27067         FREE(untag_ptr(this_ptr));
27068         APIError_free(this_ptr_conv);
27069 }
27070
27071 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
27072         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27073         *ret_copy = APIError_clone(arg);
27074         int64_t ret_ref = tag_ptr(ret_copy, true);
27075         return ret_ref;
27076 }
27077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27078         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
27079         int64_t ret_conv = APIError_clone_ptr(arg_conv);
27080         return ret_conv;
27081 }
27082
27083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27084         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
27085         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27086         *ret_copy = APIError_clone(orig_conv);
27087         int64_t ret_ref = tag_ptr(ret_copy, true);
27088         return ret_ref;
27089 }
27090
27091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
27092         LDKStr err_conv = java_to_owned_str(env, err);
27093         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27094         *ret_copy = APIError_apimisuse_error(err_conv);
27095         int64_t ret_ref = tag_ptr(ret_copy, true);
27096         return ret_ref;
27097 }
27098
27099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
27100         LDKStr err_conv = java_to_owned_str(env, err);
27101         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27102         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
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_APIError_1invalid_1route(JNIEnv *env, jclass clz, jstring err) {
27108         LDKStr err_conv = java_to_owned_str(env, err);
27109         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27110         *ret_copy = APIError_invalid_route(err_conv);
27111         int64_t ret_ref = tag_ptr(ret_copy, true);
27112         return ret_ref;
27113 }
27114
27115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
27116         LDKStr err_conv = java_to_owned_str(env, err);
27117         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27118         *ret_copy = APIError_channel_unavailable(err_conv);
27119         int64_t ret_ref = tag_ptr(ret_copy, true);
27120         return ret_ref;
27121 }
27122
27123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1in_1progress(JNIEnv *env, jclass clz) {
27124         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27125         *ret_copy = APIError_monitor_update_in_progress();
27126         int64_t ret_ref = tag_ptr(ret_copy, true);
27127         return ret_ref;
27128 }
27129
27130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
27131         LDKShutdownScript script_conv;
27132         script_conv.inner = untag_ptr(script);
27133         script_conv.is_owned = ptr_is_owned(script);
27134         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
27135         script_conv = ShutdownScript_clone(&script_conv);
27136         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27137         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
27138         int64_t ret_ref = tag_ptr(ret_copy, true);
27139         return ret_ref;
27140 }
27141
27142 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_APIError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27143         LDKAPIError* a_conv = (LDKAPIError*)untag_ptr(a);
27144         LDKAPIError* b_conv = (LDKAPIError*)untag_ptr(b);
27145         jboolean ret_conv = APIError_eq(a_conv, b_conv);
27146         return ret_conv;
27147 }
27148
27149 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_APIError_1write(JNIEnv *env, jclass clz, int64_t obj) {
27150         LDKAPIError* obj_conv = (LDKAPIError*)untag_ptr(obj);
27151         LDKCVec_u8Z ret_var = APIError_write(obj_conv);
27152         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27153         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27154         CVec_u8Z_free(ret_var);
27155         return ret_arr;
27156 }
27157
27158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27159         LDKu8slice ser_ref;
27160         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27161         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27162         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
27163         *ret_conv = APIError_read(ser_ref);
27164         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27165         return tag_ptr(ret_conv, true);
27166 }
27167
27168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27169         LDKBigSize this_obj_conv;
27170         this_obj_conv.inner = untag_ptr(this_obj);
27171         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27173         BigSize_free(this_obj_conv);
27174 }
27175
27176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27177         LDKBigSize this_ptr_conv;
27178         this_ptr_conv.inner = untag_ptr(this_ptr);
27179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27181         this_ptr_conv.is_owned = false;
27182         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
27183         return ret_conv;
27184 }
27185
27186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27187         LDKBigSize this_ptr_conv;
27188         this_ptr_conv.inner = untag_ptr(this_ptr);
27189         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27191         this_ptr_conv.is_owned = false;
27192         BigSize_set_a(&this_ptr_conv, val);
27193 }
27194
27195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
27196         LDKBigSize ret_var = BigSize_new(a_arg);
27197         int64_t ret_ref = 0;
27198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27199         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27200         return ret_ref;
27201 }
27202
27203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27204         LDKHostname this_obj_conv;
27205         this_obj_conv.inner = untag_ptr(this_obj);
27206         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27208         Hostname_free(this_obj_conv);
27209 }
27210
27211 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
27212         LDKHostname ret_var = Hostname_clone(arg);
27213         int64_t ret_ref = 0;
27214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27215         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27216         return ret_ref;
27217 }
27218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27219         LDKHostname arg_conv;
27220         arg_conv.inner = untag_ptr(arg);
27221         arg_conv.is_owned = ptr_is_owned(arg);
27222         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27223         arg_conv.is_owned = false;
27224         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
27225         return ret_conv;
27226 }
27227
27228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27229         LDKHostname orig_conv;
27230         orig_conv.inner = untag_ptr(orig);
27231         orig_conv.is_owned = ptr_is_owned(orig);
27232         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27233         orig_conv.is_owned = false;
27234         LDKHostname ret_var = Hostname_clone(&orig_conv);
27235         int64_t ret_ref = 0;
27236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27237         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27238         return ret_ref;
27239 }
27240
27241 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Hostname_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27242         LDKHostname a_conv;
27243         a_conv.inner = untag_ptr(a);
27244         a_conv.is_owned = ptr_is_owned(a);
27245         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27246         a_conv.is_owned = false;
27247         LDKHostname b_conv;
27248         b_conv.inner = untag_ptr(b);
27249         b_conv.is_owned = ptr_is_owned(b);
27250         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27251         b_conv.is_owned = false;
27252         jboolean ret_conv = Hostname_eq(&a_conv, &b_conv);
27253         return ret_conv;
27254 }
27255
27256 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
27257         LDKHostname this_arg_conv;
27258         this_arg_conv.inner = untag_ptr(this_arg);
27259         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27261         this_arg_conv.is_owned = false;
27262         int8_t ret_conv = Hostname_len(&this_arg_conv);
27263         return ret_conv;
27264 }
27265
27266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
27267         LDKu8slice msg_ref;
27268         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27269         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27270         uint8_t sk_arr[32];
27271         CHECK((*env)->GetArrayLength(env, sk) == 32);
27272         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
27273         uint8_t (*sk_ref)[32] = &sk_arr;
27274         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
27275         *ret_conv = sign(msg_ref, sk_ref);
27276         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27277         return tag_ptr(ret_conv, true);
27278 }
27279
27280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
27281         LDKu8slice msg_ref;
27282         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27283         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27284         LDKStr sig_conv = java_to_owned_str(env, sig);
27285         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
27286         *ret_conv = recover_pk(msg_ref, sig_conv);
27287         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27288         return tag_ptr(ret_conv, true);
27289 }
27290
27291 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
27292         LDKu8slice msg_ref;
27293         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27294         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27295         LDKStr sig_conv = java_to_owned_str(env, sig);
27296         LDKPublicKey pk_ref;
27297         CHECK((*env)->GetArrayLength(env, pk) == 33);
27298         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
27299         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
27300         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27301         return ret_conv;
27302 }
27303
27304 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
27305         LDKu8slice hrp_bytes_ref;
27306         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
27307         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
27308         LDKCVec_U5Z data_without_signature_constr;
27309         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
27310         if (data_without_signature_constr.datalen > 0)
27311                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
27312         else
27313                 data_without_signature_constr.data = NULL;
27314         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
27315         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
27316                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
27317                 
27318                 data_without_signature_constr.data[h] = (LDKU5){ ._0 = data_without_signature_conv_7 };
27319         }
27320         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
27321         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
27322         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27323         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27324         CVec_u8Z_free(ret_var);
27325         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
27326         return ret_arr;
27327 }
27328
27329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27330         if (!ptr_is_owned(this_ptr)) return;
27331         void* this_ptr_ptr = untag_ptr(this_ptr);
27332         CHECK_ACCESS(this_ptr_ptr);
27333         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
27334         FREE(untag_ptr(this_ptr));
27335         Persister_free(this_ptr_conv);
27336 }
27337
27338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UntrustedString_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27339         LDKUntrustedString this_obj_conv;
27340         this_obj_conv.inner = untag_ptr(this_obj);
27341         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27343         UntrustedString_free(this_obj_conv);
27344 }
27345
27346 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_UntrustedString_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27347         LDKUntrustedString this_ptr_conv;
27348         this_ptr_conv.inner = untag_ptr(this_ptr);
27349         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27351         this_ptr_conv.is_owned = false;
27352         LDKStr ret_str = UntrustedString_get_a(&this_ptr_conv);
27353         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27354         Str_free(ret_str);
27355         return ret_conv;
27356 }
27357
27358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UntrustedString_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27359         LDKUntrustedString this_ptr_conv;
27360         this_ptr_conv.inner = untag_ptr(this_ptr);
27361         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27363         this_ptr_conv.is_owned = false;
27364         LDKStr val_conv = java_to_owned_str(env, val);
27365         UntrustedString_set_a(&this_ptr_conv, val_conv);
27366 }
27367
27368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1new(JNIEnv *env, jclass clz, jstring a_arg) {
27369         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
27370         LDKUntrustedString ret_var = UntrustedString_new(a_arg_conv);
27371         int64_t ret_ref = 0;
27372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27373         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27374         return ret_ref;
27375 }
27376
27377 static inline uint64_t UntrustedString_clone_ptr(LDKUntrustedString *NONNULL_PTR arg) {
27378         LDKUntrustedString ret_var = UntrustedString_clone(arg);
27379         int64_t ret_ref = 0;
27380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27381         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27382         return ret_ref;
27383 }
27384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27385         LDKUntrustedString arg_conv;
27386         arg_conv.inner = untag_ptr(arg);
27387         arg_conv.is_owned = ptr_is_owned(arg);
27388         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27389         arg_conv.is_owned = false;
27390         int64_t ret_conv = UntrustedString_clone_ptr(&arg_conv);
27391         return ret_conv;
27392 }
27393
27394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27395         LDKUntrustedString orig_conv;
27396         orig_conv.inner = untag_ptr(orig);
27397         orig_conv.is_owned = ptr_is_owned(orig);
27398         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27399         orig_conv.is_owned = false;
27400         LDKUntrustedString ret_var = UntrustedString_clone(&orig_conv);
27401         int64_t ret_ref = 0;
27402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27403         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27404         return ret_ref;
27405 }
27406
27407 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UntrustedString_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27408         LDKUntrustedString a_conv;
27409         a_conv.inner = untag_ptr(a);
27410         a_conv.is_owned = ptr_is_owned(a);
27411         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27412         a_conv.is_owned = false;
27413         LDKUntrustedString b_conv;
27414         b_conv.inner = untag_ptr(b);
27415         b_conv.is_owned = ptr_is_owned(b);
27416         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27417         b_conv.is_owned = false;
27418         jboolean ret_conv = UntrustedString_eq(&a_conv, &b_conv);
27419         return ret_conv;
27420 }
27421
27422 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UntrustedString_1write(JNIEnv *env, jclass clz, int64_t obj) {
27423         LDKUntrustedString obj_conv;
27424         obj_conv.inner = untag_ptr(obj);
27425         obj_conv.is_owned = ptr_is_owned(obj);
27426         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27427         obj_conv.is_owned = false;
27428         LDKCVec_u8Z ret_var = UntrustedString_write(&obj_conv);
27429         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27430         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27431         CVec_u8Z_free(ret_var);
27432         return ret_arr;
27433 }
27434
27435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27436         LDKu8slice ser_ref;
27437         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27438         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27439         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
27440         *ret_conv = UntrustedString_read(ser_ref);
27441         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27442         return tag_ptr(ret_conv, true);
27443 }
27444
27445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27446         LDKPrintableString this_obj_conv;
27447         this_obj_conv.inner = untag_ptr(this_obj);
27448         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27450         PrintableString_free(this_obj_conv);
27451 }
27452
27453 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_PrintableString_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27454         LDKPrintableString this_ptr_conv;
27455         this_ptr_conv.inner = untag_ptr(this_ptr);
27456         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27458         this_ptr_conv.is_owned = false;
27459         LDKStr ret_str = PrintableString_get_a(&this_ptr_conv);
27460         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27461         Str_free(ret_str);
27462         return ret_conv;
27463 }
27464
27465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27466         LDKPrintableString this_ptr_conv;
27467         this_ptr_conv.inner = untag_ptr(this_ptr);
27468         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27470         this_ptr_conv.is_owned = false;
27471         LDKStr val_conv = java_to_owned_str(env, val);
27472         PrintableString_set_a(&this_ptr_conv, val_conv);
27473 }
27474
27475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrintableString_1new(JNIEnv *env, jclass clz, jstring a_arg) {
27476         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
27477         LDKPrintableString ret_var = PrintableString_new(a_arg_conv);
27478         int64_t ret_ref = 0;
27479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27480         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27481         return ret_ref;
27482 }
27483
27484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27485         if (!ptr_is_owned(this_ptr)) return;
27486         void* this_ptr_ptr = untag_ptr(this_ptr);
27487         CHECK_ACCESS(this_ptr_ptr);
27488         LDKFutureCallback this_ptr_conv = *(LDKFutureCallback*)(this_ptr_ptr);
27489         FREE(untag_ptr(this_ptr));
27490         FutureCallback_free(this_ptr_conv);
27491 }
27492
27493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27494         LDKFuture this_obj_conv;
27495         this_obj_conv.inner = untag_ptr(this_obj);
27496         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27498         Future_free(this_obj_conv);
27499 }
27500
27501 static inline uint64_t Future_clone_ptr(LDKFuture *NONNULL_PTR arg) {
27502         LDKFuture ret_var = Future_clone(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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Future_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27509         LDKFuture arg_conv;
27510         arg_conv.inner = untag_ptr(arg);
27511         arg_conv.is_owned = ptr_is_owned(arg);
27512         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27513         arg_conv.is_owned = false;
27514         int64_t ret_conv = Future_clone_ptr(&arg_conv);
27515         return ret_conv;
27516 }
27517
27518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Future_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27519         LDKFuture orig_conv;
27520         orig_conv.inner = untag_ptr(orig);
27521         orig_conv.is_owned = ptr_is_owned(orig);
27522         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27523         orig_conv.is_owned = false;
27524         LDKFuture ret_var = Future_clone(&orig_conv);
27525         int64_t ret_ref = 0;
27526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27527         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27528         return ret_ref;
27529 }
27530
27531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1register_1callback_1fn(JNIEnv *env, jclass clz, int64_t this_arg, int64_t callback) {
27532         LDKFuture this_arg_conv;
27533         this_arg_conv.inner = untag_ptr(this_arg);
27534         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27536         this_arg_conv.is_owned = false;
27537         void* callback_ptr = untag_ptr(callback);
27538         CHECK_ACCESS(callback_ptr);
27539         LDKFutureCallback callback_conv = *(LDKFutureCallback*)(callback_ptr);
27540         if (callback_conv.free == LDKFutureCallback_JCalls_free) {
27541                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27542                 LDKFutureCallback_JCalls_cloned(&callback_conv);
27543         }
27544         Future_register_callback_fn(&this_arg_conv, callback_conv);
27545 }
27546
27547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1wait(JNIEnv *env, jclass clz, int64_t this_arg) {
27548         LDKFuture this_arg_conv;
27549         this_arg_conv.inner = untag_ptr(this_arg);
27550         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27552         this_arg_conv = Future_clone(&this_arg_conv);
27553         Future_wait(this_arg_conv);
27554 }
27555
27556 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Future_1wait_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
27557         LDKFuture this_arg_conv;
27558         this_arg_conv.inner = untag_ptr(this_arg);
27559         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27561         this_arg_conv = Future_clone(&this_arg_conv);
27562         jboolean ret_conv = Future_wait_timeout(this_arg_conv, max_wait);
27563         return ret_conv;
27564 }
27565
27566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sleeper_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27567         LDKSleeper this_obj_conv;
27568         this_obj_conv.inner = untag_ptr(this_obj);
27569         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27571         Sleeper_free(this_obj_conv);
27572 }
27573
27574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sleeper_1from_1single_1future(JNIEnv *env, jclass clz, int64_t future) {
27575         LDKFuture future_conv;
27576         future_conv.inner = untag_ptr(future);
27577         future_conv.is_owned = ptr_is_owned(future);
27578         CHECK_INNER_FIELD_ACCESS_OR_NULL(future_conv);
27579         future_conv = Future_clone(&future_conv);
27580         LDKSleeper ret_var = Sleeper_from_single_future(future_conv);
27581         int64_t ret_ref = 0;
27582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27584         return ret_ref;
27585 }
27586
27587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sleeper_1from_1two_1futures(JNIEnv *env, jclass clz, int64_t fut_a, int64_t fut_b) {
27588         LDKFuture fut_a_conv;
27589         fut_a_conv.inner = untag_ptr(fut_a);
27590         fut_a_conv.is_owned = ptr_is_owned(fut_a);
27591         CHECK_INNER_FIELD_ACCESS_OR_NULL(fut_a_conv);
27592         fut_a_conv = Future_clone(&fut_a_conv);
27593         LDKFuture fut_b_conv;
27594         fut_b_conv.inner = untag_ptr(fut_b);
27595         fut_b_conv.is_owned = ptr_is_owned(fut_b);
27596         CHECK_INNER_FIELD_ACCESS_OR_NULL(fut_b_conv);
27597         fut_b_conv = Future_clone(&fut_b_conv);
27598         LDKSleeper ret_var = Sleeper_from_two_futures(fut_a_conv, fut_b_conv);
27599         int64_t ret_ref = 0;
27600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27601         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27602         return ret_ref;
27603 }
27604
27605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sleeper_1new(JNIEnv *env, jclass clz, int64_tArray futures) {
27606         LDKCVec_FutureZ futures_constr;
27607         futures_constr.datalen = (*env)->GetArrayLength(env, futures);
27608         if (futures_constr.datalen > 0)
27609                 futures_constr.data = MALLOC(futures_constr.datalen * sizeof(LDKFuture), "LDKCVec_FutureZ Elements");
27610         else
27611                 futures_constr.data = NULL;
27612         int64_t* futures_vals = (*env)->GetLongArrayElements (env, futures, NULL);
27613         for (size_t i = 0; i < futures_constr.datalen; i++) {
27614                 int64_t futures_conv_8 = futures_vals[i];
27615                 LDKFuture futures_conv_8_conv;
27616                 futures_conv_8_conv.inner = untag_ptr(futures_conv_8);
27617                 futures_conv_8_conv.is_owned = ptr_is_owned(futures_conv_8);
27618                 CHECK_INNER_FIELD_ACCESS_OR_NULL(futures_conv_8_conv);
27619                 futures_conv_8_conv = Future_clone(&futures_conv_8_conv);
27620                 futures_constr.data[i] = futures_conv_8_conv;
27621         }
27622         (*env)->ReleaseLongArrayElements(env, futures, futures_vals, 0);
27623         LDKSleeper ret_var = Sleeper_new(futures_constr);
27624         int64_t ret_ref = 0;
27625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27626         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27627         return ret_ref;
27628 }
27629
27630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sleeper_1wait(JNIEnv *env, jclass clz, int64_t this_arg) {
27631         LDKSleeper this_arg_conv;
27632         this_arg_conv.inner = untag_ptr(this_arg);
27633         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27635         this_arg_conv.is_owned = false;
27636         Sleeper_wait(&this_arg_conv);
27637 }
27638
27639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sleeper_1wait_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
27640         LDKSleeper this_arg_conv;
27641         this_arg_conv.inner = untag_ptr(this_arg);
27642         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27644         this_arg_conv.is_owned = false;
27645         jboolean ret_conv = Sleeper_wait_timeout(&this_arg_conv, max_wait);
27646         return ret_conv;
27647 }
27648
27649 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27650         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
27651         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
27652         return ret_conv;
27653 }
27654
27655 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
27656         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
27657         return ret_conv;
27658 }
27659
27660 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
27661         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
27662         return ret_conv;
27663 }
27664
27665 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
27666         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
27667         return ret_conv;
27668 }
27669
27670 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
27671         jclass ret_conv = LDKLevel_to_java(env, Level_info());
27672         return ret_conv;
27673 }
27674
27675 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
27676         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
27677         return ret_conv;
27678 }
27679
27680 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
27681         jclass ret_conv = LDKLevel_to_java(env, Level_error());
27682         return ret_conv;
27683 }
27684
27685 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27686         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
27687         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
27688         jboolean ret_conv = Level_eq(a_conv, b_conv);
27689         return ret_conv;
27690 }
27691
27692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
27693         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
27694         int64_t ret_conv = Level_hash(o_conv);
27695         return ret_conv;
27696 }
27697
27698 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
27699         jclass ret_conv = LDKLevel_to_java(env, Level_max());
27700         return ret_conv;
27701 }
27702
27703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27704         LDKRecord this_obj_conv;
27705         this_obj_conv.inner = untag_ptr(this_obj);
27706         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27708         Record_free(this_obj_conv);
27709 }
27710
27711 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
27712         LDKRecord this_ptr_conv;
27713         this_ptr_conv.inner = untag_ptr(this_ptr);
27714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27716         this_ptr_conv.is_owned = false;
27717         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
27718         return ret_conv;
27719 }
27720
27721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
27722         LDKRecord this_ptr_conv;
27723         this_ptr_conv.inner = untag_ptr(this_ptr);
27724         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27726         this_ptr_conv.is_owned = false;
27727         LDKLevel val_conv = LDKLevel_from_java(env, val);
27728         Record_set_level(&this_ptr_conv, val_conv);
27729 }
27730
27731 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
27732         LDKRecord this_ptr_conv;
27733         this_ptr_conv.inner = untag_ptr(this_ptr);
27734         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27736         this_ptr_conv.is_owned = false;
27737         LDKStr ret_str = Record_get_args(&this_ptr_conv);
27738         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27739         Str_free(ret_str);
27740         return ret_conv;
27741 }
27742
27743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27744         LDKRecord this_ptr_conv;
27745         this_ptr_conv.inner = untag_ptr(this_ptr);
27746         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27748         this_ptr_conv.is_owned = false;
27749         LDKStr val_conv = java_to_owned_str(env, val);
27750         Record_set_args(&this_ptr_conv, val_conv);
27751 }
27752
27753 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
27754         LDKRecord this_ptr_conv;
27755         this_ptr_conv.inner = untag_ptr(this_ptr);
27756         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27758         this_ptr_conv.is_owned = false;
27759         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
27760         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27761         Str_free(ret_str);
27762         return ret_conv;
27763 }
27764
27765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27766         LDKRecord this_ptr_conv;
27767         this_ptr_conv.inner = untag_ptr(this_ptr);
27768         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27770         this_ptr_conv.is_owned = false;
27771         LDKStr val_conv = java_to_owned_str(env, val);
27772         Record_set_module_path(&this_ptr_conv, val_conv);
27773 }
27774
27775 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
27776         LDKRecord this_ptr_conv;
27777         this_ptr_conv.inner = untag_ptr(this_ptr);
27778         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27780         this_ptr_conv.is_owned = false;
27781         LDKStr ret_str = Record_get_file(&this_ptr_conv);
27782         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27783         Str_free(ret_str);
27784         return ret_conv;
27785 }
27786
27787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27788         LDKRecord this_ptr_conv;
27789         this_ptr_conv.inner = untag_ptr(this_ptr);
27790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27792         this_ptr_conv.is_owned = false;
27793         LDKStr val_conv = java_to_owned_str(env, val);
27794         Record_set_file(&this_ptr_conv, val_conv);
27795 }
27796
27797 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
27798         LDKRecord this_ptr_conv;
27799         this_ptr_conv.inner = untag_ptr(this_ptr);
27800         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27802         this_ptr_conv.is_owned = false;
27803         int32_t ret_conv = Record_get_line(&this_ptr_conv);
27804         return ret_conv;
27805 }
27806
27807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27808         LDKRecord this_ptr_conv;
27809         this_ptr_conv.inner = untag_ptr(this_ptr);
27810         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27812         this_ptr_conv.is_owned = false;
27813         Record_set_line(&this_ptr_conv, val);
27814 }
27815
27816 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
27817         LDKRecord ret_var = Record_clone(arg);
27818         int64_t ret_ref = 0;
27819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27820         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27821         return ret_ref;
27822 }
27823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27824         LDKRecord arg_conv;
27825         arg_conv.inner = untag_ptr(arg);
27826         arg_conv.is_owned = ptr_is_owned(arg);
27827         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27828         arg_conv.is_owned = false;
27829         int64_t ret_conv = Record_clone_ptr(&arg_conv);
27830         return ret_conv;
27831 }
27832
27833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27834         LDKRecord orig_conv;
27835         orig_conv.inner = untag_ptr(orig);
27836         orig_conv.is_owned = ptr_is_owned(orig);
27837         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27838         orig_conv.is_owned = false;
27839         LDKRecord ret_var = Record_clone(&orig_conv);
27840         int64_t ret_ref = 0;
27841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27842         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27843         return ret_ref;
27844 }
27845
27846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27847         if (!ptr_is_owned(this_ptr)) return;
27848         void* this_ptr_ptr = untag_ptr(this_ptr);
27849         CHECK_ACCESS(this_ptr_ptr);
27850         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
27851         FREE(untag_ptr(this_ptr));
27852         Logger_free(this_ptr_conv);
27853 }
27854
27855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27856         LDKChannelHandshakeConfig this_obj_conv;
27857         this_obj_conv.inner = untag_ptr(this_obj);
27858         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27860         ChannelHandshakeConfig_free(this_obj_conv);
27861 }
27862
27863 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
27864         LDKChannelHandshakeConfig this_ptr_conv;
27865         this_ptr_conv.inner = untag_ptr(this_ptr);
27866         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27868         this_ptr_conv.is_owned = false;
27869         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
27870         return ret_conv;
27871 }
27872
27873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27874         LDKChannelHandshakeConfig this_ptr_conv;
27875         this_ptr_conv.inner = untag_ptr(this_ptr);
27876         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27878         this_ptr_conv.is_owned = false;
27879         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
27880 }
27881
27882 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27883         LDKChannelHandshakeConfig this_ptr_conv;
27884         this_ptr_conv.inner = untag_ptr(this_ptr);
27885         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27887         this_ptr_conv.is_owned = false;
27888         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
27889         return ret_conv;
27890 }
27891
27892 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) {
27893         LDKChannelHandshakeConfig this_ptr_conv;
27894         this_ptr_conv.inner = untag_ptr(this_ptr);
27895         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27897         this_ptr_conv.is_owned = false;
27898         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
27899 }
27900
27901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27902         LDKChannelHandshakeConfig this_ptr_conv;
27903         this_ptr_conv.inner = untag_ptr(this_ptr);
27904         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27906         this_ptr_conv.is_owned = false;
27907         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
27908         return ret_conv;
27909 }
27910
27911 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) {
27912         LDKChannelHandshakeConfig this_ptr_conv;
27913         this_ptr_conv.inner = untag_ptr(this_ptr);
27914         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27916         this_ptr_conv.is_owned = false;
27917         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
27918 }
27919
27920 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) {
27921         LDKChannelHandshakeConfig this_ptr_conv;
27922         this_ptr_conv.inner = untag_ptr(this_ptr);
27923         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27925         this_ptr_conv.is_owned = false;
27926         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
27927         return ret_conv;
27928 }
27929
27930 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) {
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         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
27937 }
27938
27939 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
27940         LDKChannelHandshakeConfig this_ptr_conv;
27941         this_ptr_conv.inner = untag_ptr(this_ptr);
27942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27944         this_ptr_conv.is_owned = false;
27945         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
27946         return ret_conv;
27947 }
27948
27949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
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         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
27956 }
27957
27958 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
27959         LDKChannelHandshakeConfig this_ptr_conv;
27960         this_ptr_conv.inner = untag_ptr(this_ptr);
27961         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27963         this_ptr_conv.is_owned = false;
27964         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
27965         return ret_conv;
27966 }
27967
27968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
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         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
27975 }
27976
27977 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27978         LDKChannelHandshakeConfig this_ptr_conv;
27979         this_ptr_conv.inner = untag_ptr(this_ptr);
27980         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27982         this_ptr_conv.is_owned = false;
27983         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
27984         return ret_conv;
27985 }
27986
27987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
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         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
27994 }
27995
27996 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1their_1channel_1reserve_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27997         LDKChannelHandshakeConfig this_ptr_conv;
27998         this_ptr_conv.inner = untag_ptr(this_ptr);
27999         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28001         this_ptr_conv.is_owned = false;
28002         int32_t ret_conv = ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(&this_ptr_conv);
28003         return ret_conv;
28004 }
28005
28006 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) {
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         ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(&this_ptr_conv, val);
28013 }
28014
28015 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28016         LDKChannelHandshakeConfig this_ptr_conv;
28017         this_ptr_conv.inner = untag_ptr(this_ptr);
28018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28020         this_ptr_conv.is_owned = false;
28021         int16_t ret_conv = ChannelHandshakeConfig_get_our_max_accepted_htlcs(&this_ptr_conv);
28022         return ret_conv;
28023 }
28024
28025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1our_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
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         ChannelHandshakeConfig_set_our_max_accepted_htlcs(&this_ptr_conv, val);
28032 }
28033
28034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv *env, jclass clz, int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg, int8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, jboolean negotiate_scid_privacy_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int32_t their_channel_reserve_proportional_millionths_arg, int16_t our_max_accepted_htlcs_arg) {
28035         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, their_channel_reserve_proportional_millionths_arg, our_max_accepted_htlcs_arg);
28036         int64_t ret_ref = 0;
28037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28038         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28039         return ret_ref;
28040 }
28041
28042 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
28043         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
28044         int64_t ret_ref = 0;
28045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28046         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28047         return ret_ref;
28048 }
28049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28050         LDKChannelHandshakeConfig arg_conv;
28051         arg_conv.inner = untag_ptr(arg);
28052         arg_conv.is_owned = ptr_is_owned(arg);
28053         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28054         arg_conv.is_owned = false;
28055         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
28056         return ret_conv;
28057 }
28058
28059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28060         LDKChannelHandshakeConfig orig_conv;
28061         orig_conv.inner = untag_ptr(orig);
28062         orig_conv.is_owned = ptr_is_owned(orig);
28063         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28064         orig_conv.is_owned = false;
28065         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
28066         int64_t ret_ref = 0;
28067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28068         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28069         return ret_ref;
28070 }
28071
28072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
28073         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
28074         int64_t ret_ref = 0;
28075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28076         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28077         return ret_ref;
28078 }
28079
28080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28081         LDKChannelHandshakeLimits this_obj_conv;
28082         this_obj_conv.inner = untag_ptr(this_obj);
28083         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28085         ChannelHandshakeLimits_free(this_obj_conv);
28086 }
28087
28088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28089         LDKChannelHandshakeLimits this_ptr_conv;
28090         this_ptr_conv.inner = untag_ptr(this_ptr);
28091         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28093         this_ptr_conv.is_owned = false;
28094         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
28095         return ret_conv;
28096 }
28097
28098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28099         LDKChannelHandshakeLimits this_ptr_conv;
28100         this_ptr_conv.inner = untag_ptr(this_ptr);
28101         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28103         this_ptr_conv.is_owned = false;
28104         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
28105 }
28106
28107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28108         LDKChannelHandshakeLimits this_ptr_conv;
28109         this_ptr_conv.inner = untag_ptr(this_ptr);
28110         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28112         this_ptr_conv.is_owned = false;
28113         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
28114         return ret_conv;
28115 }
28116
28117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28118         LDKChannelHandshakeLimits this_ptr_conv;
28119         this_ptr_conv.inner = untag_ptr(this_ptr);
28120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28122         this_ptr_conv.is_owned = false;
28123         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
28124 }
28125
28126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28127         LDKChannelHandshakeLimits this_ptr_conv;
28128         this_ptr_conv.inner = untag_ptr(this_ptr);
28129         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28131         this_ptr_conv.is_owned = false;
28132         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
28133         return ret_conv;
28134 }
28135
28136 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) {
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         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
28143 }
28144
28145 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) {
28146         LDKChannelHandshakeLimits this_ptr_conv;
28147         this_ptr_conv.inner = untag_ptr(this_ptr);
28148         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28150         this_ptr_conv.is_owned = false;
28151         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
28152         return ret_conv;
28153 }
28154
28155 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) {
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         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28162 }
28163
28164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28165         LDKChannelHandshakeLimits this_ptr_conv;
28166         this_ptr_conv.inner = untag_ptr(this_ptr);
28167         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28169         this_ptr_conv.is_owned = false;
28170         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
28171         return ret_conv;
28172 }
28173
28174 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) {
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         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
28181 }
28182
28183 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28184         LDKChannelHandshakeLimits this_ptr_conv;
28185         this_ptr_conv.inner = untag_ptr(this_ptr);
28186         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28188         this_ptr_conv.is_owned = false;
28189         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
28190         return ret_conv;
28191 }
28192
28193 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) {
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         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
28200 }
28201
28202 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
28203         LDKChannelHandshakeLimits this_ptr_conv;
28204         this_ptr_conv.inner = untag_ptr(this_ptr);
28205         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28207         this_ptr_conv.is_owned = false;
28208         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
28209         return ret_conv;
28210 }
28211
28212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
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         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
28219 }
28220
28221 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
28222         LDKChannelHandshakeLimits this_ptr_conv;
28223         this_ptr_conv.inner = untag_ptr(this_ptr);
28224         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28226         this_ptr_conv.is_owned = false;
28227         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
28228         return ret_conv;
28229 }
28230
28231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
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         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
28238 }
28239
28240 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
28241         LDKChannelHandshakeLimits this_ptr_conv;
28242         this_ptr_conv.inner = untag_ptr(this_ptr);
28243         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28245         this_ptr_conv.is_owned = false;
28246         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
28247         return ret_conv;
28248 }
28249
28250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
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         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
28257 }
28258
28259 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28260         LDKChannelHandshakeLimits this_ptr_conv;
28261         this_ptr_conv.inner = untag_ptr(this_ptr);
28262         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28264         this_ptr_conv.is_owned = false;
28265         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
28266         return ret_conv;
28267 }
28268
28269 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) {
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         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
28276 }
28277
28278 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) {
28279         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);
28280         int64_t ret_ref = 0;
28281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28282         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28283         return ret_ref;
28284 }
28285
28286 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
28287         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
28288         int64_t ret_ref = 0;
28289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28290         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28291         return ret_ref;
28292 }
28293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28294         LDKChannelHandshakeLimits arg_conv;
28295         arg_conv.inner = untag_ptr(arg);
28296         arg_conv.is_owned = ptr_is_owned(arg);
28297         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28298         arg_conv.is_owned = false;
28299         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
28300         return ret_conv;
28301 }
28302
28303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28304         LDKChannelHandshakeLimits orig_conv;
28305         orig_conv.inner = untag_ptr(orig);
28306         orig_conv.is_owned = ptr_is_owned(orig);
28307         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28308         orig_conv.is_owned = false;
28309         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
28310         int64_t ret_ref = 0;
28311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28312         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28313         return ret_ref;
28314 }
28315
28316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
28317         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
28318         int64_t ret_ref = 0;
28319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28320         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28321         return ret_ref;
28322 }
28323
28324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28325         LDKChannelConfig this_obj_conv;
28326         this_obj_conv.inner = untag_ptr(this_obj);
28327         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28329         ChannelConfig_free(this_obj_conv);
28330 }
28331
28332 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28333         LDKChannelConfig this_ptr_conv;
28334         this_ptr_conv.inner = untag_ptr(this_ptr);
28335         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28337         this_ptr_conv.is_owned = false;
28338         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
28339         return ret_conv;
28340 }
28341
28342 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) {
28343         LDKChannelConfig this_ptr_conv;
28344         this_ptr_conv.inner = untag_ptr(this_ptr);
28345         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28347         this_ptr_conv.is_owned = false;
28348         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
28349 }
28350
28351 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28352         LDKChannelConfig this_ptr_conv;
28353         this_ptr_conv.inner = untag_ptr(this_ptr);
28354         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28356         this_ptr_conv.is_owned = false;
28357         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
28358         return ret_conv;
28359 }
28360
28361 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) {
28362         LDKChannelConfig this_ptr_conv;
28363         this_ptr_conv.inner = untag_ptr(this_ptr);
28364         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28366         this_ptr_conv.is_owned = false;
28367         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
28368 }
28369
28370 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28371         LDKChannelConfig this_ptr_conv;
28372         this_ptr_conv.inner = untag_ptr(this_ptr);
28373         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28375         this_ptr_conv.is_owned = false;
28376         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
28377         return ret_conv;
28378 }
28379
28380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
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         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
28387 }
28388
28389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28390         LDKChannelConfig this_ptr_conv;
28391         this_ptr_conv.inner = untag_ptr(this_ptr);
28392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28394         this_ptr_conv.is_owned = false;
28395         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
28396         return ret_conv;
28397 }
28398
28399 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) {
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         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
28406 }
28407
28408 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) {
28409         LDKChannelConfig this_ptr_conv;
28410         this_ptr_conv.inner = untag_ptr(this_ptr);
28411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28413         this_ptr_conv.is_owned = false;
28414         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
28415         return ret_conv;
28416 }
28417
28418 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) {
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         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
28425 }
28426
28427 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) {
28428         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);
28429         int64_t ret_ref = 0;
28430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28431         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28432         return ret_ref;
28433 }
28434
28435 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
28436         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
28437         int64_t ret_ref = 0;
28438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28439         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28440         return ret_ref;
28441 }
28442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28443         LDKChannelConfig arg_conv;
28444         arg_conv.inner = untag_ptr(arg);
28445         arg_conv.is_owned = ptr_is_owned(arg);
28446         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28447         arg_conv.is_owned = false;
28448         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
28449         return ret_conv;
28450 }
28451
28452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28453         LDKChannelConfig orig_conv;
28454         orig_conv.inner = untag_ptr(orig);
28455         orig_conv.is_owned = ptr_is_owned(orig);
28456         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28457         orig_conv.is_owned = false;
28458         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
28459         int64_t ret_ref = 0;
28460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28461         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28462         return ret_ref;
28463 }
28464
28465 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28466         LDKChannelConfig a_conv;
28467         a_conv.inner = untag_ptr(a);
28468         a_conv.is_owned = ptr_is_owned(a);
28469         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28470         a_conv.is_owned = false;
28471         LDKChannelConfig b_conv;
28472         b_conv.inner = untag_ptr(b);
28473         b_conv.is_owned = ptr_is_owned(b);
28474         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28475         b_conv.is_owned = false;
28476         jboolean ret_conv = ChannelConfig_eq(&a_conv, &b_conv);
28477         return ret_conv;
28478 }
28479
28480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
28481         LDKChannelConfig ret_var = ChannelConfig_default();
28482         int64_t ret_ref = 0;
28483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28484         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28485         return ret_ref;
28486 }
28487
28488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
28489         LDKChannelConfig obj_conv;
28490         obj_conv.inner = untag_ptr(obj);
28491         obj_conv.is_owned = ptr_is_owned(obj);
28492         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28493         obj_conv.is_owned = false;
28494         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
28495         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28496         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28497         CVec_u8Z_free(ret_var);
28498         return ret_arr;
28499 }
28500
28501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28502         LDKu8slice ser_ref;
28503         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28504         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28505         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
28506         *ret_conv = ChannelConfig_read(ser_ref);
28507         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28508         return tag_ptr(ret_conv, true);
28509 }
28510
28511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28512         LDKUserConfig this_obj_conv;
28513         this_obj_conv.inner = untag_ptr(this_obj);
28514         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28516         UserConfig_free(this_obj_conv);
28517 }
28518
28519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28520         LDKUserConfig this_ptr_conv;
28521         this_ptr_conv.inner = untag_ptr(this_ptr);
28522         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28524         this_ptr_conv.is_owned = false;
28525         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
28526         int64_t ret_ref = 0;
28527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28528         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28529         return ret_ref;
28530 }
28531
28532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28533         LDKUserConfig this_ptr_conv;
28534         this_ptr_conv.inner = untag_ptr(this_ptr);
28535         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28537         this_ptr_conv.is_owned = false;
28538         LDKChannelHandshakeConfig val_conv;
28539         val_conv.inner = untag_ptr(val);
28540         val_conv.is_owned = ptr_is_owned(val);
28541         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28542         val_conv = ChannelHandshakeConfig_clone(&val_conv);
28543         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
28544 }
28545
28546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
28547         LDKUserConfig this_ptr_conv;
28548         this_ptr_conv.inner = untag_ptr(this_ptr);
28549         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28551         this_ptr_conv.is_owned = false;
28552         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
28553         int64_t ret_ref = 0;
28554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28555         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28556         return ret_ref;
28557 }
28558
28559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28560         LDKUserConfig this_ptr_conv;
28561         this_ptr_conv.inner = untag_ptr(this_ptr);
28562         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28564         this_ptr_conv.is_owned = false;
28565         LDKChannelHandshakeLimits val_conv;
28566         val_conv.inner = untag_ptr(val);
28567         val_conv.is_owned = ptr_is_owned(val);
28568         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28569         val_conv = ChannelHandshakeLimits_clone(&val_conv);
28570         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
28571 }
28572
28573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28574         LDKUserConfig this_ptr_conv;
28575         this_ptr_conv.inner = untag_ptr(this_ptr);
28576         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28578         this_ptr_conv.is_owned = false;
28579         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
28580         int64_t ret_ref = 0;
28581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28582         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28583         return ret_ref;
28584 }
28585
28586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28587         LDKUserConfig this_ptr_conv;
28588         this_ptr_conv.inner = untag_ptr(this_ptr);
28589         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28591         this_ptr_conv.is_owned = false;
28592         LDKChannelConfig val_conv;
28593         val_conv.inner = untag_ptr(val);
28594         val_conv.is_owned = ptr_is_owned(val);
28595         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28596         val_conv = ChannelConfig_clone(&val_conv);
28597         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
28598 }
28599
28600 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28601         LDKUserConfig this_ptr_conv;
28602         this_ptr_conv.inner = untag_ptr(this_ptr);
28603         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28605         this_ptr_conv.is_owned = false;
28606         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
28607         return ret_conv;
28608 }
28609
28610 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) {
28611         LDKUserConfig this_ptr_conv;
28612         this_ptr_conv.inner = untag_ptr(this_ptr);
28613         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28615         this_ptr_conv.is_owned = false;
28616         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
28617 }
28618
28619 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28620         LDKUserConfig this_ptr_conv;
28621         this_ptr_conv.inner = untag_ptr(this_ptr);
28622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28624         this_ptr_conv.is_owned = false;
28625         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
28626         return ret_conv;
28627 }
28628
28629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28630         LDKUserConfig this_ptr_conv;
28631         this_ptr_conv.inner = untag_ptr(this_ptr);
28632         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28634         this_ptr_conv.is_owned = false;
28635         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
28636 }
28637
28638 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28639         LDKUserConfig this_ptr_conv;
28640         this_ptr_conv.inner = untag_ptr(this_ptr);
28641         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28643         this_ptr_conv.is_owned = false;
28644         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
28645         return ret_conv;
28646 }
28647
28648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
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         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
28655 }
28656
28657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28658         LDKUserConfig this_ptr_conv;
28659         this_ptr_conv.inner = untag_ptr(this_ptr);
28660         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28662         this_ptr_conv.is_owned = false;
28663         jboolean ret_conv = UserConfig_get_accept_intercept_htlcs(&this_ptr_conv);
28664         return ret_conv;
28665 }
28666
28667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
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         UserConfig_set_accept_intercept_htlcs(&this_ptr_conv, val);
28674 }
28675
28676 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) {
28677         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
28678         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
28679         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
28680         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
28681         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
28682         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
28683         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
28684         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
28685         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
28686         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
28687         LDKChannelConfig channel_config_arg_conv;
28688         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
28689         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
28690         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
28691         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
28692         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);
28693         int64_t ret_ref = 0;
28694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28696         return ret_ref;
28697 }
28698
28699 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
28700         LDKUserConfig ret_var = UserConfig_clone(arg);
28701         int64_t ret_ref = 0;
28702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28703         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28704         return ret_ref;
28705 }
28706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28707         LDKUserConfig arg_conv;
28708         arg_conv.inner = untag_ptr(arg);
28709         arg_conv.is_owned = ptr_is_owned(arg);
28710         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28711         arg_conv.is_owned = false;
28712         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
28713         return ret_conv;
28714 }
28715
28716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28717         LDKUserConfig orig_conv;
28718         orig_conv.inner = untag_ptr(orig);
28719         orig_conv.is_owned = ptr_is_owned(orig);
28720         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28721         orig_conv.is_owned = false;
28722         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
28723         int64_t ret_ref = 0;
28724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28725         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28726         return ret_ref;
28727 }
28728
28729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
28730         LDKUserConfig ret_var = UserConfig_default();
28731         int64_t ret_ref = 0;
28732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28733         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28734         return ret_ref;
28735 }
28736
28737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28738         LDKBestBlock this_obj_conv;
28739         this_obj_conv.inner = untag_ptr(this_obj);
28740         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28742         BestBlock_free(this_obj_conv);
28743 }
28744
28745 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
28746         LDKBestBlock ret_var = BestBlock_clone(arg);
28747         int64_t ret_ref = 0;
28748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28749         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28750         return ret_ref;
28751 }
28752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28753         LDKBestBlock arg_conv;
28754         arg_conv.inner = untag_ptr(arg);
28755         arg_conv.is_owned = ptr_is_owned(arg);
28756         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28757         arg_conv.is_owned = false;
28758         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
28759         return ret_conv;
28760 }
28761
28762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28763         LDKBestBlock orig_conv;
28764         orig_conv.inner = untag_ptr(orig);
28765         orig_conv.is_owned = ptr_is_owned(orig);
28766         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28767         orig_conv.is_owned = false;
28768         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
28769         int64_t ret_ref = 0;
28770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28771         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28772         return ret_ref;
28773 }
28774
28775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BestBlock_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28776         LDKBestBlock a_conv;
28777         a_conv.inner = untag_ptr(a);
28778         a_conv.is_owned = ptr_is_owned(a);
28779         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28780         a_conv.is_owned = false;
28781         LDKBestBlock b_conv;
28782         b_conv.inner = untag_ptr(b);
28783         b_conv.is_owned = ptr_is_owned(b);
28784         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28785         b_conv.is_owned = false;
28786         jboolean ret_conv = BestBlock_eq(&a_conv, &b_conv);
28787         return ret_conv;
28788 }
28789
28790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1network(JNIEnv *env, jclass clz, jclass network) {
28791         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
28792         LDKBestBlock ret_var = BestBlock_from_network(network_conv);
28793         int64_t ret_ref = 0;
28794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28795         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28796         return ret_ref;
28797 }
28798
28799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
28800         LDKThirtyTwoBytes block_hash_ref;
28801         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
28802         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
28803         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
28804         int64_t ret_ref = 0;
28805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28806         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28807         return ret_ref;
28808 }
28809
28810 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
28811         LDKBestBlock this_arg_conv;
28812         this_arg_conv.inner = untag_ptr(this_arg);
28813         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28815         this_arg_conv.is_owned = false;
28816         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28817         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
28818         return ret_arr;
28819 }
28820
28821 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
28822         LDKBestBlock this_arg_conv;
28823         this_arg_conv.inner = untag_ptr(this_arg);
28824         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28826         this_arg_conv.is_owned = false;
28827         int32_t ret_conv = BestBlock_height(&this_arg_conv);
28828         return ret_conv;
28829 }
28830
28831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28832         if (!ptr_is_owned(this_ptr)) return;
28833         void* this_ptr_ptr = untag_ptr(this_ptr);
28834         CHECK_ACCESS(this_ptr_ptr);
28835         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
28836         FREE(untag_ptr(this_ptr));
28837         Listen_free(this_ptr_conv);
28838 }
28839
28840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28841         if (!ptr_is_owned(this_ptr)) return;
28842         void* this_ptr_ptr = untag_ptr(this_ptr);
28843         CHECK_ACCESS(this_ptr_ptr);
28844         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
28845         FREE(untag_ptr(this_ptr));
28846         Confirm_free(this_ptr_conv);
28847 }
28848
28849 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28850         LDKChannelMonitorUpdateStatus* orig_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(orig);
28851         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_clone(orig_conv));
28852         return ret_conv;
28853 }
28854
28855 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1completed(JNIEnv *env, jclass clz) {
28856         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_completed());
28857         return ret_conv;
28858 }
28859
28860 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1in_1progress(JNIEnv *env, jclass clz) {
28861         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_in_progress());
28862         return ret_conv;
28863 }
28864
28865 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1permanent_1failure(JNIEnv *env, jclass clz) {
28866         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_permanent_failure());
28867         return ret_conv;
28868 }
28869
28870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28871         LDKChannelMonitorUpdateStatus* a_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(a);
28872         LDKChannelMonitorUpdateStatus* b_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(b);
28873         jboolean ret_conv = ChannelMonitorUpdateStatus_eq(a_conv, b_conv);
28874         return ret_conv;
28875 }
28876
28877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28878         if (!ptr_is_owned(this_ptr)) return;
28879         void* this_ptr_ptr = untag_ptr(this_ptr);
28880         CHECK_ACCESS(this_ptr_ptr);
28881         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
28882         FREE(untag_ptr(this_ptr));
28883         Watch_free(this_ptr_conv);
28884 }
28885
28886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28887         if (!ptr_is_owned(this_ptr)) return;
28888         void* this_ptr_ptr = untag_ptr(this_ptr);
28889         CHECK_ACCESS(this_ptr_ptr);
28890         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
28891         FREE(untag_ptr(this_ptr));
28892         Filter_free(this_ptr_conv);
28893 }
28894
28895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28896         LDKWatchedOutput this_obj_conv;
28897         this_obj_conv.inner = untag_ptr(this_obj);
28898         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28900         WatchedOutput_free(this_obj_conv);
28901 }
28902
28903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
28904         LDKWatchedOutput this_ptr_conv;
28905         this_ptr_conv.inner = untag_ptr(this_ptr);
28906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28908         this_ptr_conv.is_owned = false;
28909         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28910         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
28911         return ret_arr;
28912 }
28913
28914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28915         LDKWatchedOutput this_ptr_conv;
28916         this_ptr_conv.inner = untag_ptr(this_ptr);
28917         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28919         this_ptr_conv.is_owned = false;
28920         LDKThirtyTwoBytes val_ref;
28921         CHECK((*env)->GetArrayLength(env, val) == 32);
28922         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28923         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
28924 }
28925
28926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28927         LDKWatchedOutput this_ptr_conv;
28928         this_ptr_conv.inner = untag_ptr(this_ptr);
28929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28931         this_ptr_conv.is_owned = false;
28932         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
28933         int64_t ret_ref = 0;
28934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28935         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28936         return ret_ref;
28937 }
28938
28939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28940         LDKWatchedOutput this_ptr_conv;
28941         this_ptr_conv.inner = untag_ptr(this_ptr);
28942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28944         this_ptr_conv.is_owned = false;
28945         LDKOutPoint val_conv;
28946         val_conv.inner = untag_ptr(val);
28947         val_conv.is_owned = ptr_is_owned(val);
28948         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28949         val_conv = OutPoint_clone(&val_conv);
28950         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
28951 }
28952
28953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28954         LDKWatchedOutput this_ptr_conv;
28955         this_ptr_conv.inner = untag_ptr(this_ptr);
28956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28958         this_ptr_conv.is_owned = false;
28959         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
28960         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28961         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28962         return ret_arr;
28963 }
28964
28965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28966         LDKWatchedOutput this_ptr_conv;
28967         this_ptr_conv.inner = untag_ptr(this_ptr);
28968         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28970         this_ptr_conv.is_owned = false;
28971         LDKCVec_u8Z val_ref;
28972         val_ref.datalen = (*env)->GetArrayLength(env, val);
28973         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
28974         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
28975         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
28976 }
28977
28978 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) {
28979         LDKThirtyTwoBytes block_hash_arg_ref;
28980         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
28981         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
28982         LDKOutPoint outpoint_arg_conv;
28983         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
28984         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
28985         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28986         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28987         LDKCVec_u8Z script_pubkey_arg_ref;
28988         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
28989         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
28990         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
28991         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
28992         int64_t ret_ref = 0;
28993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28994         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28995         return ret_ref;
28996 }
28997
28998 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
28999         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
29000         int64_t ret_ref = 0;
29001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29002         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29003         return ret_ref;
29004 }
29005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29006         LDKWatchedOutput arg_conv;
29007         arg_conv.inner = untag_ptr(arg);
29008         arg_conv.is_owned = ptr_is_owned(arg);
29009         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29010         arg_conv.is_owned = false;
29011         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
29012         return ret_conv;
29013 }
29014
29015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29016         LDKWatchedOutput orig_conv;
29017         orig_conv.inner = untag_ptr(orig);
29018         orig_conv.is_owned = ptr_is_owned(orig);
29019         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29020         orig_conv.is_owned = false;
29021         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
29022         int64_t ret_ref = 0;
29023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29024         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29025         return ret_ref;
29026 }
29027
29028 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29029         LDKWatchedOutput a_conv;
29030         a_conv.inner = untag_ptr(a);
29031         a_conv.is_owned = ptr_is_owned(a);
29032         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29033         a_conv.is_owned = false;
29034         LDKWatchedOutput b_conv;
29035         b_conv.inner = untag_ptr(b);
29036         b_conv.is_owned = ptr_is_owned(b);
29037         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29038         b_conv.is_owned = false;
29039         jboolean ret_conv = WatchedOutput_eq(&a_conv, &b_conv);
29040         return ret_conv;
29041 }
29042
29043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
29044         LDKWatchedOutput o_conv;
29045         o_conv.inner = untag_ptr(o);
29046         o_conv.is_owned = ptr_is_owned(o);
29047         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29048         o_conv.is_owned = false;
29049         int64_t ret_conv = WatchedOutput_hash(&o_conv);
29050         return ret_conv;
29051 }
29052
29053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29054         if (!ptr_is_owned(this_ptr)) return;
29055         void* this_ptr_ptr = untag_ptr(this_ptr);
29056         CHECK_ACCESS(this_ptr_ptr);
29057         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
29058         FREE(untag_ptr(this_ptr));
29059         BroadcasterInterface_free(this_ptr_conv);
29060 }
29061
29062 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29063         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
29064         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
29065         return ret_conv;
29066 }
29067
29068 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
29069         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
29070         return ret_conv;
29071 }
29072
29073 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
29074         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
29075         return ret_conv;
29076 }
29077
29078 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
29079         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
29080         return ret_conv;
29081 }
29082
29083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1hash(JNIEnv *env, jclass clz, int64_t o) {
29084         LDKConfirmationTarget* o_conv = (LDKConfirmationTarget*)untag_ptr(o);
29085         int64_t ret_conv = ConfirmationTarget_hash(o_conv);
29086         return ret_conv;
29087 }
29088
29089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29090         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
29091         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
29092         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
29093         return ret_conv;
29094 }
29095
29096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29097         if (!ptr_is_owned(this_ptr)) return;
29098         void* this_ptr_ptr = untag_ptr(this_ptr);
29099         CHECK_ACCESS(this_ptr_ptr);
29100         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
29101         FREE(untag_ptr(this_ptr));
29102         FeeEstimator_free(this_ptr_conv);
29103 }
29104
29105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29106         LDKMonitorUpdateId this_obj_conv;
29107         this_obj_conv.inner = untag_ptr(this_obj);
29108         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29110         MonitorUpdateId_free(this_obj_conv);
29111 }
29112
29113 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
29114         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
29115         int64_t ret_ref = 0;
29116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29117         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29118         return ret_ref;
29119 }
29120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29121         LDKMonitorUpdateId arg_conv;
29122         arg_conv.inner = untag_ptr(arg);
29123         arg_conv.is_owned = ptr_is_owned(arg);
29124         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29125         arg_conv.is_owned = false;
29126         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
29127         return ret_conv;
29128 }
29129
29130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29131         LDKMonitorUpdateId orig_conv;
29132         orig_conv.inner = untag_ptr(orig);
29133         orig_conv.is_owned = ptr_is_owned(orig);
29134         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29135         orig_conv.is_owned = false;
29136         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
29137         int64_t ret_ref = 0;
29138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29139         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29140         return ret_ref;
29141 }
29142
29143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
29144         LDKMonitorUpdateId o_conv;
29145         o_conv.inner = untag_ptr(o);
29146         o_conv.is_owned = ptr_is_owned(o);
29147         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29148         o_conv.is_owned = false;
29149         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
29150         return ret_conv;
29151 }
29152
29153 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29154         LDKMonitorUpdateId a_conv;
29155         a_conv.inner = untag_ptr(a);
29156         a_conv.is_owned = ptr_is_owned(a);
29157         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29158         a_conv.is_owned = false;
29159         LDKMonitorUpdateId b_conv;
29160         b_conv.inner = untag_ptr(b);
29161         b_conv.is_owned = ptr_is_owned(b);
29162         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29163         b_conv.is_owned = false;
29164         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
29165         return ret_conv;
29166 }
29167
29168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29169         if (!ptr_is_owned(this_ptr)) return;
29170         void* this_ptr_ptr = untag_ptr(this_ptr);
29171         CHECK_ACCESS(this_ptr_ptr);
29172         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
29173         FREE(untag_ptr(this_ptr));
29174         Persist_free(this_ptr_conv);
29175 }
29176
29177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29178         LDKLockedChannelMonitor this_obj_conv;
29179         this_obj_conv.inner = untag_ptr(this_obj);
29180         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29182         LockedChannelMonitor_free(this_obj_conv);
29183 }
29184
29185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29186         LDKChainMonitor this_obj_conv;
29187         this_obj_conv.inner = untag_ptr(this_obj);
29188         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29190         ChainMonitor_free(this_obj_conv);
29191 }
29192
29193 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) {
29194         void* chain_source_ptr = untag_ptr(chain_source);
29195         CHECK_ACCESS(chain_source_ptr);
29196         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
29197         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
29198         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
29199                 // Manually implement clone for Java trait instances
29200                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
29201                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29202                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
29203                 }
29204         }
29205         void* broadcaster_ptr = untag_ptr(broadcaster);
29206         CHECK_ACCESS(broadcaster_ptr);
29207         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29208         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29209                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29210                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29211         }
29212         void* logger_ptr = untag_ptr(logger);
29213         CHECK_ACCESS(logger_ptr);
29214         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29215         if (logger_conv.free == LDKLogger_JCalls_free) {
29216                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29217                 LDKLogger_JCalls_cloned(&logger_conv);
29218         }
29219         void* feeest_ptr = untag_ptr(feeest);
29220         CHECK_ACCESS(feeest_ptr);
29221         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
29222         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
29223                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29224                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
29225         }
29226         void* persister_ptr = untag_ptr(persister);
29227         CHECK_ACCESS(persister_ptr);
29228         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
29229         if (persister_conv.free == LDKPersist_JCalls_free) {
29230                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29231                 LDKPersist_JCalls_cloned(&persister_conv);
29232         }
29233         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
29234         int64_t ret_ref = 0;
29235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29236         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29237         return ret_ref;
29238 }
29239
29240 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) {
29241         LDKChainMonitor this_arg_conv;
29242         this_arg_conv.inner = untag_ptr(this_arg);
29243         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29245         this_arg_conv.is_owned = false;
29246         LDKCVec_ChannelDetailsZ ignored_channels_constr;
29247         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
29248         if (ignored_channels_constr.datalen > 0)
29249                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29250         else
29251                 ignored_channels_constr.data = NULL;
29252         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
29253         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
29254                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
29255                 LDKChannelDetails ignored_channels_conv_16_conv;
29256                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
29257                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
29258                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
29259                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
29260                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
29261         }
29262         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
29263         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
29264         int64_tArray ret_arr = NULL;
29265         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29266         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29267         for (size_t j = 0; j < ret_var.datalen; j++) {
29268                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29269                 *ret_conv_9_copy = ret_var.data[j];
29270                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
29271                 ret_arr_ptr[j] = ret_conv_9_ref;
29272         }
29273         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29274         FREE(ret_var.data);
29275         return ret_arr;
29276 }
29277
29278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
29279         LDKChainMonitor this_arg_conv;
29280         this_arg_conv.inner = untag_ptr(this_arg);
29281         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29283         this_arg_conv.is_owned = false;
29284         LDKOutPoint funding_txo_conv;
29285         funding_txo_conv.inner = untag_ptr(funding_txo);
29286         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29287         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29288         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29289         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
29290         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
29291         return tag_ptr(ret_conv, true);
29292 }
29293
29294 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
29295         LDKChainMonitor this_arg_conv;
29296         this_arg_conv.inner = untag_ptr(this_arg);
29297         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29299         this_arg_conv.is_owned = false;
29300         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
29301         int64_tArray ret_arr = NULL;
29302         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29303         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29304         for (size_t k = 0; k < ret_var.datalen; k++) {
29305                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
29306                 int64_t ret_conv_10_ref = 0;
29307                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
29308                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
29309                 ret_arr_ptr[k] = ret_conv_10_ref;
29310         }
29311         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29312         FREE(ret_var.data);
29313         return ret_arr;
29314 }
29315
29316 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1pending_1monitor_1updates(JNIEnv *env, jclass clz, int64_t this_arg) {
29317         LDKChainMonitor this_arg_conv;
29318         this_arg_conv.inner = untag_ptr(this_arg);
29319         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29321         this_arg_conv.is_owned = false;
29322         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret_var = ChainMonitor_list_pending_monitor_updates(&this_arg_conv);
29323         int64_tArray ret_arr = NULL;
29324         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29325         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29326         for (size_t p = 0; p < ret_var.datalen; p++) {
29327                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv_41_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
29328                 *ret_conv_41_conv = ret_var.data[p];
29329                 ret_arr_ptr[p] = tag_ptr(ret_conv_41_conv, true);
29330         }
29331         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29332         FREE(ret_var.data);
29333         return ret_arr;
29334 }
29335
29336 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) {
29337         LDKChainMonitor this_arg_conv;
29338         this_arg_conv.inner = untag_ptr(this_arg);
29339         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29341         this_arg_conv.is_owned = false;
29342         LDKOutPoint funding_txo_conv;
29343         funding_txo_conv.inner = untag_ptr(funding_txo);
29344         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29345         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29346         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29347         LDKMonitorUpdateId completed_update_id_conv;
29348         completed_update_id_conv.inner = untag_ptr(completed_update_id);
29349         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
29350         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
29351         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
29352         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29353         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
29354         return tag_ptr(ret_conv, true);
29355 }
29356
29357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
29358         LDKChainMonitor this_arg_conv;
29359         this_arg_conv.inner = untag_ptr(this_arg);
29360         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29362         this_arg_conv.is_owned = false;
29363         LDKFuture ret_var = ChainMonitor_get_update_future(&this_arg_conv);
29364         int64_t ret_ref = 0;
29365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29366         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29367         return ret_ref;
29368 }
29369
29370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1rebroadcast_1pending_1claims(JNIEnv *env, jclass clz, int64_t this_arg) {
29371         LDKChainMonitor this_arg_conv;
29372         this_arg_conv.inner = untag_ptr(this_arg);
29373         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29375         this_arg_conv.is_owned = false;
29376         ChainMonitor_rebroadcast_pending_claims(&this_arg_conv);
29377 }
29378
29379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
29380         LDKChainMonitor this_arg_conv;
29381         this_arg_conv.inner = untag_ptr(this_arg);
29382         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29384         this_arg_conv.is_owned = false;
29385         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
29386         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
29387         return tag_ptr(ret_ret, true);
29388 }
29389
29390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
29391         LDKChainMonitor this_arg_conv;
29392         this_arg_conv.inner = untag_ptr(this_arg);
29393         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29395         this_arg_conv.is_owned = false;
29396         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
29397         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
29398         return tag_ptr(ret_ret, true);
29399 }
29400
29401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
29402         LDKChainMonitor this_arg_conv;
29403         this_arg_conv.inner = untag_ptr(this_arg);
29404         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29406         this_arg_conv.is_owned = false;
29407         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
29408         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
29409         return tag_ptr(ret_ret, true);
29410 }
29411
29412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29413         LDKChainMonitor this_arg_conv;
29414         this_arg_conv.inner = untag_ptr(this_arg);
29415         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29417         this_arg_conv.is_owned = false;
29418         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
29419         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
29420         return tag_ptr(ret_ret, true);
29421 }
29422
29423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29424         LDKChannelMonitorUpdate this_obj_conv;
29425         this_obj_conv.inner = untag_ptr(this_obj);
29426         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29428         ChannelMonitorUpdate_free(this_obj_conv);
29429 }
29430
29431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29432         LDKChannelMonitorUpdate this_ptr_conv;
29433         this_ptr_conv.inner = untag_ptr(this_ptr);
29434         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29436         this_ptr_conv.is_owned = false;
29437         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
29438         return ret_conv;
29439 }
29440
29441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29442         LDKChannelMonitorUpdate this_ptr_conv;
29443         this_ptr_conv.inner = untag_ptr(this_ptr);
29444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29446         this_ptr_conv.is_owned = false;
29447         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
29448 }
29449
29450 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
29451         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
29452         int64_t ret_ref = 0;
29453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29454         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29455         return ret_ref;
29456 }
29457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29458         LDKChannelMonitorUpdate arg_conv;
29459         arg_conv.inner = untag_ptr(arg);
29460         arg_conv.is_owned = ptr_is_owned(arg);
29461         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29462         arg_conv.is_owned = false;
29463         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
29464         return ret_conv;
29465 }
29466
29467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29468         LDKChannelMonitorUpdate orig_conv;
29469         orig_conv.inner = untag_ptr(orig);
29470         orig_conv.is_owned = ptr_is_owned(orig);
29471         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29472         orig_conv.is_owned = false;
29473         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
29474         int64_t ret_ref = 0;
29475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29476         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29477         return ret_ref;
29478 }
29479
29480 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29481         LDKChannelMonitorUpdate a_conv;
29482         a_conv.inner = untag_ptr(a);
29483         a_conv.is_owned = ptr_is_owned(a);
29484         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29485         a_conv.is_owned = false;
29486         LDKChannelMonitorUpdate b_conv;
29487         b_conv.inner = untag_ptr(b);
29488         b_conv.is_owned = ptr_is_owned(b);
29489         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29490         b_conv.is_owned = false;
29491         jboolean ret_conv = ChannelMonitorUpdate_eq(&a_conv, &b_conv);
29492         return ret_conv;
29493 }
29494
29495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29496         LDKChannelMonitorUpdate obj_conv;
29497         obj_conv.inner = untag_ptr(obj);
29498         obj_conv.is_owned = ptr_is_owned(obj);
29499         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29500         obj_conv.is_owned = false;
29501         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
29502         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29503         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29504         CVec_u8Z_free(ret_var);
29505         return ret_arr;
29506 }
29507
29508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29509         LDKu8slice ser_ref;
29510         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29511         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29512         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
29513         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
29514         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29515         return tag_ptr(ret_conv, true);
29516 }
29517
29518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29519         if (!ptr_is_owned(this_ptr)) return;
29520         void* this_ptr_ptr = untag_ptr(this_ptr);
29521         CHECK_ACCESS(this_ptr_ptr);
29522         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
29523         FREE(untag_ptr(this_ptr));
29524         MonitorEvent_free(this_ptr_conv);
29525 }
29526
29527 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
29528         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29529         *ret_copy = MonitorEvent_clone(arg);
29530         int64_t ret_ref = tag_ptr(ret_copy, true);
29531         return ret_ref;
29532 }
29533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29534         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
29535         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
29536         return ret_conv;
29537 }
29538
29539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29540         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
29541         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29542         *ret_copy = MonitorEvent_clone(orig_conv);
29543         int64_t ret_ref = tag_ptr(ret_copy, true);
29544         return ret_ref;
29545 }
29546
29547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
29548         LDKHTLCUpdate a_conv;
29549         a_conv.inner = untag_ptr(a);
29550         a_conv.is_owned = ptr_is_owned(a);
29551         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29552         a_conv = HTLCUpdate_clone(&a_conv);
29553         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29554         *ret_copy = MonitorEvent_htlcevent(a_conv);
29555         int64_t ret_ref = tag_ptr(ret_copy, true);
29556         return ret_ref;
29557 }
29558
29559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
29560         LDKOutPoint a_conv;
29561         a_conv.inner = untag_ptr(a);
29562         a_conv.is_owned = ptr_is_owned(a);
29563         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29564         a_conv = OutPoint_clone(&a_conv);
29565         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29566         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
29567         int64_t ret_ref = tag_ptr(ret_copy, true);
29568         return ret_ref;
29569 }
29570
29571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
29572         LDKOutPoint funding_txo_conv;
29573         funding_txo_conv.inner = untag_ptr(funding_txo);
29574         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29575         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29576         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29577         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29578         *ret_copy = MonitorEvent_completed(funding_txo_conv, monitor_update_id);
29579         int64_t ret_ref = tag_ptr(ret_copy, true);
29580         return ret_ref;
29581 }
29582
29583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
29584         LDKOutPoint a_conv;
29585         a_conv.inner = untag_ptr(a);
29586         a_conv.is_owned = ptr_is_owned(a);
29587         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29588         a_conv = OutPoint_clone(&a_conv);
29589         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29590         *ret_copy = MonitorEvent_update_failed(a_conv);
29591         int64_t ret_ref = tag_ptr(ret_copy, true);
29592         return ret_ref;
29593 }
29594
29595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29596         LDKMonitorEvent* a_conv = (LDKMonitorEvent*)untag_ptr(a);
29597         LDKMonitorEvent* b_conv = (LDKMonitorEvent*)untag_ptr(b);
29598         jboolean ret_conv = MonitorEvent_eq(a_conv, b_conv);
29599         return ret_conv;
29600 }
29601
29602 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
29603         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
29604         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
29605         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29606         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29607         CVec_u8Z_free(ret_var);
29608         return ret_arr;
29609 }
29610
29611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29612         LDKu8slice ser_ref;
29613         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29614         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29615         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
29616         *ret_conv = MonitorEvent_read(ser_ref);
29617         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29618         return tag_ptr(ret_conv, true);
29619 }
29620
29621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29622         LDKHTLCUpdate this_obj_conv;
29623         this_obj_conv.inner = untag_ptr(this_obj);
29624         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29626         HTLCUpdate_free(this_obj_conv);
29627 }
29628
29629 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
29630         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
29631         int64_t ret_ref = 0;
29632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29634         return ret_ref;
29635 }
29636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29637         LDKHTLCUpdate arg_conv;
29638         arg_conv.inner = untag_ptr(arg);
29639         arg_conv.is_owned = ptr_is_owned(arg);
29640         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29641         arg_conv.is_owned = false;
29642         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
29643         return ret_conv;
29644 }
29645
29646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29647         LDKHTLCUpdate orig_conv;
29648         orig_conv.inner = untag_ptr(orig);
29649         orig_conv.is_owned = ptr_is_owned(orig);
29650         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29651         orig_conv.is_owned = false;
29652         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
29653         int64_t ret_ref = 0;
29654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29656         return ret_ref;
29657 }
29658
29659 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29660         LDKHTLCUpdate a_conv;
29661         a_conv.inner = untag_ptr(a);
29662         a_conv.is_owned = ptr_is_owned(a);
29663         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29664         a_conv.is_owned = false;
29665         LDKHTLCUpdate b_conv;
29666         b_conv.inner = untag_ptr(b);
29667         b_conv.is_owned = ptr_is_owned(b);
29668         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29669         b_conv.is_owned = false;
29670         jboolean ret_conv = HTLCUpdate_eq(&a_conv, &b_conv);
29671         return ret_conv;
29672 }
29673
29674 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29675         LDKHTLCUpdate obj_conv;
29676         obj_conv.inner = untag_ptr(obj);
29677         obj_conv.is_owned = ptr_is_owned(obj);
29678         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29679         obj_conv.is_owned = false;
29680         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
29681         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29682         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29683         CVec_u8Z_free(ret_var);
29684         return ret_arr;
29685 }
29686
29687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29688         LDKu8slice ser_ref;
29689         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29690         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29691         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
29692         *ret_conv = HTLCUpdate_read(ser_ref);
29693         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29694         return tag_ptr(ret_conv, true);
29695 }
29696
29697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29698         if (!ptr_is_owned(this_ptr)) return;
29699         void* this_ptr_ptr = untag_ptr(this_ptr);
29700         CHECK_ACCESS(this_ptr_ptr);
29701         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
29702         FREE(untag_ptr(this_ptr));
29703         Balance_free(this_ptr_conv);
29704 }
29705
29706 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
29707         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29708         *ret_copy = Balance_clone(arg);
29709         int64_t ret_ref = tag_ptr(ret_copy, true);
29710         return ret_ref;
29711 }
29712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29713         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
29714         int64_t ret_conv = Balance_clone_ptr(arg_conv);
29715         return ret_conv;
29716 }
29717
29718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29719         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
29720         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29721         *ret_copy = Balance_clone(orig_conv);
29722         int64_t ret_ref = tag_ptr(ret_copy, true);
29723         return ret_ref;
29724 }
29725
29726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29727         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29728         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
29729         int64_t ret_ref = tag_ptr(ret_copy, true);
29730         return ret_ref;
29731 }
29732
29733 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) {
29734         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29735         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
29736         int64_t ret_ref = tag_ptr(ret_copy, true);
29737         return ret_ref;
29738 }
29739
29740 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) {
29741         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29742         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
29743         int64_t ret_ref = tag_ptr(ret_copy, true);
29744         return ret_ref;
29745 }
29746
29747 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) {
29748         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29749         *ret_copy = Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis, claimable_height);
29750         int64_t ret_ref = tag_ptr(ret_copy, true);
29751         return ret_ref;
29752 }
29753
29754 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) {
29755         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29756         *ret_copy = Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis, expiry_height);
29757         int64_t ret_ref = tag_ptr(ret_copy, true);
29758         return ret_ref;
29759 }
29760
29761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1counterparty_1revoked_1output_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29762         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29763         *ret_copy = Balance_counterparty_revoked_output_claimable(claimable_amount_satoshis);
29764         int64_t ret_ref = tag_ptr(ret_copy, true);
29765         return ret_ref;
29766 }
29767
29768 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29769         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
29770         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
29771         jboolean ret_conv = Balance_eq(a_conv, b_conv);
29772         return ret_conv;
29773 }
29774
29775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29776         LDKChannelMonitor this_obj_conv;
29777         this_obj_conv.inner = untag_ptr(this_obj);
29778         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29780         ChannelMonitor_free(this_obj_conv);
29781 }
29782
29783 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
29784         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
29785         int64_t ret_ref = 0;
29786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29787         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29788         return ret_ref;
29789 }
29790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29791         LDKChannelMonitor arg_conv;
29792         arg_conv.inner = untag_ptr(arg);
29793         arg_conv.is_owned = ptr_is_owned(arg);
29794         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29795         arg_conv.is_owned = false;
29796         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
29797         return ret_conv;
29798 }
29799
29800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29801         LDKChannelMonitor orig_conv;
29802         orig_conv.inner = untag_ptr(orig);
29803         orig_conv.is_owned = ptr_is_owned(orig);
29804         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29805         orig_conv.is_owned = false;
29806         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
29807         int64_t ret_ref = 0;
29808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29809         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29810         return ret_ref;
29811 }
29812
29813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29814         LDKChannelMonitor obj_conv;
29815         obj_conv.inner = untag_ptr(obj);
29816         obj_conv.is_owned = ptr_is_owned(obj);
29817         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29818         obj_conv.is_owned = false;
29819         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
29820         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29821         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29822         CVec_u8Z_free(ret_var);
29823         return ret_arr;
29824 }
29825
29826 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) {
29827         LDKChannelMonitor this_arg_conv;
29828         this_arg_conv.inner = untag_ptr(this_arg);
29829         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29831         this_arg_conv.is_owned = false;
29832         LDKChannelMonitorUpdate updates_conv;
29833         updates_conv.inner = untag_ptr(updates);
29834         updates_conv.is_owned = ptr_is_owned(updates);
29835         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
29836         updates_conv.is_owned = false;
29837         void* broadcaster_ptr = untag_ptr(broadcaster);
29838         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
29839         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
29840         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29841         CHECK_ACCESS(fee_estimator_ptr);
29842         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29843         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29844                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29845                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29846         }
29847         void* logger_ptr = untag_ptr(logger);
29848         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29849         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29850         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
29851         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
29852         return tag_ptr(ret_conv, true);
29853 }
29854
29855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29856         LDKChannelMonitor this_arg_conv;
29857         this_arg_conv.inner = untag_ptr(this_arg);
29858         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29860         this_arg_conv.is_owned = false;
29861         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
29862         return ret_conv;
29863 }
29864
29865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
29866         LDKChannelMonitor this_arg_conv;
29867         this_arg_conv.inner = untag_ptr(this_arg);
29868         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29870         this_arg_conv.is_owned = false;
29871         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
29872         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
29873         return tag_ptr(ret_conv, true);
29874 }
29875
29876 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(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         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
29883         int64_tArray ret_arr = NULL;
29884         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29885         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29886         for (size_t o = 0; o < ret_var.datalen; o++) {
29887                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
29888                 *ret_conv_40_conv = ret_var.data[o];
29889                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
29890         }
29891         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29892         FREE(ret_var.data);
29893         return ret_arr;
29894 }
29895
29896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
29897         LDKChannelMonitor this_arg_conv;
29898         this_arg_conv.inner = untag_ptr(this_arg);
29899         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29901         this_arg_conv.is_owned = false;
29902         void* filter_ptr = untag_ptr(filter);
29903         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
29904         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
29905         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
29906 }
29907
29908 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
29909         LDKChannelMonitor this_arg_conv;
29910         this_arg_conv.inner = untag_ptr(this_arg);
29911         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29913         this_arg_conv.is_owned = false;
29914         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
29915         int64_tArray ret_arr = NULL;
29916         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29917         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29918         for (size_t o = 0; o < ret_var.datalen; o++) {
29919                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29920                 *ret_conv_14_copy = ret_var.data[o];
29921                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
29922                 ret_arr_ptr[o] = ret_conv_14_ref;
29923         }
29924         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29925         FREE(ret_var.data);
29926         return ret_arr;
29927 }
29928
29929 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
29930         LDKChannelMonitor this_arg_conv;
29931         this_arg_conv.inner = untag_ptr(this_arg);
29932         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29934         this_arg_conv.is_owned = false;
29935         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
29936         int64_tArray ret_arr = NULL;
29937         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29938         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29939         for (size_t h = 0; h < ret_var.datalen; h++) {
29940                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
29941                 *ret_conv_7_copy = ret_var.data[h];
29942                 int64_t ret_conv_7_ref = tag_ptr(ret_conv_7_copy, true);
29943                 ret_arr_ptr[h] = ret_conv_7_ref;
29944         }
29945         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29946         FREE(ret_var.data);
29947         return ret_arr;
29948 }
29949
29950 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29951         LDKChannelMonitor this_arg_conv;
29952         this_arg_conv.inner = untag_ptr(this_arg);
29953         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29955         this_arg_conv.is_owned = false;
29956         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
29958         return ret_arr;
29959 }
29960
29961 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) {
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         void* logger_ptr = untag_ptr(logger);
29968         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29969         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29970         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
29971         jobjectArray ret_arr = NULL;
29972         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
29973         ;
29974         for (size_t i = 0; i < ret_var.datalen; i++) {
29975                 LDKTransaction ret_conv_8_var = ret_var.data[i];
29976                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
29977                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
29978                 Transaction_free(ret_conv_8_var);
29979                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
29980         }
29981         
29982         FREE(ret_var.data);
29983         return ret_arr;
29984 }
29985
29986 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) {
29987         LDKChannelMonitor this_arg_conv;
29988         this_arg_conv.inner = untag_ptr(this_arg);
29989         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29991         this_arg_conv.is_owned = false;
29992         uint8_t header_arr[80];
29993         CHECK((*env)->GetArrayLength(env, header) == 80);
29994         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
29995         uint8_t (*header_ref)[80] = &header_arr;
29996         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
29997         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
29998         if (txdata_constr.datalen > 0)
29999                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
30000         else
30001                 txdata_constr.data = NULL;
30002         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
30003         for (size_t c = 0; c < txdata_constr.datalen; c++) {
30004                 int64_t txdata_conv_28 = txdata_vals[c];
30005                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
30006                 CHECK_ACCESS(txdata_conv_28_ptr);
30007                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
30008                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
30009                 txdata_constr.data[c] = txdata_conv_28_conv;
30010         }
30011         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
30012         void* broadcaster_ptr = untag_ptr(broadcaster);
30013         CHECK_ACCESS(broadcaster_ptr);
30014         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30015         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30016                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30017                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30018         }
30019         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30020         CHECK_ACCESS(fee_estimator_ptr);
30021         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30022         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30023                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30024                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30025         }
30026         void* logger_ptr = untag_ptr(logger);
30027         CHECK_ACCESS(logger_ptr);
30028         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30029         if (logger_conv.free == LDKLogger_JCalls_free) {
30030                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30031                 LDKLogger_JCalls_cloned(&logger_conv);
30032         }
30033         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);
30034         int64_tArray ret_arr = NULL;
30035         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30036         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30037         for (size_t n = 0; n < ret_var.datalen; n++) {
30038                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30039                 *ret_conv_39_conv = ret_var.data[n];
30040                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30041         }
30042         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30043         FREE(ret_var.data);
30044         return ret_arr;
30045 }
30046
30047 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) {
30048         LDKChannelMonitor this_arg_conv;
30049         this_arg_conv.inner = untag_ptr(this_arg);
30050         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30052         this_arg_conv.is_owned = false;
30053         uint8_t header_arr[80];
30054         CHECK((*env)->GetArrayLength(env, header) == 80);
30055         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30056         uint8_t (*header_ref)[80] = &header_arr;
30057         void* broadcaster_ptr = untag_ptr(broadcaster);
30058         CHECK_ACCESS(broadcaster_ptr);
30059         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30060         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30061                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30062                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30063         }
30064         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30065         CHECK_ACCESS(fee_estimator_ptr);
30066         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30067         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30068                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30069                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30070         }
30071         void* logger_ptr = untag_ptr(logger);
30072         CHECK_ACCESS(logger_ptr);
30073         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30074         if (logger_conv.free == LDKLogger_JCalls_free) {
30075                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30076                 LDKLogger_JCalls_cloned(&logger_conv);
30077         }
30078         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
30079 }
30080
30081 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) {
30082         LDKChannelMonitor this_arg_conv;
30083         this_arg_conv.inner = untag_ptr(this_arg);
30084         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30086         this_arg_conv.is_owned = false;
30087         uint8_t header_arr[80];
30088         CHECK((*env)->GetArrayLength(env, header) == 80);
30089         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30090         uint8_t (*header_ref)[80] = &header_arr;
30091         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
30092         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
30093         if (txdata_constr.datalen > 0)
30094                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
30095         else
30096                 txdata_constr.data = NULL;
30097         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
30098         for (size_t c = 0; c < txdata_constr.datalen; c++) {
30099                 int64_t txdata_conv_28 = txdata_vals[c];
30100                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
30101                 CHECK_ACCESS(txdata_conv_28_ptr);
30102                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
30103                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
30104                 txdata_constr.data[c] = txdata_conv_28_conv;
30105         }
30106         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
30107         void* broadcaster_ptr = untag_ptr(broadcaster);
30108         CHECK_ACCESS(broadcaster_ptr);
30109         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30110         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30111                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30112                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30113         }
30114         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30115         CHECK_ACCESS(fee_estimator_ptr);
30116         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30117         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30118                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30119                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30120         }
30121         void* logger_ptr = untag_ptr(logger);
30122         CHECK_ACCESS(logger_ptr);
30123         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30124         if (logger_conv.free == LDKLogger_JCalls_free) {
30125                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30126                 LDKLogger_JCalls_cloned(&logger_conv);
30127         }
30128         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);
30129         int64_tArray ret_arr = NULL;
30130         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30131         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30132         for (size_t n = 0; n < ret_var.datalen; n++) {
30133                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30134                 *ret_conv_39_conv = ret_var.data[n];
30135                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30136         }
30137         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30138         FREE(ret_var.data);
30139         return ret_arr;
30140 }
30141
30142 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) {
30143         LDKChannelMonitor this_arg_conv;
30144         this_arg_conv.inner = untag_ptr(this_arg);
30145         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30147         this_arg_conv.is_owned = false;
30148         uint8_t txid_arr[32];
30149         CHECK((*env)->GetArrayLength(env, txid) == 32);
30150         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
30151         uint8_t (*txid_ref)[32] = &txid_arr;
30152         void* broadcaster_ptr = untag_ptr(broadcaster);
30153         CHECK_ACCESS(broadcaster_ptr);
30154         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30155         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30156                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30157                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30158         }
30159         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30160         CHECK_ACCESS(fee_estimator_ptr);
30161         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30162         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30163                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30164                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30165         }
30166         void* logger_ptr = untag_ptr(logger);
30167         CHECK_ACCESS(logger_ptr);
30168         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30169         if (logger_conv.free == LDKLogger_JCalls_free) {
30170                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30171                 LDKLogger_JCalls_cloned(&logger_conv);
30172         }
30173         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
30174 }
30175
30176 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) {
30177         LDKChannelMonitor this_arg_conv;
30178         this_arg_conv.inner = untag_ptr(this_arg);
30179         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30181         this_arg_conv.is_owned = false;
30182         uint8_t header_arr[80];
30183         CHECK((*env)->GetArrayLength(env, header) == 80);
30184         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30185         uint8_t (*header_ref)[80] = &header_arr;
30186         void* broadcaster_ptr = untag_ptr(broadcaster);
30187         CHECK_ACCESS(broadcaster_ptr);
30188         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30189         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30190                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30191                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30192         }
30193         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30194         CHECK_ACCESS(fee_estimator_ptr);
30195         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30196         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30197                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30198                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30199         }
30200         void* logger_ptr = untag_ptr(logger);
30201         CHECK_ACCESS(logger_ptr);
30202         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30203         if (logger_conv.free == LDKLogger_JCalls_free) {
30204                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30205                 LDKLogger_JCalls_cloned(&logger_conv);
30206         }
30207         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
30208         int64_tArray ret_arr = NULL;
30209         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30210         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30211         for (size_t n = 0; n < ret_var.datalen; n++) {
30212                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30213                 *ret_conv_39_conv = ret_var.data[n];
30214                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30215         }
30216         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30217         FREE(ret_var.data);
30218         return ret_arr;
30219 }
30220
30221 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
30222         LDKChannelMonitor this_arg_conv;
30223         this_arg_conv.inner = untag_ptr(this_arg);
30224         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30226         this_arg_conv.is_owned = false;
30227         LDKCVec_C2Tuple_TxidBlockHashZZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
30228         int64_tArray ret_arr = NULL;
30229         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30230         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30231         for (size_t z = 0; z < ret_var.datalen; z++) {
30232                 LDKC2Tuple_TxidBlockHashZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
30233                 *ret_conv_25_conv = ret_var.data[z];
30234                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
30235         }
30236         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30237         FREE(ret_var.data);
30238         return ret_arr;
30239 }
30240
30241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
30242         LDKChannelMonitor this_arg_conv;
30243         this_arg_conv.inner = untag_ptr(this_arg);
30244         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30246         this_arg_conv.is_owned = false;
30247         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
30248         int64_t ret_ref = 0;
30249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30251         return ret_ref;
30252 }
30253
30254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1rebroadcast_1pending_1claims(JNIEnv *env, jclass clz, int64_t this_arg, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
30255         LDKChannelMonitor this_arg_conv;
30256         this_arg_conv.inner = untag_ptr(this_arg);
30257         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30259         this_arg_conv.is_owned = false;
30260         void* broadcaster_ptr = untag_ptr(broadcaster);
30261         CHECK_ACCESS(broadcaster_ptr);
30262         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30263         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30264                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30265                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30266         }
30267         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30268         CHECK_ACCESS(fee_estimator_ptr);
30269         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30270         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30271                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30272                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30273         }
30274         void* logger_ptr = untag_ptr(logger);
30275         CHECK_ACCESS(logger_ptr);
30276         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30277         if (logger_conv.free == LDKLogger_JCalls_free) {
30278                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30279                 LDKLogger_JCalls_cloned(&logger_conv);
30280         }
30281         ChannelMonitor_rebroadcast_pending_claims(&this_arg_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
30282 }
30283
30284 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
30285         LDKChannelMonitor this_arg_conv;
30286         this_arg_conv.inner = untag_ptr(this_arg);
30287         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30289         this_arg_conv.is_owned = false;
30290         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
30291         int64_tArray ret_arr = NULL;
30292         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30293         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30294         for (size_t j = 0; j < ret_var.datalen; j++) {
30295                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
30296                 *ret_conv_9_copy = ret_var.data[j];
30297                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
30298                 ret_arr_ptr[j] = ret_conv_9_ref;
30299         }
30300         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30301         FREE(ret_var.data);
30302         return ret_arr;
30303 }
30304
30305 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) {
30306         LDKu8slice ser_ref;
30307         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30308         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30309         void* arg_a_ptr = untag_ptr(arg_a);
30310         if (ptr_is_owned(arg_a)) { CHECK_ACCESS(arg_a_ptr); }
30311         LDKEntropySource* arg_a_conv = (LDKEntropySource*)arg_a_ptr;
30312         void* arg_b_ptr = untag_ptr(arg_b);
30313         if (ptr_is_owned(arg_b)) { CHECK_ACCESS(arg_b_ptr); }
30314         LDKSignerProvider* arg_b_conv = (LDKSignerProvider*)arg_b_ptr;
30315         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
30316         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_a_conv, arg_b_conv);
30317         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30318         return tag_ptr(ret_conv, true);
30319 }
30320
30321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30322         LDKOutPoint this_obj_conv;
30323         this_obj_conv.inner = untag_ptr(this_obj);
30324         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30326         OutPoint_free(this_obj_conv);
30327 }
30328
30329 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
30330         LDKOutPoint this_ptr_conv;
30331         this_ptr_conv.inner = untag_ptr(this_ptr);
30332         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30334         this_ptr_conv.is_owned = false;
30335         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30336         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
30337         return ret_arr;
30338 }
30339
30340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30341         LDKOutPoint this_ptr_conv;
30342         this_ptr_conv.inner = untag_ptr(this_ptr);
30343         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30345         this_ptr_conv.is_owned = false;
30346         LDKThirtyTwoBytes val_ref;
30347         CHECK((*env)->GetArrayLength(env, val) == 32);
30348         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30349         OutPoint_set_txid(&this_ptr_conv, val_ref);
30350 }
30351
30352 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
30353         LDKOutPoint this_ptr_conv;
30354         this_ptr_conv.inner = untag_ptr(this_ptr);
30355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30357         this_ptr_conv.is_owned = false;
30358         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
30359         return ret_conv;
30360 }
30361
30362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30363         LDKOutPoint this_ptr_conv;
30364         this_ptr_conv.inner = untag_ptr(this_ptr);
30365         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30367         this_ptr_conv.is_owned = false;
30368         OutPoint_set_index(&this_ptr_conv, val);
30369 }
30370
30371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
30372         LDKThirtyTwoBytes txid_arg_ref;
30373         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
30374         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
30375         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
30376         int64_t ret_ref = 0;
30377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30378         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30379         return ret_ref;
30380 }
30381
30382 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
30383         LDKOutPoint ret_var = OutPoint_clone(arg);
30384         int64_t ret_ref = 0;
30385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30386         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30387         return ret_ref;
30388 }
30389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30390         LDKOutPoint arg_conv;
30391         arg_conv.inner = untag_ptr(arg);
30392         arg_conv.is_owned = ptr_is_owned(arg);
30393         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30394         arg_conv.is_owned = false;
30395         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
30396         return ret_conv;
30397 }
30398
30399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30400         LDKOutPoint orig_conv;
30401         orig_conv.inner = untag_ptr(orig);
30402         orig_conv.is_owned = ptr_is_owned(orig);
30403         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30404         orig_conv.is_owned = false;
30405         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
30406         int64_t ret_ref = 0;
30407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30408         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30409         return ret_ref;
30410 }
30411
30412 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30413         LDKOutPoint a_conv;
30414         a_conv.inner = untag_ptr(a);
30415         a_conv.is_owned = ptr_is_owned(a);
30416         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30417         a_conv.is_owned = false;
30418         LDKOutPoint b_conv;
30419         b_conv.inner = untag_ptr(b);
30420         b_conv.is_owned = ptr_is_owned(b);
30421         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30422         b_conv.is_owned = false;
30423         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
30424         return ret_conv;
30425 }
30426
30427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
30428         LDKOutPoint o_conv;
30429         o_conv.inner = untag_ptr(o);
30430         o_conv.is_owned = ptr_is_owned(o);
30431         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
30432         o_conv.is_owned = false;
30433         int64_t ret_conv = OutPoint_hash(&o_conv);
30434         return ret_conv;
30435 }
30436
30437 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
30438         LDKOutPoint this_arg_conv;
30439         this_arg_conv.inner = untag_ptr(this_arg);
30440         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30442         this_arg_conv.is_owned = false;
30443         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30444         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
30445         return ret_arr;
30446 }
30447
30448 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
30449         LDKOutPoint obj_conv;
30450         obj_conv.inner = untag_ptr(obj);
30451         obj_conv.is_owned = ptr_is_owned(obj);
30452         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30453         obj_conv.is_owned = false;
30454         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
30455         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30456         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30457         CVec_u8Z_free(ret_var);
30458         return ret_arr;
30459 }
30460
30461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30462         LDKu8slice ser_ref;
30463         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30464         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30465         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
30466         *ret_conv = OutPoint_read(ser_ref);
30467         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30468         return tag_ptr(ret_conv, true);
30469 }
30470
30471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30472         LDKDelayedPaymentOutputDescriptor this_obj_conv;
30473         this_obj_conv.inner = untag_ptr(this_obj);
30474         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30476         DelayedPaymentOutputDescriptor_free(this_obj_conv);
30477 }
30478
30479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30480         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30481         this_ptr_conv.inner = untag_ptr(this_ptr);
30482         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30484         this_ptr_conv.is_owned = false;
30485         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30486         int64_t ret_ref = 0;
30487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30488         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30489         return ret_ref;
30490 }
30491
30492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30493         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30494         this_ptr_conv.inner = untag_ptr(this_ptr);
30495         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30497         this_ptr_conv.is_owned = false;
30498         LDKOutPoint val_conv;
30499         val_conv.inner = untag_ptr(val);
30500         val_conv.is_owned = ptr_is_owned(val);
30501         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30502         val_conv = OutPoint_clone(&val_conv);
30503         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30504 }
30505
30506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30507         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30508         this_ptr_conv.inner = untag_ptr(this_ptr);
30509         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30511         this_ptr_conv.is_owned = false;
30512         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30513         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
30514         return ret_arr;
30515 }
30516
30517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30518         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30519         this_ptr_conv.inner = untag_ptr(this_ptr);
30520         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30522         this_ptr_conv.is_owned = false;
30523         LDKPublicKey val_ref;
30524         CHECK((*env)->GetArrayLength(env, val) == 33);
30525         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30526         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
30527 }
30528
30529 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(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         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
30536         return ret_conv;
30537 }
30538
30539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30540         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30541         this_ptr_conv.inner = untag_ptr(this_ptr);
30542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30544         this_ptr_conv.is_owned = false;
30545         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
30546 }
30547
30548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30549         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30550         this_ptr_conv.inner = untag_ptr(this_ptr);
30551         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30553         this_ptr_conv.is_owned = false;
30554         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30555         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
30556         return tag_ptr(ret_ref, true);
30557 }
30558
30559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30560         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30561         this_ptr_conv.inner = untag_ptr(this_ptr);
30562         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30564         this_ptr_conv.is_owned = false;
30565         void* val_ptr = untag_ptr(val);
30566         CHECK_ACCESS(val_ptr);
30567         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30568         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30569         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30570 }
30571
30572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30573         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30574         this_ptr_conv.inner = untag_ptr(this_ptr);
30575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30577         this_ptr_conv.is_owned = false;
30578         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30579         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
30580         return ret_arr;
30581 }
30582
30583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30584         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30585         this_ptr_conv.inner = untag_ptr(this_ptr);
30586         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30588         this_ptr_conv.is_owned = false;
30589         LDKPublicKey val_ref;
30590         CHECK((*env)->GetArrayLength(env, val) == 33);
30591         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30592         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
30593 }
30594
30595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30596         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30597         this_ptr_conv.inner = untag_ptr(this_ptr);
30598         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30600         this_ptr_conv.is_owned = false;
30601         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30602         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30603         return ret_arr;
30604 }
30605
30606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30607         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30608         this_ptr_conv.inner = untag_ptr(this_ptr);
30609         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30611         this_ptr_conv.is_owned = false;
30612         LDKThirtyTwoBytes val_ref;
30613         CHECK((*env)->GetArrayLength(env, val) == 32);
30614         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30615         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30616 }
30617
30618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30619         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30620         this_ptr_conv.inner = untag_ptr(this_ptr);
30621         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30623         this_ptr_conv.is_owned = false;
30624         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30625         return ret_conv;
30626 }
30627
30628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30629         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30630         this_ptr_conv.inner = untag_ptr(this_ptr);
30631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30633         this_ptr_conv.is_owned = false;
30634         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30635 }
30636
30637 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) {
30638         LDKOutPoint outpoint_arg_conv;
30639         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30640         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30641         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30642         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30643         LDKPublicKey per_commitment_point_arg_ref;
30644         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
30645         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
30646         void* output_arg_ptr = untag_ptr(output_arg);
30647         CHECK_ACCESS(output_arg_ptr);
30648         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30649         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30650         LDKPublicKey revocation_pubkey_arg_ref;
30651         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
30652         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
30653         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30654         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30655         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30656         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);
30657         int64_t ret_ref = 0;
30658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30659         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30660         return ret_ref;
30661 }
30662
30663 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
30664         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
30665         int64_t ret_ref = 0;
30666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30667         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30668         return ret_ref;
30669 }
30670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30671         LDKDelayedPaymentOutputDescriptor arg_conv;
30672         arg_conv.inner = untag_ptr(arg);
30673         arg_conv.is_owned = ptr_is_owned(arg);
30674         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30675         arg_conv.is_owned = false;
30676         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
30677         return ret_conv;
30678 }
30679
30680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30681         LDKDelayedPaymentOutputDescriptor orig_conv;
30682         orig_conv.inner = untag_ptr(orig);
30683         orig_conv.is_owned = ptr_is_owned(orig);
30684         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30685         orig_conv.is_owned = false;
30686         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
30687         int64_t ret_ref = 0;
30688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30690         return ret_ref;
30691 }
30692
30693 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30694         LDKDelayedPaymentOutputDescriptor a_conv;
30695         a_conv.inner = untag_ptr(a);
30696         a_conv.is_owned = ptr_is_owned(a);
30697         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30698         a_conv.is_owned = false;
30699         LDKDelayedPaymentOutputDescriptor b_conv;
30700         b_conv.inner = untag_ptr(b);
30701         b_conv.is_owned = ptr_is_owned(b);
30702         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30703         b_conv.is_owned = false;
30704         jboolean ret_conv = DelayedPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30705         return ret_conv;
30706 }
30707
30708 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30709         LDKDelayedPaymentOutputDescriptor obj_conv;
30710         obj_conv.inner = untag_ptr(obj);
30711         obj_conv.is_owned = ptr_is_owned(obj);
30712         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30713         obj_conv.is_owned = false;
30714         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
30715         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30716         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30717         CVec_u8Z_free(ret_var);
30718         return ret_arr;
30719 }
30720
30721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30722         LDKu8slice ser_ref;
30723         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30724         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30725         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
30726         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
30727         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30728         return tag_ptr(ret_conv, true);
30729 }
30730
30731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30732         LDKStaticPaymentOutputDescriptor this_obj_conv;
30733         this_obj_conv.inner = untag_ptr(this_obj);
30734         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30736         StaticPaymentOutputDescriptor_free(this_obj_conv);
30737 }
30738
30739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30740         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30741         this_ptr_conv.inner = untag_ptr(this_ptr);
30742         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30744         this_ptr_conv.is_owned = false;
30745         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30746         int64_t ret_ref = 0;
30747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30748         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30749         return ret_ref;
30750 }
30751
30752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30753         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30754         this_ptr_conv.inner = untag_ptr(this_ptr);
30755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30757         this_ptr_conv.is_owned = false;
30758         LDKOutPoint val_conv;
30759         val_conv.inner = untag_ptr(val);
30760         val_conv.is_owned = ptr_is_owned(val);
30761         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30762         val_conv = OutPoint_clone(&val_conv);
30763         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30764 }
30765
30766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30767         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30768         this_ptr_conv.inner = untag_ptr(this_ptr);
30769         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30771         this_ptr_conv.is_owned = false;
30772         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30773         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
30774         return tag_ptr(ret_ref, true);
30775 }
30776
30777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30778         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30779         this_ptr_conv.inner = untag_ptr(this_ptr);
30780         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30782         this_ptr_conv.is_owned = false;
30783         void* val_ptr = untag_ptr(val);
30784         CHECK_ACCESS(val_ptr);
30785         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30786         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30787         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30788 }
30789
30790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30791         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30792         this_ptr_conv.inner = untag_ptr(this_ptr);
30793         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30795         this_ptr_conv.is_owned = false;
30796         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30797         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30798         return ret_arr;
30799 }
30800
30801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30802         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30803         this_ptr_conv.inner = untag_ptr(this_ptr);
30804         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30806         this_ptr_conv.is_owned = false;
30807         LDKThirtyTwoBytes val_ref;
30808         CHECK((*env)->GetArrayLength(env, val) == 32);
30809         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30810         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30811 }
30812
30813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30814         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30815         this_ptr_conv.inner = untag_ptr(this_ptr);
30816         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30818         this_ptr_conv.is_owned = false;
30819         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30820         return ret_conv;
30821 }
30822
30823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30824         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30825         this_ptr_conv.inner = untag_ptr(this_ptr);
30826         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30828         this_ptr_conv.is_owned = false;
30829         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30830 }
30831
30832 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) {
30833         LDKOutPoint outpoint_arg_conv;
30834         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30835         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30836         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30837         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30838         void* output_arg_ptr = untag_ptr(output_arg);
30839         CHECK_ACCESS(output_arg_ptr);
30840         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30841         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30842         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30843         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30844         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30845         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
30846         int64_t ret_ref = 0;
30847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30848         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30849         return ret_ref;
30850 }
30851
30852 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
30853         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
30854         int64_t ret_ref = 0;
30855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30856         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30857         return ret_ref;
30858 }
30859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30860         LDKStaticPaymentOutputDescriptor arg_conv;
30861         arg_conv.inner = untag_ptr(arg);
30862         arg_conv.is_owned = ptr_is_owned(arg);
30863         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30864         arg_conv.is_owned = false;
30865         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
30866         return ret_conv;
30867 }
30868
30869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30870         LDKStaticPaymentOutputDescriptor orig_conv;
30871         orig_conv.inner = untag_ptr(orig);
30872         orig_conv.is_owned = ptr_is_owned(orig);
30873         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30874         orig_conv.is_owned = false;
30875         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
30876         int64_t ret_ref = 0;
30877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30878         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30879         return ret_ref;
30880 }
30881
30882 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30883         LDKStaticPaymentOutputDescriptor a_conv;
30884         a_conv.inner = untag_ptr(a);
30885         a_conv.is_owned = ptr_is_owned(a);
30886         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30887         a_conv.is_owned = false;
30888         LDKStaticPaymentOutputDescriptor b_conv;
30889         b_conv.inner = untag_ptr(b);
30890         b_conv.is_owned = ptr_is_owned(b);
30891         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30892         b_conv.is_owned = false;
30893         jboolean ret_conv = StaticPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30894         return ret_conv;
30895 }
30896
30897 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30898         LDKStaticPaymentOutputDescriptor obj_conv;
30899         obj_conv.inner = untag_ptr(obj);
30900         obj_conv.is_owned = ptr_is_owned(obj);
30901         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30902         obj_conv.is_owned = false;
30903         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
30904         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30905         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30906         CVec_u8Z_free(ret_var);
30907         return ret_arr;
30908 }
30909
30910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30911         LDKu8slice ser_ref;
30912         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30913         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30914         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
30915         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
30916         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30917         return tag_ptr(ret_conv, true);
30918 }
30919
30920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30921         if (!ptr_is_owned(this_ptr)) return;
30922         void* this_ptr_ptr = untag_ptr(this_ptr);
30923         CHECK_ACCESS(this_ptr_ptr);
30924         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
30925         FREE(untag_ptr(this_ptr));
30926         SpendableOutputDescriptor_free(this_ptr_conv);
30927 }
30928
30929 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
30930         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30931         *ret_copy = SpendableOutputDescriptor_clone(arg);
30932         int64_t ret_ref = tag_ptr(ret_copy, true);
30933         return ret_ref;
30934 }
30935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30936         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
30937         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
30938         return ret_conv;
30939 }
30940
30941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30942         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
30943         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30944         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
30945         int64_t ret_ref = tag_ptr(ret_copy, true);
30946         return ret_ref;
30947 }
30948
30949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
30950         LDKOutPoint outpoint_conv;
30951         outpoint_conv.inner = untag_ptr(outpoint);
30952         outpoint_conv.is_owned = ptr_is_owned(outpoint);
30953         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
30954         outpoint_conv = OutPoint_clone(&outpoint_conv);
30955         void* output_ptr = untag_ptr(output);
30956         CHECK_ACCESS(output_ptr);
30957         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
30958         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
30959         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30960         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
30961         int64_t ret_ref = tag_ptr(ret_copy, true);
30962         return ret_ref;
30963 }
30964
30965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30966         LDKDelayedPaymentOutputDescriptor a_conv;
30967         a_conv.inner = untag_ptr(a);
30968         a_conv.is_owned = ptr_is_owned(a);
30969         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30970         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
30971         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30972         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
30973         int64_t ret_ref = tag_ptr(ret_copy, true);
30974         return ret_ref;
30975 }
30976
30977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30978         LDKStaticPaymentOutputDescriptor a_conv;
30979         a_conv.inner = untag_ptr(a);
30980         a_conv.is_owned = ptr_is_owned(a);
30981         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30982         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
30983         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30984         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
30985         int64_t ret_ref = tag_ptr(ret_copy, true);
30986         return ret_ref;
30987 }
30988
30989 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30990         LDKSpendableOutputDescriptor* a_conv = (LDKSpendableOutputDescriptor*)untag_ptr(a);
30991         LDKSpendableOutputDescriptor* b_conv = (LDKSpendableOutputDescriptor*)untag_ptr(b);
30992         jboolean ret_conv = SpendableOutputDescriptor_eq(a_conv, b_conv);
30993         return ret_conv;
30994 }
30995
30996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30997         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
30998         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
30999         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31000         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31001         CVec_u8Z_free(ret_var);
31002         return ret_arr;
31003 }
31004
31005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31006         LDKu8slice ser_ref;
31007         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31008         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31009         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
31010         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
31011         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31012         return tag_ptr(ret_conv, true);
31013 }
31014
31015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31016         if (!ptr_is_owned(this_ptr)) return;
31017         void* this_ptr_ptr = untag_ptr(this_ptr);
31018         CHECK_ACCESS(this_ptr_ptr);
31019         LDKChannelSigner this_ptr_conv = *(LDKChannelSigner*)(this_ptr_ptr);
31020         FREE(untag_ptr(this_ptr));
31021         ChannelSigner_free(this_ptr_conv);
31022 }
31023
31024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31025         if (!ptr_is_owned(this_ptr)) return;
31026         void* this_ptr_ptr = untag_ptr(this_ptr);
31027         CHECK_ACCESS(this_ptr_ptr);
31028         LDKEcdsaChannelSigner this_ptr_conv = *(LDKEcdsaChannelSigner*)(this_ptr_ptr);
31029         FREE(untag_ptr(this_ptr));
31030         EcdsaChannelSigner_free(this_ptr_conv);
31031 }
31032
31033 static inline uint64_t WriteableEcdsaChannelSigner_clone_ptr(LDKWriteableEcdsaChannelSigner *NONNULL_PTR arg) {
31034         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31035         *ret_ret = WriteableEcdsaChannelSigner_clone(arg);
31036         return tag_ptr(ret_ret, true);
31037 }
31038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31039         void* arg_ptr = untag_ptr(arg);
31040         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
31041         LDKWriteableEcdsaChannelSigner* arg_conv = (LDKWriteableEcdsaChannelSigner*)arg_ptr;
31042         int64_t ret_conv = WriteableEcdsaChannelSigner_clone_ptr(arg_conv);
31043         return ret_conv;
31044 }
31045
31046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31047         void* orig_ptr = untag_ptr(orig);
31048         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
31049         LDKWriteableEcdsaChannelSigner* orig_conv = (LDKWriteableEcdsaChannelSigner*)orig_ptr;
31050         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31051         *ret_ret = WriteableEcdsaChannelSigner_clone(orig_conv);
31052         return tag_ptr(ret_ret, true);
31053 }
31054
31055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31056         if (!ptr_is_owned(this_ptr)) return;
31057         void* this_ptr_ptr = untag_ptr(this_ptr);
31058         CHECK_ACCESS(this_ptr_ptr);
31059         LDKWriteableEcdsaChannelSigner this_ptr_conv = *(LDKWriteableEcdsaChannelSigner*)(this_ptr_ptr);
31060         FREE(untag_ptr(this_ptr));
31061         WriteableEcdsaChannelSigner_free(this_ptr_conv);
31062 }
31063
31064 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31065         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
31066         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
31067         return ret_conv;
31068 }
31069
31070 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
31071         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
31072         return ret_conv;
31073 }
31074
31075 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
31076         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
31077         return ret_conv;
31078 }
31079
31080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EntropySource_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31081         if (!ptr_is_owned(this_ptr)) return;
31082         void* this_ptr_ptr = untag_ptr(this_ptr);
31083         CHECK_ACCESS(this_ptr_ptr);
31084         LDKEntropySource this_ptr_conv = *(LDKEntropySource*)(this_ptr_ptr);
31085         FREE(untag_ptr(this_ptr));
31086         EntropySource_free(this_ptr_conv);
31087 }
31088
31089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31090         if (!ptr_is_owned(this_ptr)) return;
31091         void* this_ptr_ptr = untag_ptr(this_ptr);
31092         CHECK_ACCESS(this_ptr_ptr);
31093         LDKNodeSigner this_ptr_conv = *(LDKNodeSigner*)(this_ptr_ptr);
31094         FREE(untag_ptr(this_ptr));
31095         NodeSigner_free(this_ptr_conv);
31096 }
31097
31098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignerProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31099         if (!ptr_is_owned(this_ptr)) return;
31100         void* this_ptr_ptr = untag_ptr(this_ptr);
31101         CHECK_ACCESS(this_ptr_ptr);
31102         LDKSignerProvider this_ptr_conv = *(LDKSignerProvider*)(this_ptr_ptr);
31103         FREE(untag_ptr(this_ptr));
31104         SignerProvider_free(this_ptr_conv);
31105 }
31106
31107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31108         LDKInMemorySigner this_obj_conv;
31109         this_obj_conv.inner = untag_ptr(this_obj);
31110         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31112         InMemorySigner_free(this_obj_conv);
31113 }
31114
31115 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31116         LDKInMemorySigner this_ptr_conv;
31117         this_ptr_conv.inner = untag_ptr(this_ptr);
31118         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31120         this_ptr_conv.is_owned = false;
31121         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31122         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
31123         return ret_arr;
31124 }
31125
31126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31127         LDKInMemorySigner this_ptr_conv;
31128         this_ptr_conv.inner = untag_ptr(this_ptr);
31129         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31131         this_ptr_conv.is_owned = false;
31132         LDKSecretKey val_ref;
31133         CHECK((*env)->GetArrayLength(env, val) == 32);
31134         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31135         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
31136 }
31137
31138 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31139         LDKInMemorySigner this_ptr_conv;
31140         this_ptr_conv.inner = untag_ptr(this_ptr);
31141         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31143         this_ptr_conv.is_owned = false;
31144         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31145         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
31146         return ret_arr;
31147 }
31148
31149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31150         LDKInMemorySigner this_ptr_conv;
31151         this_ptr_conv.inner = untag_ptr(this_ptr);
31152         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31154         this_ptr_conv.is_owned = false;
31155         LDKSecretKey val_ref;
31156         CHECK((*env)->GetArrayLength(env, val) == 32);
31157         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31158         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
31159 }
31160
31161 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31162         LDKInMemorySigner this_ptr_conv;
31163         this_ptr_conv.inner = untag_ptr(this_ptr);
31164         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31166         this_ptr_conv.is_owned = false;
31167         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31168         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
31169         return ret_arr;
31170 }
31171
31172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31173         LDKInMemorySigner this_ptr_conv;
31174         this_ptr_conv.inner = untag_ptr(this_ptr);
31175         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31177         this_ptr_conv.is_owned = false;
31178         LDKSecretKey val_ref;
31179         CHECK((*env)->GetArrayLength(env, val) == 32);
31180         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31181         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
31182 }
31183
31184 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31185         LDKInMemorySigner this_ptr_conv;
31186         this_ptr_conv.inner = untag_ptr(this_ptr);
31187         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31189         this_ptr_conv.is_owned = false;
31190         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31191         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
31192         return ret_arr;
31193 }
31194
31195 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) {
31196         LDKInMemorySigner this_ptr_conv;
31197         this_ptr_conv.inner = untag_ptr(this_ptr);
31198         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31200         this_ptr_conv.is_owned = false;
31201         LDKSecretKey val_ref;
31202         CHECK((*env)->GetArrayLength(env, val) == 32);
31203         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31204         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
31205 }
31206
31207 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31208         LDKInMemorySigner this_ptr_conv;
31209         this_ptr_conv.inner = untag_ptr(this_ptr);
31210         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31212         this_ptr_conv.is_owned = false;
31213         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31214         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
31215         return ret_arr;
31216 }
31217
31218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31219         LDKInMemorySigner this_ptr_conv;
31220         this_ptr_conv.inner = untag_ptr(this_ptr);
31221         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31223         this_ptr_conv.is_owned = false;
31224         LDKSecretKey val_ref;
31225         CHECK((*env)->GetArrayLength(env, val) == 32);
31226         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31227         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
31228 }
31229
31230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
31231         LDKInMemorySigner this_ptr_conv;
31232         this_ptr_conv.inner = untag_ptr(this_ptr);
31233         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31235         this_ptr_conv.is_owned = false;
31236         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31237         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
31238         return ret_arr;
31239 }
31240
31241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31242         LDKInMemorySigner this_ptr_conv;
31243         this_ptr_conv.inner = untag_ptr(this_ptr);
31244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31246         this_ptr_conv.is_owned = false;
31247         LDKThirtyTwoBytes val_ref;
31248         CHECK((*env)->GetArrayLength(env, val) == 32);
31249         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31250         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
31251 }
31252
31253 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
31254         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
31255         int64_t ret_ref = 0;
31256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31257         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31258         return ret_ref;
31259 }
31260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31261         LDKInMemorySigner arg_conv;
31262         arg_conv.inner = untag_ptr(arg);
31263         arg_conv.is_owned = ptr_is_owned(arg);
31264         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31265         arg_conv.is_owned = false;
31266         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
31267         return ret_conv;
31268 }
31269
31270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31271         LDKInMemorySigner orig_conv;
31272         orig_conv.inner = untag_ptr(orig);
31273         orig_conv.is_owned = ptr_is_owned(orig);
31274         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31275         orig_conv.is_owned = false;
31276         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
31277         int64_t ret_ref = 0;
31278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31279         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31280         return ret_ref;
31281 }
31282
31283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1new(JNIEnv *env, jclass clz, int8_tArray funding_key, int8_tArray revocation_base_key, int8_tArray payment_key, int8_tArray delayed_payment_base_key, int8_tArray htlc_base_key, int8_tArray commitment_seed, int64_t channel_value_satoshis, int8_tArray channel_keys_id, int8_tArray rand_bytes_unique_start) {
31284         LDKSecretKey funding_key_ref;
31285         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
31286         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
31287         LDKSecretKey revocation_base_key_ref;
31288         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
31289         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
31290         LDKSecretKey payment_key_ref;
31291         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
31292         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
31293         LDKSecretKey delayed_payment_base_key_ref;
31294         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
31295         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
31296         LDKSecretKey htlc_base_key_ref;
31297         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
31298         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
31299         LDKThirtyTwoBytes commitment_seed_ref;
31300         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
31301         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
31302         LDKThirtyTwoBytes channel_keys_id_ref;
31303         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
31304         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
31305         LDKThirtyTwoBytes rand_bytes_unique_start_ref;
31306         CHECK((*env)->GetArrayLength(env, rand_bytes_unique_start) == 32);
31307         (*env)->GetByteArrayRegion(env, rand_bytes_unique_start, 0, 32, rand_bytes_unique_start_ref.data);
31308         LDKInMemorySigner ret_var = InMemorySigner_new(funding_key_ref, revocation_base_key_ref, payment_key_ref, delayed_payment_base_key_ref, htlc_base_key_ref, commitment_seed_ref, channel_value_satoshis, channel_keys_id_ref, rand_bytes_unique_start_ref);
31309         int64_t ret_ref = 0;
31310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31311         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31312         return ret_ref;
31313 }
31314
31315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
31316         LDKInMemorySigner this_arg_conv;
31317         this_arg_conv.inner = untag_ptr(this_arg);
31318         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31320         this_arg_conv.is_owned = false;
31321         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
31322         int64_t ret_ref = 0;
31323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31324         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31325         return ret_ref;
31326 }
31327
31328 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
31329         LDKInMemorySigner this_arg_conv;
31330         this_arg_conv.inner = untag_ptr(this_arg);
31331         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31333         this_arg_conv.is_owned = false;
31334         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
31335         return ret_conv;
31336 }
31337
31338 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
31339         LDKInMemorySigner this_arg_conv;
31340         this_arg_conv.inner = untag_ptr(this_arg);
31341         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31343         this_arg_conv.is_owned = false;
31344         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
31345         return ret_conv;
31346 }
31347
31348 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
31349         LDKInMemorySigner this_arg_conv;
31350         this_arg_conv.inner = untag_ptr(this_arg);
31351         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31353         this_arg_conv.is_owned = false;
31354         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
31355         return ret_conv;
31356 }
31357
31358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
31359         LDKInMemorySigner this_arg_conv;
31360         this_arg_conv.inner = untag_ptr(this_arg);
31361         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31363         this_arg_conv.is_owned = false;
31364         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
31365         int64_t ret_ref = 0;
31366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31368         return ret_ref;
31369 }
31370
31371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
31372         LDKInMemorySigner this_arg_conv;
31373         this_arg_conv.inner = untag_ptr(this_arg);
31374         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31376         this_arg_conv.is_owned = false;
31377         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
31378         int64_t ret_ref = 0;
31379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31380         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31381         return ret_ref;
31382 }
31383
31384 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
31385         LDKInMemorySigner this_arg_conv;
31386         this_arg_conv.inner = untag_ptr(this_arg);
31387         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31389         this_arg_conv.is_owned = false;
31390         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
31391         return ret_conv;
31392 }
31393
31394 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) {
31395         LDKInMemorySigner this_arg_conv;
31396         this_arg_conv.inner = untag_ptr(this_arg);
31397         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31399         this_arg_conv.is_owned = false;
31400         LDKTransaction spend_tx_ref;
31401         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
31402         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
31403         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31404         spend_tx_ref.data_is_owned = true;
31405         LDKStaticPaymentOutputDescriptor descriptor_conv;
31406         descriptor_conv.inner = untag_ptr(descriptor);
31407         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31408         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31409         descriptor_conv.is_owned = false;
31410         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31411         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31412         return tag_ptr(ret_conv, true);
31413 }
31414
31415 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) {
31416         LDKInMemorySigner this_arg_conv;
31417         this_arg_conv.inner = untag_ptr(this_arg);
31418         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31420         this_arg_conv.is_owned = false;
31421         LDKTransaction spend_tx_ref;
31422         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
31423         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
31424         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31425         spend_tx_ref.data_is_owned = true;
31426         LDKDelayedPaymentOutputDescriptor descriptor_conv;
31427         descriptor_conv.inner = untag_ptr(descriptor);
31428         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31429         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31430         descriptor_conv.is_owned = false;
31431         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31432         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31433         return tag_ptr(ret_conv, true);
31434 }
31435
31436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1EntropySource(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         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31443         *ret_ret = InMemorySigner_as_EntropySource(&this_arg_conv);
31444         return tag_ptr(ret_ret, true);
31445 }
31446
31447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1ChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31448         LDKInMemorySigner this_arg_conv;
31449         this_arg_conv.inner = untag_ptr(this_arg);
31450         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31452         this_arg_conv.is_owned = false;
31453         LDKChannelSigner* ret_ret = MALLOC(sizeof(LDKChannelSigner), "LDKChannelSigner");
31454         *ret_ret = InMemorySigner_as_ChannelSigner(&this_arg_conv);
31455         return tag_ptr(ret_ret, true);
31456 }
31457
31458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1EcdsaChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31459         LDKInMemorySigner this_arg_conv;
31460         this_arg_conv.inner = untag_ptr(this_arg);
31461         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31463         this_arg_conv.is_owned = false;
31464         LDKEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKEcdsaChannelSigner), "LDKEcdsaChannelSigner");
31465         *ret_ret = InMemorySigner_as_EcdsaChannelSigner(&this_arg_conv);
31466         return tag_ptr(ret_ret, true);
31467 }
31468
31469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1WriteableEcdsaChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31470         LDKInMemorySigner this_arg_conv;
31471         this_arg_conv.inner = untag_ptr(this_arg);
31472         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31474         this_arg_conv.is_owned = false;
31475         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31476         *ret_ret = InMemorySigner_as_WriteableEcdsaChannelSigner(&this_arg_conv);
31477         return tag_ptr(ret_ret, true);
31478 }
31479
31480 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
31481         LDKInMemorySigner obj_conv;
31482         obj_conv.inner = untag_ptr(obj);
31483         obj_conv.is_owned = ptr_is_owned(obj);
31484         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31485         obj_conv.is_owned = false;
31486         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
31487         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31488         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31489         CVec_u8Z_free(ret_var);
31490         return ret_arr;
31491 }
31492
31493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
31494         LDKu8slice ser_ref;
31495         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31496         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31497         void* arg_ptr = untag_ptr(arg);
31498         CHECK_ACCESS(arg_ptr);
31499         LDKEntropySource arg_conv = *(LDKEntropySource*)(arg_ptr);
31500         if (arg_conv.free == LDKEntropySource_JCalls_free) {
31501                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31502                 LDKEntropySource_JCalls_cloned(&arg_conv);
31503         }
31504         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
31505         *ret_conv = InMemorySigner_read(ser_ref, arg_conv);
31506         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31507         return tag_ptr(ret_conv, true);
31508 }
31509
31510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31511         LDKKeysManager this_obj_conv;
31512         this_obj_conv.inner = untag_ptr(this_obj);
31513         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31515         KeysManager_free(this_obj_conv);
31516 }
31517
31518 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) {
31519         uint8_t seed_arr[32];
31520         CHECK((*env)->GetArrayLength(env, seed) == 32);
31521         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31522         uint8_t (*seed_ref)[32] = &seed_arr;
31523         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
31524         int64_t ret_ref = 0;
31525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31526         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31527         return ret_ref;
31528 }
31529
31530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysManager_1get_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31531         LDKKeysManager this_arg_conv;
31532         this_arg_conv.inner = untag_ptr(this_arg);
31533         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31535         this_arg_conv.is_owned = false;
31536         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31537         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, KeysManager_get_node_secret_key(&this_arg_conv).bytes);
31538         return ret_arr;
31539 }
31540
31541 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) {
31542         LDKKeysManager this_arg_conv;
31543         this_arg_conv.inner = untag_ptr(this_arg);
31544         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31546         this_arg_conv.is_owned = false;
31547         uint8_t params_arr[32];
31548         CHECK((*env)->GetArrayLength(env, params) == 32);
31549         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31550         uint8_t (*params_ref)[32] = &params_arr;
31551         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31552         int64_t ret_ref = 0;
31553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31554         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31555         return ret_ref;
31556 }
31557
31558 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) {
31559         LDKKeysManager this_arg_conv;
31560         this_arg_conv.inner = untag_ptr(this_arg);
31561         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31563         this_arg_conv.is_owned = false;
31564         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31565         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31566         if (descriptors_constr.datalen > 0)
31567                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31568         else
31569                 descriptors_constr.data = NULL;
31570         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31571         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31572                 int64_t descriptors_conv_27 = descriptors_vals[b];
31573                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31574                 CHECK_ACCESS(descriptors_conv_27_ptr);
31575                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31576                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31577                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31578         }
31579         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31580         LDKCVec_TxOutZ outputs_constr;
31581         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31582         if (outputs_constr.datalen > 0)
31583                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31584         else
31585                 outputs_constr.data = NULL;
31586         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31587         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31588                 int64_t outputs_conv_7 = outputs_vals[h];
31589                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31590                 CHECK_ACCESS(outputs_conv_7_ptr);
31591                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31592                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31593                 outputs_constr.data[h] = outputs_conv_7_conv;
31594         }
31595         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31596         LDKCVec_u8Z change_destination_script_ref;
31597         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31598         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31599         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31600         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31601         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31602         return tag_ptr(ret_conv, true);
31603 }
31604
31605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1EntropySource(JNIEnv *env, jclass clz, int64_t this_arg) {
31606         LDKKeysManager this_arg_conv;
31607         this_arg_conv.inner = untag_ptr(this_arg);
31608         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31610         this_arg_conv.is_owned = false;
31611         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31612         *ret_ret = KeysManager_as_EntropySource(&this_arg_conv);
31613         return tag_ptr(ret_ret, true);
31614 }
31615
31616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1NodeSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31617         LDKKeysManager this_arg_conv;
31618         this_arg_conv.inner = untag_ptr(this_arg);
31619         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31621         this_arg_conv.is_owned = false;
31622         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
31623         *ret_ret = KeysManager_as_NodeSigner(&this_arg_conv);
31624         return tag_ptr(ret_ret, true);
31625 }
31626
31627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1SignerProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31628         LDKKeysManager this_arg_conv;
31629         this_arg_conv.inner = untag_ptr(this_arg);
31630         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31632         this_arg_conv.is_owned = false;
31633         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
31634         *ret_ret = KeysManager_as_SignerProvider(&this_arg_conv);
31635         return tag_ptr(ret_ret, true);
31636 }
31637
31638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31639         LDKPhantomKeysManager this_obj_conv;
31640         this_obj_conv.inner = untag_ptr(this_obj);
31641         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31643         PhantomKeysManager_free(this_obj_conv);
31644 }
31645
31646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1EntropySource(JNIEnv *env, jclass clz, int64_t this_arg) {
31647         LDKPhantomKeysManager this_arg_conv;
31648         this_arg_conv.inner = untag_ptr(this_arg);
31649         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31651         this_arg_conv.is_owned = false;
31652         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31653         *ret_ret = PhantomKeysManager_as_EntropySource(&this_arg_conv);
31654         return tag_ptr(ret_ret, true);
31655 }
31656
31657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1NodeSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31658         LDKPhantomKeysManager this_arg_conv;
31659         this_arg_conv.inner = untag_ptr(this_arg);
31660         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31662         this_arg_conv.is_owned = false;
31663         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
31664         *ret_ret = PhantomKeysManager_as_NodeSigner(&this_arg_conv);
31665         return tag_ptr(ret_ret, true);
31666 }
31667
31668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1SignerProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31669         LDKPhantomKeysManager this_arg_conv;
31670         this_arg_conv.inner = untag_ptr(this_arg);
31671         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31673         this_arg_conv.is_owned = false;
31674         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
31675         *ret_ret = PhantomKeysManager_as_SignerProvider(&this_arg_conv);
31676         return tag_ptr(ret_ret, true);
31677 }
31678
31679 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) {
31680         uint8_t seed_arr[32];
31681         CHECK((*env)->GetArrayLength(env, seed) == 32);
31682         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31683         uint8_t (*seed_ref)[32] = &seed_arr;
31684         uint8_t cross_node_seed_arr[32];
31685         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
31686         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
31687         uint8_t (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
31688         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
31689         int64_t ret_ref = 0;
31690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31692         return ret_ref;
31693 }
31694
31695 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) {
31696         LDKPhantomKeysManager this_arg_conv;
31697         this_arg_conv.inner = untag_ptr(this_arg);
31698         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31700         this_arg_conv.is_owned = false;
31701         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31702         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31703         if (descriptors_constr.datalen > 0)
31704                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31705         else
31706                 descriptors_constr.data = NULL;
31707         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31708         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31709                 int64_t descriptors_conv_27 = descriptors_vals[b];
31710                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31711                 CHECK_ACCESS(descriptors_conv_27_ptr);
31712                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31713                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31714                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31715         }
31716         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31717         LDKCVec_TxOutZ outputs_constr;
31718         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31719         if (outputs_constr.datalen > 0)
31720                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31721         else
31722                 outputs_constr.data = NULL;
31723         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31724         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31725                 int64_t outputs_conv_7 = outputs_vals[h];
31726                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31727                 CHECK_ACCESS(outputs_conv_7_ptr);
31728                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31729                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31730                 outputs_constr.data[h] = outputs_conv_7_conv;
31731         }
31732         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31733         LDKCVec_u8Z change_destination_script_ref;
31734         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31735         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31736         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31737         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31738         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31739         return tag_ptr(ret_conv, true);
31740 }
31741
31742 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) {
31743         LDKPhantomKeysManager this_arg_conv;
31744         this_arg_conv.inner = untag_ptr(this_arg);
31745         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31747         this_arg_conv.is_owned = false;
31748         uint8_t params_arr[32];
31749         CHECK((*env)->GetArrayLength(env, params) == 32);
31750         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31751         uint8_t (*params_ref)[32] = &params_arr;
31752         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31753         int64_t ret_ref = 0;
31754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31755         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31756         return ret_ref;
31757 }
31758
31759 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1get_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31760         LDKPhantomKeysManager this_arg_conv;
31761         this_arg_conv.inner = untag_ptr(this_arg);
31762         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31764         this_arg_conv.is_owned = false;
31765         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31766         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, PhantomKeysManager_get_node_secret_key(&this_arg_conv).bytes);
31767         return ret_arr;
31768 }
31769
31770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1get_1phantom_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31771         LDKPhantomKeysManager this_arg_conv;
31772         this_arg_conv.inner = untag_ptr(this_arg);
31773         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31775         this_arg_conv.is_owned = false;
31776         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31777         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, PhantomKeysManager_get_phantom_node_secret_key(&this_arg_conv).bytes);
31778         return ret_arr;
31779 }
31780
31781 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31782         LDKFailureCode* orig_conv = (LDKFailureCode*)untag_ptr(orig);
31783         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_clone(orig_conv));
31784         return ret_conv;
31785 }
31786
31787 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1temporary_1node_1failure(JNIEnv *env, jclass clz) {
31788         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_temporary_node_failure());
31789         return ret_conv;
31790 }
31791
31792 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1required_1node_1feature_1missing(JNIEnv *env, jclass clz) {
31793         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_required_node_feature_missing());
31794         return ret_conv;
31795 }
31796
31797 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1incorrect_1or_1unknown_1payment_1details(JNIEnv *env, jclass clz) {
31798         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_incorrect_or_unknown_payment_details());
31799         return ret_conv;
31800 }
31801
31802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31803         LDKChannelManager this_obj_conv;
31804         this_obj_conv.inner = untag_ptr(this_obj);
31805         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31807         ChannelManager_free(this_obj_conv);
31808 }
31809
31810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31811         LDKChainParameters this_obj_conv;
31812         this_obj_conv.inner = untag_ptr(this_obj);
31813         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31815         ChainParameters_free(this_obj_conv);
31816 }
31817
31818 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
31819         LDKChainParameters this_ptr_conv;
31820         this_ptr_conv.inner = untag_ptr(this_ptr);
31821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31823         this_ptr_conv.is_owned = false;
31824         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
31825         return ret_conv;
31826 }
31827
31828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
31829         LDKChainParameters this_ptr_conv;
31830         this_ptr_conv.inner = untag_ptr(this_ptr);
31831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31833         this_ptr_conv.is_owned = false;
31834         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
31835         ChainParameters_set_network(&this_ptr_conv, val_conv);
31836 }
31837
31838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
31839         LDKChainParameters this_ptr_conv;
31840         this_ptr_conv.inner = untag_ptr(this_ptr);
31841         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31843         this_ptr_conv.is_owned = false;
31844         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
31845         int64_t ret_ref = 0;
31846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31848         return ret_ref;
31849 }
31850
31851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31852         LDKChainParameters this_ptr_conv;
31853         this_ptr_conv.inner = untag_ptr(this_ptr);
31854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31856         this_ptr_conv.is_owned = false;
31857         LDKBestBlock val_conv;
31858         val_conv.inner = untag_ptr(val);
31859         val_conv.is_owned = ptr_is_owned(val);
31860         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31861         val_conv = BestBlock_clone(&val_conv);
31862         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
31863 }
31864
31865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
31866         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
31867         LDKBestBlock best_block_arg_conv;
31868         best_block_arg_conv.inner = untag_ptr(best_block_arg);
31869         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
31870         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
31871         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
31872         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
31873         int64_t ret_ref = 0;
31874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31875         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31876         return ret_ref;
31877 }
31878
31879 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
31880         LDKChainParameters ret_var = ChainParameters_clone(arg);
31881         int64_t ret_ref = 0;
31882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31883         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31884         return ret_ref;
31885 }
31886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31887         LDKChainParameters arg_conv;
31888         arg_conv.inner = untag_ptr(arg);
31889         arg_conv.is_owned = ptr_is_owned(arg);
31890         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31891         arg_conv.is_owned = false;
31892         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
31893         return ret_conv;
31894 }
31895
31896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31897         LDKChainParameters orig_conv;
31898         orig_conv.inner = untag_ptr(orig);
31899         orig_conv.is_owned = ptr_is_owned(orig);
31900         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31901         orig_conv.is_owned = false;
31902         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
31903         int64_t ret_ref = 0;
31904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31905         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31906         return ret_ref;
31907 }
31908
31909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31910         LDKCounterpartyForwardingInfo this_obj_conv;
31911         this_obj_conv.inner = untag_ptr(this_obj);
31912         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31914         CounterpartyForwardingInfo_free(this_obj_conv);
31915 }
31916
31917 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31918         LDKCounterpartyForwardingInfo this_ptr_conv;
31919         this_ptr_conv.inner = untag_ptr(this_ptr);
31920         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31922         this_ptr_conv.is_owned = false;
31923         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
31924         return ret_conv;
31925 }
31926
31927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31928         LDKCounterpartyForwardingInfo this_ptr_conv;
31929         this_ptr_conv.inner = untag_ptr(this_ptr);
31930         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31932         this_ptr_conv.is_owned = false;
31933         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
31934 }
31935
31936 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
31937         LDKCounterpartyForwardingInfo this_ptr_conv;
31938         this_ptr_conv.inner = untag_ptr(this_ptr);
31939         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31941         this_ptr_conv.is_owned = false;
31942         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
31943         return ret_conv;
31944 }
31945
31946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31947         LDKCounterpartyForwardingInfo this_ptr_conv;
31948         this_ptr_conv.inner = untag_ptr(this_ptr);
31949         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31951         this_ptr_conv.is_owned = false;
31952         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
31953 }
31954
31955 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
31956         LDKCounterpartyForwardingInfo this_ptr_conv;
31957         this_ptr_conv.inner = untag_ptr(this_ptr);
31958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31960         this_ptr_conv.is_owned = false;
31961         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
31962         return ret_conv;
31963 }
31964
31965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31966         LDKCounterpartyForwardingInfo this_ptr_conv;
31967         this_ptr_conv.inner = untag_ptr(this_ptr);
31968         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31970         this_ptr_conv.is_owned = false;
31971         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
31972 }
31973
31974 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) {
31975         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
31976         int64_t ret_ref = 0;
31977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31978         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31979         return ret_ref;
31980 }
31981
31982 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
31983         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
31984         int64_t ret_ref = 0;
31985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31986         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31987         return ret_ref;
31988 }
31989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31990         LDKCounterpartyForwardingInfo arg_conv;
31991         arg_conv.inner = untag_ptr(arg);
31992         arg_conv.is_owned = ptr_is_owned(arg);
31993         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31994         arg_conv.is_owned = false;
31995         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
31996         return ret_conv;
31997 }
31998
31999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32000         LDKCounterpartyForwardingInfo orig_conv;
32001         orig_conv.inner = untag_ptr(orig);
32002         orig_conv.is_owned = ptr_is_owned(orig);
32003         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32004         orig_conv.is_owned = false;
32005         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
32006         int64_t ret_ref = 0;
32007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32008         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32009         return ret_ref;
32010 }
32011
32012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32013         LDKChannelCounterparty this_obj_conv;
32014         this_obj_conv.inner = untag_ptr(this_obj);
32015         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32017         ChannelCounterparty_free(this_obj_conv);
32018 }
32019
32020 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32021         LDKChannelCounterparty this_ptr_conv;
32022         this_ptr_conv.inner = untag_ptr(this_ptr);
32023         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32025         this_ptr_conv.is_owned = false;
32026         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32027         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
32028         return ret_arr;
32029 }
32030
32031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32032         LDKChannelCounterparty this_ptr_conv;
32033         this_ptr_conv.inner = untag_ptr(this_ptr);
32034         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32036         this_ptr_conv.is_owned = false;
32037         LDKPublicKey val_ref;
32038         CHECK((*env)->GetArrayLength(env, val) == 33);
32039         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32040         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
32041 }
32042
32043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
32044         LDKChannelCounterparty this_ptr_conv;
32045         this_ptr_conv.inner = untag_ptr(this_ptr);
32046         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32048         this_ptr_conv.is_owned = false;
32049         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
32050         int64_t ret_ref = 0;
32051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32052         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32053         return ret_ref;
32054 }
32055
32056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32057         LDKChannelCounterparty this_ptr_conv;
32058         this_ptr_conv.inner = untag_ptr(this_ptr);
32059         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32061         this_ptr_conv.is_owned = false;
32062         LDKInitFeatures val_conv;
32063         val_conv.inner = untag_ptr(val);
32064         val_conv.is_owned = ptr_is_owned(val);
32065         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32066         val_conv = InitFeatures_clone(&val_conv);
32067         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
32068 }
32069
32070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
32071         LDKChannelCounterparty this_ptr_conv;
32072         this_ptr_conv.inner = untag_ptr(this_ptr);
32073         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32075         this_ptr_conv.is_owned = false;
32076         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
32077         return ret_conv;
32078 }
32079
32080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32081         LDKChannelCounterparty this_ptr_conv;
32082         this_ptr_conv.inner = untag_ptr(this_ptr);
32083         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32085         this_ptr_conv.is_owned = false;
32086         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
32087 }
32088
32089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
32090         LDKChannelCounterparty this_ptr_conv;
32091         this_ptr_conv.inner = untag_ptr(this_ptr);
32092         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32094         this_ptr_conv.is_owned = false;
32095         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
32096         int64_t ret_ref = 0;
32097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32099         return ret_ref;
32100 }
32101
32102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32103         LDKChannelCounterparty this_ptr_conv;
32104         this_ptr_conv.inner = untag_ptr(this_ptr);
32105         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32107         this_ptr_conv.is_owned = false;
32108         LDKCounterpartyForwardingInfo val_conv;
32109         val_conv.inner = untag_ptr(val);
32110         val_conv.is_owned = ptr_is_owned(val);
32111         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32112         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
32113         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
32114 }
32115
32116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32117         LDKChannelCounterparty this_ptr_conv;
32118         this_ptr_conv.inner = untag_ptr(this_ptr);
32119         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32121         this_ptr_conv.is_owned = false;
32122         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32123         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
32124         int64_t ret_ref = tag_ptr(ret_copy, true);
32125         return ret_ref;
32126 }
32127
32128 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) {
32129         LDKChannelCounterparty this_ptr_conv;
32130         this_ptr_conv.inner = untag_ptr(this_ptr);
32131         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32133         this_ptr_conv.is_owned = false;
32134         void* val_ptr = untag_ptr(val);
32135         CHECK_ACCESS(val_ptr);
32136         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32137         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32138         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
32139 }
32140
32141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32142         LDKChannelCounterparty this_ptr_conv;
32143         this_ptr_conv.inner = untag_ptr(this_ptr);
32144         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32146         this_ptr_conv.is_owned = false;
32147         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32148         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
32149         int64_t ret_ref = tag_ptr(ret_copy, true);
32150         return ret_ref;
32151 }
32152
32153 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) {
32154         LDKChannelCounterparty this_ptr_conv;
32155         this_ptr_conv.inner = untag_ptr(this_ptr);
32156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32158         this_ptr_conv.is_owned = false;
32159         void* val_ptr = untag_ptr(val);
32160         CHECK_ACCESS(val_ptr);
32161         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32162         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32163         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
32164 }
32165
32166 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) {
32167         LDKPublicKey node_id_arg_ref;
32168         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
32169         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
32170         LDKInitFeatures features_arg_conv;
32171         features_arg_conv.inner = untag_ptr(features_arg);
32172         features_arg_conv.is_owned = ptr_is_owned(features_arg);
32173         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
32174         features_arg_conv = InitFeatures_clone(&features_arg_conv);
32175         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
32176         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
32177         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
32178         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
32179         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
32180         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
32181         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
32182         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
32183         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
32184         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
32185         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
32186         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
32187         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
32188         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);
32189         int64_t ret_ref = 0;
32190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32191         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32192         return ret_ref;
32193 }
32194
32195 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
32196         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
32197         int64_t ret_ref = 0;
32198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32199         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32200         return ret_ref;
32201 }
32202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32203         LDKChannelCounterparty arg_conv;
32204         arg_conv.inner = untag_ptr(arg);
32205         arg_conv.is_owned = ptr_is_owned(arg);
32206         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32207         arg_conv.is_owned = false;
32208         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
32209         return ret_conv;
32210 }
32211
32212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32213         LDKChannelCounterparty orig_conv;
32214         orig_conv.inner = untag_ptr(orig);
32215         orig_conv.is_owned = ptr_is_owned(orig);
32216         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32217         orig_conv.is_owned = false;
32218         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
32219         int64_t ret_ref = 0;
32220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32221         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32222         return ret_ref;
32223 }
32224
32225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32226         LDKChannelDetails this_obj_conv;
32227         this_obj_conv.inner = untag_ptr(this_obj);
32228         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32230         ChannelDetails_free(this_obj_conv);
32231 }
32232
32233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32234         LDKChannelDetails this_ptr_conv;
32235         this_ptr_conv.inner = untag_ptr(this_ptr);
32236         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32238         this_ptr_conv.is_owned = false;
32239         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32240         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
32241         return ret_arr;
32242 }
32243
32244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32245         LDKChannelDetails this_ptr_conv;
32246         this_ptr_conv.inner = untag_ptr(this_ptr);
32247         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32249         this_ptr_conv.is_owned = false;
32250         LDKThirtyTwoBytes val_ref;
32251         CHECK((*env)->GetArrayLength(env, val) == 32);
32252         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32253         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
32254 }
32255
32256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
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         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
32263         int64_t ret_ref = 0;
32264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32265         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32266         return ret_ref;
32267 }
32268
32269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32270         LDKChannelDetails this_ptr_conv;
32271         this_ptr_conv.inner = untag_ptr(this_ptr);
32272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32274         this_ptr_conv.is_owned = false;
32275         LDKChannelCounterparty val_conv;
32276         val_conv.inner = untag_ptr(val);
32277         val_conv.is_owned = ptr_is_owned(val);
32278         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32279         val_conv = ChannelCounterparty_clone(&val_conv);
32280         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
32281 }
32282
32283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
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         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
32290         int64_t ret_ref = 0;
32291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32292         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32293         return ret_ref;
32294 }
32295
32296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32297         LDKChannelDetails this_ptr_conv;
32298         this_ptr_conv.inner = untag_ptr(this_ptr);
32299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32301         this_ptr_conv.is_owned = false;
32302         LDKOutPoint val_conv;
32303         val_conv.inner = untag_ptr(val);
32304         val_conv.is_owned = ptr_is_owned(val);
32305         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32306         val_conv = OutPoint_clone(&val_conv);
32307         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
32308 }
32309
32310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
32311         LDKChannelDetails this_ptr_conv;
32312         this_ptr_conv.inner = untag_ptr(this_ptr);
32313         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32315         this_ptr_conv.is_owned = false;
32316         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
32317         int64_t ret_ref = 0;
32318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32319         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32320         return ret_ref;
32321 }
32322
32323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32324         LDKChannelDetails this_ptr_conv;
32325         this_ptr_conv.inner = untag_ptr(this_ptr);
32326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32328         this_ptr_conv.is_owned = false;
32329         LDKChannelTypeFeatures val_conv;
32330         val_conv.inner = untag_ptr(val);
32331         val_conv.is_owned = ptr_is_owned(val);
32332         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32333         val_conv = ChannelTypeFeatures_clone(&val_conv);
32334         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
32335 }
32336
32337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32338         LDKChannelDetails this_ptr_conv;
32339         this_ptr_conv.inner = untag_ptr(this_ptr);
32340         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32342         this_ptr_conv.is_owned = false;
32343         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32344         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
32345         int64_t ret_ref = tag_ptr(ret_copy, true);
32346         return ret_ref;
32347 }
32348
32349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32350         LDKChannelDetails this_ptr_conv;
32351         this_ptr_conv.inner = untag_ptr(this_ptr);
32352         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32354         this_ptr_conv.is_owned = false;
32355         void* val_ptr = untag_ptr(val);
32356         CHECK_ACCESS(val_ptr);
32357         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32358         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32359         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
32360 }
32361
32362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32363         LDKChannelDetails this_ptr_conv;
32364         this_ptr_conv.inner = untag_ptr(this_ptr);
32365         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32367         this_ptr_conv.is_owned = false;
32368         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32369         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
32370         int64_t ret_ref = tag_ptr(ret_copy, true);
32371         return ret_ref;
32372 }
32373
32374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32375         LDKChannelDetails this_ptr_conv;
32376         this_ptr_conv.inner = untag_ptr(this_ptr);
32377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32379         this_ptr_conv.is_owned = false;
32380         void* val_ptr = untag_ptr(val);
32381         CHECK_ACCESS(val_ptr);
32382         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32383         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32384         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
32385 }
32386
32387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32388         LDKChannelDetails this_ptr_conv;
32389         this_ptr_conv.inner = untag_ptr(this_ptr);
32390         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32392         this_ptr_conv.is_owned = false;
32393         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32394         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
32395         int64_t ret_ref = tag_ptr(ret_copy, true);
32396         return ret_ref;
32397 }
32398
32399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32400         LDKChannelDetails this_ptr_conv;
32401         this_ptr_conv.inner = untag_ptr(this_ptr);
32402         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32404         this_ptr_conv.is_owned = false;
32405         void* val_ptr = untag_ptr(val);
32406         CHECK_ACCESS(val_ptr);
32407         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32408         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32409         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
32410 }
32411
32412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32413         LDKChannelDetails this_ptr_conv;
32414         this_ptr_conv.inner = untag_ptr(this_ptr);
32415         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32417         this_ptr_conv.is_owned = false;
32418         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
32419         return ret_conv;
32420 }
32421
32422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32423         LDKChannelDetails this_ptr_conv;
32424         this_ptr_conv.inner = untag_ptr(this_ptr);
32425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32427         this_ptr_conv.is_owned = false;
32428         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
32429 }
32430
32431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
32432         LDKChannelDetails this_ptr_conv;
32433         this_ptr_conv.inner = untag_ptr(this_ptr);
32434         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32436         this_ptr_conv.is_owned = false;
32437         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32438         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
32439         int64_t ret_ref = tag_ptr(ret_copy, true);
32440         return ret_ref;
32441 }
32442
32443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32444         LDKChannelDetails this_ptr_conv;
32445         this_ptr_conv.inner = untag_ptr(this_ptr);
32446         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32448         this_ptr_conv.is_owned = false;
32449         void* val_ptr = untag_ptr(val);
32450         CHECK_ACCESS(val_ptr);
32451         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32452         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32453         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
32454 }
32455
32456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32457         LDKChannelDetails this_ptr_conv;
32458         this_ptr_conv.inner = untag_ptr(this_ptr);
32459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32461         this_ptr_conv.is_owned = false;
32462         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
32463         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, ChannelDetails_get_user_channel_id(&this_ptr_conv).le_bytes);
32464         return ret_arr;
32465 }
32466
32467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32468         LDKChannelDetails this_ptr_conv;
32469         this_ptr_conv.inner = untag_ptr(this_ptr);
32470         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32472         this_ptr_conv.is_owned = false;
32473         LDKU128 val_ref;
32474         CHECK((*env)->GetArrayLength(env, val) == 16);
32475         (*env)->GetByteArrayRegion(env, val, 0, 16, val_ref.le_bytes);
32476         ChannelDetails_set_user_channel_id(&this_ptr_conv, val_ref);
32477 }
32478
32479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1feerate_1sat_1per_11000_1weight(JNIEnv *env, jclass clz, int64_t this_ptr) {
32480         LDKChannelDetails this_ptr_conv;
32481         this_ptr_conv.inner = untag_ptr(this_ptr);
32482         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32484         this_ptr_conv.is_owned = false;
32485         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32486         *ret_copy = ChannelDetails_get_feerate_sat_per_1000_weight(&this_ptr_conv);
32487         int64_t ret_ref = tag_ptr(ret_copy, true);
32488         return ret_ref;
32489 }
32490
32491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1feerate_1sat_1per_11000_1weight(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32492         LDKChannelDetails this_ptr_conv;
32493         this_ptr_conv.inner = untag_ptr(this_ptr);
32494         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32496         this_ptr_conv.is_owned = false;
32497         void* val_ptr = untag_ptr(val);
32498         CHECK_ACCESS(val_ptr);
32499         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32500         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32501         ChannelDetails_set_feerate_sat_per_1000_weight(&this_ptr_conv, val_conv);
32502 }
32503
32504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32505         LDKChannelDetails this_ptr_conv;
32506         this_ptr_conv.inner = untag_ptr(this_ptr);
32507         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32509         this_ptr_conv.is_owned = false;
32510         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
32511         return ret_conv;
32512 }
32513
32514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32515         LDKChannelDetails this_ptr_conv;
32516         this_ptr_conv.inner = untag_ptr(this_ptr);
32517         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32519         this_ptr_conv.is_owned = false;
32520         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
32521 }
32522
32523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32524         LDKChannelDetails this_ptr_conv;
32525         this_ptr_conv.inner = untag_ptr(this_ptr);
32526         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32528         this_ptr_conv.is_owned = false;
32529         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
32530         return ret_conv;
32531 }
32532
32533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32534         LDKChannelDetails this_ptr_conv;
32535         this_ptr_conv.inner = untag_ptr(this_ptr);
32536         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32538         this_ptr_conv.is_owned = false;
32539         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
32540 }
32541
32542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32543         LDKChannelDetails this_ptr_conv;
32544         this_ptr_conv.inner = untag_ptr(this_ptr);
32545         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32547         this_ptr_conv.is_owned = false;
32548         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
32549         return ret_conv;
32550 }
32551
32552 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) {
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         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
32559 }
32560
32561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32562         LDKChannelDetails this_ptr_conv;
32563         this_ptr_conv.inner = untag_ptr(this_ptr);
32564         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32566         this_ptr_conv.is_owned = false;
32567         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
32568         return ret_conv;
32569 }
32570
32571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32572         LDKChannelDetails this_ptr_conv;
32573         this_ptr_conv.inner = untag_ptr(this_ptr);
32574         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32576         this_ptr_conv.is_owned = false;
32577         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
32578 }
32579
32580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
32581         LDKChannelDetails this_ptr_conv;
32582         this_ptr_conv.inner = untag_ptr(this_ptr);
32583         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32585         this_ptr_conv.is_owned = false;
32586         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32587         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
32588         int64_t ret_ref = tag_ptr(ret_copy, true);
32589         return ret_ref;
32590 }
32591
32592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32593         LDKChannelDetails this_ptr_conv;
32594         this_ptr_conv.inner = untag_ptr(this_ptr);
32595         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32597         this_ptr_conv.is_owned = false;
32598         void* val_ptr = untag_ptr(val);
32599         CHECK_ACCESS(val_ptr);
32600         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32601         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32602         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
32603 }
32604
32605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr) {
32606         LDKChannelDetails this_ptr_conv;
32607         this_ptr_conv.inner = untag_ptr(this_ptr);
32608         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32610         this_ptr_conv.is_owned = false;
32611         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32612         *ret_copy = ChannelDetails_get_confirmations(&this_ptr_conv);
32613         int64_t ret_ref = tag_ptr(ret_copy, true);
32614         return ret_ref;
32615 }
32616
32617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32618         LDKChannelDetails this_ptr_conv;
32619         this_ptr_conv.inner = untag_ptr(this_ptr);
32620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32622         this_ptr_conv.is_owned = false;
32623         void* val_ptr = untag_ptr(val);
32624         CHECK_ACCESS(val_ptr);
32625         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32626         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32627         ChannelDetails_set_confirmations(&this_ptr_conv, val_conv);
32628 }
32629
32630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32631         LDKChannelDetails this_ptr_conv;
32632         this_ptr_conv.inner = untag_ptr(this_ptr);
32633         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32635         this_ptr_conv.is_owned = false;
32636         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
32637         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
32638         int64_t ret_ref = tag_ptr(ret_copy, true);
32639         return ret_ref;
32640 }
32641
32642 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) {
32643         LDKChannelDetails this_ptr_conv;
32644         this_ptr_conv.inner = untag_ptr(this_ptr);
32645         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32647         this_ptr_conv.is_owned = false;
32648         void* val_ptr = untag_ptr(val);
32649         CHECK_ACCESS(val_ptr);
32650         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
32651         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
32652         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
32653 }
32654
32655 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
32656         LDKChannelDetails this_ptr_conv;
32657         this_ptr_conv.inner = untag_ptr(this_ptr);
32658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32660         this_ptr_conv.is_owned = false;
32661         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
32662         return ret_conv;
32663 }
32664
32665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32666         LDKChannelDetails this_ptr_conv;
32667         this_ptr_conv.inner = untag_ptr(this_ptr);
32668         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32670         this_ptr_conv.is_owned = false;
32671         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
32672 }
32673
32674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
32675         LDKChannelDetails this_ptr_conv;
32676         this_ptr_conv.inner = untag_ptr(this_ptr);
32677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32679         this_ptr_conv.is_owned = false;
32680         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
32681         return ret_conv;
32682 }
32683
32684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32685         LDKChannelDetails this_ptr_conv;
32686         this_ptr_conv.inner = untag_ptr(this_ptr);
32687         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32689         this_ptr_conv.is_owned = false;
32690         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
32691 }
32692
32693 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
32694         LDKChannelDetails this_ptr_conv;
32695         this_ptr_conv.inner = untag_ptr(this_ptr);
32696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32698         this_ptr_conv.is_owned = false;
32699         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
32700         return ret_conv;
32701 }
32702
32703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean 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         ChannelDetails_set_is_usable(&this_ptr_conv, val);
32710 }
32711
32712 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
32713         LDKChannelDetails this_ptr_conv;
32714         this_ptr_conv.inner = untag_ptr(this_ptr);
32715         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32717         this_ptr_conv.is_owned = false;
32718         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
32719         return ret_conv;
32720 }
32721
32722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32723         LDKChannelDetails this_ptr_conv;
32724         this_ptr_conv.inner = untag_ptr(this_ptr);
32725         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32727         this_ptr_conv.is_owned = false;
32728         ChannelDetails_set_is_public(&this_ptr_conv, val);
32729 }
32730
32731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32732         LDKChannelDetails this_ptr_conv;
32733         this_ptr_conv.inner = untag_ptr(this_ptr);
32734         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32736         this_ptr_conv.is_owned = false;
32737         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32738         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
32739         int64_t ret_ref = tag_ptr(ret_copy, true);
32740         return ret_ref;
32741 }
32742
32743 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) {
32744         LDKChannelDetails this_ptr_conv;
32745         this_ptr_conv.inner = untag_ptr(this_ptr);
32746         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32748         this_ptr_conv.is_owned = false;
32749         void* val_ptr = untag_ptr(val);
32750         CHECK_ACCESS(val_ptr);
32751         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32752         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32753         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
32754 }
32755
32756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32757         LDKChannelDetails this_ptr_conv;
32758         this_ptr_conv.inner = untag_ptr(this_ptr);
32759         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32761         this_ptr_conv.is_owned = false;
32762         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32763         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
32764         int64_t ret_ref = tag_ptr(ret_copy, true);
32765         return ret_ref;
32766 }
32767
32768 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) {
32769         LDKChannelDetails this_ptr_conv;
32770         this_ptr_conv.inner = untag_ptr(this_ptr);
32771         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32773         this_ptr_conv.is_owned = false;
32774         void* val_ptr = untag_ptr(val);
32775         CHECK_ACCESS(val_ptr);
32776         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32777         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32778         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
32779 }
32780
32781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
32782         LDKChannelDetails this_ptr_conv;
32783         this_ptr_conv.inner = untag_ptr(this_ptr);
32784         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32786         this_ptr_conv.is_owned = false;
32787         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
32788         int64_t ret_ref = 0;
32789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32790         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32791         return ret_ref;
32792 }
32793
32794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32795         LDKChannelDetails this_ptr_conv;
32796         this_ptr_conv.inner = untag_ptr(this_ptr);
32797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32799         this_ptr_conv.is_owned = false;
32800         LDKChannelConfig val_conv;
32801         val_conv.inner = untag_ptr(val);
32802         val_conv.is_owned = ptr_is_owned(val);
32803         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32804         val_conv = ChannelConfig_clone(&val_conv);
32805         ChannelDetails_set_config(&this_ptr_conv, val_conv);
32806 }
32807
32808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t channel_type_arg, int64_t short_channel_id_arg, int64_t outbound_scid_alias_arg, int64_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int8_tArray user_channel_id_arg, int64_t feerate_sat_per_1000_weight_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t next_outbound_htlc_limit_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t confirmations_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_channel_ready_arg, jboolean is_usable_arg, jboolean is_public_arg, int64_t inbound_htlc_minimum_msat_arg, int64_t inbound_htlc_maximum_msat_arg, int64_t config_arg) {
32809         LDKThirtyTwoBytes channel_id_arg_ref;
32810         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32811         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32812         LDKChannelCounterparty counterparty_arg_conv;
32813         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
32814         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
32815         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
32816         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
32817         LDKOutPoint funding_txo_arg_conv;
32818         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
32819         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
32820         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
32821         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
32822         LDKChannelTypeFeatures channel_type_arg_conv;
32823         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
32824         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
32825         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
32826         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
32827         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
32828         CHECK_ACCESS(short_channel_id_arg_ptr);
32829         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
32830         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
32831         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
32832         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
32833         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
32834         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
32835         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
32836         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
32837         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
32838         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
32839         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
32840         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
32841         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
32842         LDKU128 user_channel_id_arg_ref;
32843         CHECK((*env)->GetArrayLength(env, user_channel_id_arg) == 16);
32844         (*env)->GetByteArrayRegion(env, user_channel_id_arg, 0, 16, user_channel_id_arg_ref.le_bytes);
32845         void* feerate_sat_per_1000_weight_arg_ptr = untag_ptr(feerate_sat_per_1000_weight_arg);
32846         CHECK_ACCESS(feerate_sat_per_1000_weight_arg_ptr);
32847         LDKCOption_u32Z feerate_sat_per_1000_weight_arg_conv = *(LDKCOption_u32Z*)(feerate_sat_per_1000_weight_arg_ptr);
32848         feerate_sat_per_1000_weight_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(feerate_sat_per_1000_weight_arg));
32849         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
32850         CHECK_ACCESS(confirmations_required_arg_ptr);
32851         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
32852         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
32853         void* confirmations_arg_ptr = untag_ptr(confirmations_arg);
32854         CHECK_ACCESS(confirmations_arg_ptr);
32855         LDKCOption_u32Z confirmations_arg_conv = *(LDKCOption_u32Z*)(confirmations_arg_ptr);
32856         confirmations_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_arg));
32857         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
32858         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
32859         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
32860         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
32861         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
32862         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
32863         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
32864         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
32865         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
32866         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
32867         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
32868         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
32869         LDKChannelConfig config_arg_conv;
32870         config_arg_conv.inner = untag_ptr(config_arg);
32871         config_arg_conv.is_owned = ptr_is_owned(config_arg);
32872         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
32873         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
32874         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, outbound_scid_alias_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg_ref, feerate_sat_per_1000_weight_arg_conv, balance_msat_arg, outbound_capacity_msat_arg, next_outbound_htlc_limit_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, confirmations_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_channel_ready_arg, is_usable_arg, is_public_arg, inbound_htlc_minimum_msat_arg_conv, inbound_htlc_maximum_msat_arg_conv, config_arg_conv);
32875         int64_t ret_ref = 0;
32876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32877         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32878         return ret_ref;
32879 }
32880
32881 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
32882         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
32883         int64_t ret_ref = 0;
32884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32885         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32886         return ret_ref;
32887 }
32888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32889         LDKChannelDetails arg_conv;
32890         arg_conv.inner = untag_ptr(arg);
32891         arg_conv.is_owned = ptr_is_owned(arg);
32892         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32893         arg_conv.is_owned = false;
32894         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
32895         return ret_conv;
32896 }
32897
32898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32899         LDKChannelDetails orig_conv;
32900         orig_conv.inner = untag_ptr(orig);
32901         orig_conv.is_owned = ptr_is_owned(orig);
32902         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32903         orig_conv.is_owned = false;
32904         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
32905         int64_t ret_ref = 0;
32906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32907         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32908         return ret_ref;
32909 }
32910
32911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32912         LDKChannelDetails this_arg_conv;
32913         this_arg_conv.inner = untag_ptr(this_arg);
32914         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32916         this_arg_conv.is_owned = false;
32917         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32918         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
32919         int64_t ret_ref = tag_ptr(ret_copy, true);
32920         return ret_ref;
32921 }
32922
32923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32924         LDKChannelDetails this_arg_conv;
32925         this_arg_conv.inner = untag_ptr(this_arg);
32926         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32928         this_arg_conv.is_owned = false;
32929         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32930         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
32931         int64_t ret_ref = tag_ptr(ret_copy, true);
32932         return ret_ref;
32933 }
32934
32935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32936         if (!ptr_is_owned(this_ptr)) return;
32937         void* this_ptr_ptr = untag_ptr(this_ptr);
32938         CHECK_ACCESS(this_ptr_ptr);
32939         LDKRecentPaymentDetails this_ptr_conv = *(LDKRecentPaymentDetails*)(this_ptr_ptr);
32940         FREE(untag_ptr(this_ptr));
32941         RecentPaymentDetails_free(this_ptr_conv);
32942 }
32943
32944 static inline uint64_t RecentPaymentDetails_clone_ptr(LDKRecentPaymentDetails *NONNULL_PTR arg) {
32945         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32946         *ret_copy = RecentPaymentDetails_clone(arg);
32947         int64_t ret_ref = tag_ptr(ret_copy, true);
32948         return ret_ref;
32949 }
32950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32951         LDKRecentPaymentDetails* arg_conv = (LDKRecentPaymentDetails*)untag_ptr(arg);
32952         int64_t ret_conv = RecentPaymentDetails_clone_ptr(arg_conv);
32953         return ret_conv;
32954 }
32955
32956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32957         LDKRecentPaymentDetails* orig_conv = (LDKRecentPaymentDetails*)untag_ptr(orig);
32958         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32959         *ret_copy = RecentPaymentDetails_clone(orig_conv);
32960         int64_t ret_ref = tag_ptr(ret_copy, true);
32961         return ret_ref;
32962 }
32963
32964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1pending(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t total_msat) {
32965         LDKThirtyTwoBytes payment_hash_ref;
32966         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32967         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32968         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32969         *ret_copy = RecentPaymentDetails_pending(payment_hash_ref, total_msat);
32970         int64_t ret_ref = tag_ptr(ret_copy, true);
32971         return ret_ref;
32972 }
32973
32974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1fulfilled(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
32975         LDKThirtyTwoBytes payment_hash_ref;
32976         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32977         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32978         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32979         *ret_copy = RecentPaymentDetails_fulfilled(payment_hash_ref);
32980         int64_t ret_ref = tag_ptr(ret_copy, true);
32981         return ret_ref;
32982 }
32983
32984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1abandoned(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
32985         LDKThirtyTwoBytes payment_hash_ref;
32986         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32987         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32988         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32989         *ret_copy = RecentPaymentDetails_abandoned(payment_hash_ref);
32990         int64_t ret_ref = tag_ptr(ret_copy, true);
32991         return ret_ref;
32992 }
32993
32994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32995         LDKPhantomRouteHints this_obj_conv;
32996         this_obj_conv.inner = untag_ptr(this_obj);
32997         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32999         PhantomRouteHints_free(this_obj_conv);
33000 }
33001
33002 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
33003         LDKPhantomRouteHints this_ptr_conv;
33004         this_ptr_conv.inner = untag_ptr(this_ptr);
33005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33007         this_ptr_conv.is_owned = false;
33008         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
33009         int64_tArray ret_arr = NULL;
33010         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33011         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33012         for (size_t q = 0; q < ret_var.datalen; q++) {
33013                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33014                 int64_t ret_conv_16_ref = 0;
33015                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33016                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33017                 ret_arr_ptr[q] = ret_conv_16_ref;
33018         }
33019         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33020         FREE(ret_var.data);
33021         return ret_arr;
33022 }
33023
33024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
33025         LDKPhantomRouteHints this_ptr_conv;
33026         this_ptr_conv.inner = untag_ptr(this_ptr);
33027         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33029         this_ptr_conv.is_owned = false;
33030         LDKCVec_ChannelDetailsZ val_constr;
33031         val_constr.datalen = (*env)->GetArrayLength(env, val);
33032         if (val_constr.datalen > 0)
33033                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
33034         else
33035                 val_constr.data = NULL;
33036         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
33037         for (size_t q = 0; q < val_constr.datalen; q++) {
33038                 int64_t val_conv_16 = val_vals[q];
33039                 LDKChannelDetails val_conv_16_conv;
33040                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
33041                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
33042                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
33043                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
33044                 val_constr.data[q] = val_conv_16_conv;
33045         }
33046         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
33047         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
33048 }
33049
33050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
33051         LDKPhantomRouteHints this_ptr_conv;
33052         this_ptr_conv.inner = untag_ptr(this_ptr);
33053         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33055         this_ptr_conv.is_owned = false;
33056         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
33057         return ret_conv;
33058 }
33059
33060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33061         LDKPhantomRouteHints this_ptr_conv;
33062         this_ptr_conv.inner = untag_ptr(this_ptr);
33063         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33065         this_ptr_conv.is_owned = false;
33066         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
33067 }
33068
33069 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33070         LDKPhantomRouteHints this_ptr_conv;
33071         this_ptr_conv.inner = untag_ptr(this_ptr);
33072         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33074         this_ptr_conv.is_owned = false;
33075         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33076         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
33077         return ret_arr;
33078 }
33079
33080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33081         LDKPhantomRouteHints this_ptr_conv;
33082         this_ptr_conv.inner = untag_ptr(this_ptr);
33083         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33085         this_ptr_conv.is_owned = false;
33086         LDKPublicKey val_ref;
33087         CHECK((*env)->GetArrayLength(env, val) == 33);
33088         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33089         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
33090 }
33091
33092 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) {
33093         LDKCVec_ChannelDetailsZ channels_arg_constr;
33094         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
33095         if (channels_arg_constr.datalen > 0)
33096                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
33097         else
33098                 channels_arg_constr.data = NULL;
33099         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
33100         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
33101                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
33102                 LDKChannelDetails channels_arg_conv_16_conv;
33103                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
33104                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
33105                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
33106                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
33107                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
33108         }
33109         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
33110         LDKPublicKey real_node_pubkey_arg_ref;
33111         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
33112         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
33113         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
33114         int64_t ret_ref = 0;
33115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33116         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33117         return ret_ref;
33118 }
33119
33120 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
33121         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
33122         int64_t ret_ref = 0;
33123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33124         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33125         return ret_ref;
33126 }
33127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33128         LDKPhantomRouteHints arg_conv;
33129         arg_conv.inner = untag_ptr(arg);
33130         arg_conv.is_owned = ptr_is_owned(arg);
33131         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33132         arg_conv.is_owned = false;
33133         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
33134         return ret_conv;
33135 }
33136
33137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33138         LDKPhantomRouteHints orig_conv;
33139         orig_conv.inner = untag_ptr(orig);
33140         orig_conv.is_owned = ptr_is_owned(orig);
33141         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33142         orig_conv.is_owned = false;
33143         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
33144         int64_t ret_ref = 0;
33145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33147         return ret_ref;
33148 }
33149
33150 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) {
33151         void* fee_est_ptr = untag_ptr(fee_est);
33152         CHECK_ACCESS(fee_est_ptr);
33153         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
33154         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
33155                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33156                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
33157         }
33158         void* chain_monitor_ptr = untag_ptr(chain_monitor);
33159         CHECK_ACCESS(chain_monitor_ptr);
33160         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
33161         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
33162                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33163                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
33164         }
33165         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
33166         CHECK_ACCESS(tx_broadcaster_ptr);
33167         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
33168         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33169                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33170                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
33171         }
33172         void* router_ptr = untag_ptr(router);
33173         CHECK_ACCESS(router_ptr);
33174         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
33175         if (router_conv.free == LDKRouter_JCalls_free) {
33176                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33177                 LDKRouter_JCalls_cloned(&router_conv);
33178         }
33179         void* logger_ptr = untag_ptr(logger);
33180         CHECK_ACCESS(logger_ptr);
33181         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33182         if (logger_conv.free == LDKLogger_JCalls_free) {
33183                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33184                 LDKLogger_JCalls_cloned(&logger_conv);
33185         }
33186         void* entropy_source_ptr = untag_ptr(entropy_source);
33187         CHECK_ACCESS(entropy_source_ptr);
33188         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
33189         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
33190                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33191                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
33192         }
33193         void* node_signer_ptr = untag_ptr(node_signer);
33194         CHECK_ACCESS(node_signer_ptr);
33195         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
33196         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
33197                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33198                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
33199         }
33200         void* signer_provider_ptr = untag_ptr(signer_provider);
33201         CHECK_ACCESS(signer_provider_ptr);
33202         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
33203         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
33204                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33205                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
33206         }
33207         LDKUserConfig config_conv;
33208         config_conv.inner = untag_ptr(config);
33209         config_conv.is_owned = ptr_is_owned(config);
33210         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
33211         config_conv = UserConfig_clone(&config_conv);
33212         LDKChainParameters params_conv;
33213         params_conv.inner = untag_ptr(params);
33214         params_conv.is_owned = ptr_is_owned(params);
33215         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
33216         params_conv = ChainParameters_clone(&params_conv);
33217         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);
33218         int64_t ret_ref = 0;
33219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33220         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33221         return ret_ref;
33222 }
33223
33224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
33225         LDKChannelManager this_arg_conv;
33226         this_arg_conv.inner = untag_ptr(this_arg);
33227         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33229         this_arg_conv.is_owned = false;
33230         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
33231         int64_t ret_ref = 0;
33232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33233         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33234         return ret_ref;
33235 }
33236
33237 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) {
33238         LDKChannelManager this_arg_conv;
33239         this_arg_conv.inner = untag_ptr(this_arg);
33240         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33242         this_arg_conv.is_owned = false;
33243         LDKPublicKey their_network_key_ref;
33244         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
33245         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
33246         LDKU128 user_channel_id_ref;
33247         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33248         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33249         LDKUserConfig override_config_conv;
33250         override_config_conv.inner = untag_ptr(override_config);
33251         override_config_conv.is_owned = ptr_is_owned(override_config);
33252         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
33253         override_config_conv = UserConfig_clone(&override_config_conv);
33254         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
33255         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id_ref, override_config_conv);
33256         return tag_ptr(ret_conv, true);
33257 }
33258
33259 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
33260         LDKChannelManager this_arg_conv;
33261         this_arg_conv.inner = untag_ptr(this_arg);
33262         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33264         this_arg_conv.is_owned = false;
33265         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
33266         int64_tArray ret_arr = NULL;
33267         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33268         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33269         for (size_t q = 0; q < ret_var.datalen; q++) {
33270                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33271                 int64_t ret_conv_16_ref = 0;
33272                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33273                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33274                 ret_arr_ptr[q] = ret_conv_16_ref;
33275         }
33276         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33277         FREE(ret_var.data);
33278         return ret_arr;
33279 }
33280
33281 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
33282         LDKChannelManager this_arg_conv;
33283         this_arg_conv.inner = untag_ptr(this_arg);
33284         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33286         this_arg_conv.is_owned = false;
33287         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
33288         int64_tArray ret_arr = NULL;
33289         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33290         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33291         for (size_t q = 0; q < ret_var.datalen; q++) {
33292                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33293                 int64_t ret_conv_16_ref = 0;
33294                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33295                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33296                 ret_arr_ptr[q] = ret_conv_16_ref;
33297         }
33298         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33299         FREE(ret_var.data);
33300         return ret_arr;
33301 }
33302
33303 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels_1with_1counterparty(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray counterparty_node_id) {
33304         LDKChannelManager this_arg_conv;
33305         this_arg_conv.inner = untag_ptr(this_arg);
33306         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33308         this_arg_conv.is_owned = false;
33309         LDKPublicKey counterparty_node_id_ref;
33310         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33311         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33312         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels_with_counterparty(&this_arg_conv, counterparty_node_id_ref);
33313         int64_tArray ret_arr = NULL;
33314         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33315         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33316         for (size_t q = 0; q < ret_var.datalen; q++) {
33317                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33318                 int64_t ret_conv_16_ref = 0;
33319                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33320                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33321                 ret_arr_ptr[q] = ret_conv_16_ref;
33322         }
33323         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33324         FREE(ret_var.data);
33325         return ret_arr;
33326 }
33327
33328 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1recent_1payments(JNIEnv *env, jclass clz, int64_t this_arg) {
33329         LDKChannelManager this_arg_conv;
33330         this_arg_conv.inner = untag_ptr(this_arg);
33331         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33333         this_arg_conv.is_owned = false;
33334         LDKCVec_RecentPaymentDetailsZ ret_var = ChannelManager_list_recent_payments(&this_arg_conv);
33335         int64_tArray ret_arr = NULL;
33336         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33337         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33338         for (size_t w = 0; w < ret_var.datalen; w++) {
33339                 LDKRecentPaymentDetails *ret_conv_22_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
33340                 *ret_conv_22_copy = ret_var.data[w];
33341                 int64_t ret_conv_22_ref = tag_ptr(ret_conv_22_copy, true);
33342                 ret_arr_ptr[w] = ret_conv_22_ref;
33343         }
33344         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33345         FREE(ret_var.data);
33346         return ret_arr;
33347 }
33348
33349 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) {
33350         LDKChannelManager this_arg_conv;
33351         this_arg_conv.inner = untag_ptr(this_arg);
33352         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33354         this_arg_conv.is_owned = false;
33355         uint8_t channel_id_arr[32];
33356         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33357         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33358         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33359         LDKPublicKey counterparty_node_id_ref;
33360         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33361         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33362         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33363         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33364         return tag_ptr(ret_conv, true);
33365 }
33366
33367 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) {
33368         LDKChannelManager this_arg_conv;
33369         this_arg_conv.inner = untag_ptr(this_arg);
33370         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33372         this_arg_conv.is_owned = false;
33373         uint8_t channel_id_arr[32];
33374         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33375         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33376         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33377         LDKPublicKey counterparty_node_id_ref;
33378         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33379         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33380         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33381         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
33382         return tag_ptr(ret_conv, true);
33383 }
33384
33385 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) {
33386         LDKChannelManager this_arg_conv;
33387         this_arg_conv.inner = untag_ptr(this_arg);
33388         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33390         this_arg_conv.is_owned = false;
33391         uint8_t channel_id_arr[32];
33392         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33393         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33394         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33395         LDKPublicKey counterparty_node_id_ref;
33396         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33397         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33398         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33399         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33400         return tag_ptr(ret_conv, true);
33401 }
33402
33403 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) {
33404         LDKChannelManager this_arg_conv;
33405         this_arg_conv.inner = untag_ptr(this_arg);
33406         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33408         this_arg_conv.is_owned = false;
33409         uint8_t channel_id_arr[32];
33410         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33411         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33412         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33413         LDKPublicKey counterparty_node_id_ref;
33414         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33415         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33416         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33417         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33418         return tag_ptr(ret_conv, true);
33419 }
33420
33421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
33422         LDKChannelManager this_arg_conv;
33423         this_arg_conv.inner = untag_ptr(this_arg);
33424         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33426         this_arg_conv.is_owned = false;
33427         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
33428 }
33429
33430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
33431         LDKChannelManager this_arg_conv;
33432         this_arg_conv.inner = untag_ptr(this_arg);
33433         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33435         this_arg_conv.is_owned = false;
33436         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
33437 }
33438
33439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment_1with_1route(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id) {
33440         LDKChannelManager this_arg_conv;
33441         this_arg_conv.inner = untag_ptr(this_arg);
33442         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33444         this_arg_conv.is_owned = false;
33445         LDKRoute route_conv;
33446         route_conv.inner = untag_ptr(route);
33447         route_conv.is_owned = ptr_is_owned(route);
33448         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
33449         route_conv.is_owned = false;
33450         LDKThirtyTwoBytes payment_hash_ref;
33451         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33452         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33453         LDKRecipientOnionFields recipient_onion_conv;
33454         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33455         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33456         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33457         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33458         LDKThirtyTwoBytes payment_id_ref;
33459         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33460         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33461         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
33462         *ret_conv = ChannelManager_send_payment_with_route(&this_arg_conv, &route_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref);
33463         return tag_ptr(ret_conv, true);
33464 }
33465
33466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id, int64_t route_params, int64_t retry_strategy) {
33467         LDKChannelManager this_arg_conv;
33468         this_arg_conv.inner = untag_ptr(this_arg);
33469         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33471         this_arg_conv.is_owned = false;
33472         LDKThirtyTwoBytes payment_hash_ref;
33473         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33474         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33475         LDKRecipientOnionFields recipient_onion_conv;
33476         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33477         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33478         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33479         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33480         LDKThirtyTwoBytes payment_id_ref;
33481         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33482         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33483         LDKRouteParameters route_params_conv;
33484         route_params_conv.inner = untag_ptr(route_params);
33485         route_params_conv.is_owned = ptr_is_owned(route_params);
33486         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
33487         route_params_conv = RouteParameters_clone(&route_params_conv);
33488         void* retry_strategy_ptr = untag_ptr(retry_strategy);
33489         CHECK_ACCESS(retry_strategy_ptr);
33490         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
33491         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
33492         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
33493         *ret_conv = ChannelManager_send_payment(&this_arg_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref, route_params_conv, retry_strategy_conv);
33494         return tag_ptr(ret_conv, true);
33495 }
33496
33497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
33498         LDKChannelManager this_arg_conv;
33499         this_arg_conv.inner = untag_ptr(this_arg);
33500         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33502         this_arg_conv.is_owned = false;
33503         LDKThirtyTwoBytes payment_id_ref;
33504         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33505         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33506         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
33507 }
33508
33509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1spontaneous_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_preimage, int64_t recipient_onion, int8_tArray payment_id) {
33510         LDKChannelManager this_arg_conv;
33511         this_arg_conv.inner = untag_ptr(this_arg);
33512         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33514         this_arg_conv.is_owned = false;
33515         LDKRoute route_conv;
33516         route_conv.inner = untag_ptr(route);
33517         route_conv.is_owned = ptr_is_owned(route);
33518         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
33519         route_conv.is_owned = false;
33520         LDKThirtyTwoBytes payment_preimage_ref;
33521         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33522         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33523         LDKRecipientOnionFields recipient_onion_conv;
33524         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33525         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33526         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33527         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33528         LDKThirtyTwoBytes payment_id_ref;
33529         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33530         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33531         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
33532         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref, recipient_onion_conv, payment_id_ref);
33533         return tag_ptr(ret_conv, true);
33534 }
33535
33536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1spontaneous_1payment_1with_1retry(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage, int64_t recipient_onion, int8_tArray payment_id, int64_t route_params, int64_t retry_strategy) {
33537         LDKChannelManager this_arg_conv;
33538         this_arg_conv.inner = untag_ptr(this_arg);
33539         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33541         this_arg_conv.is_owned = false;
33542         LDKThirtyTwoBytes payment_preimage_ref;
33543         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33544         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33545         LDKRecipientOnionFields recipient_onion_conv;
33546         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33547         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33548         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33549         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33550         LDKThirtyTwoBytes payment_id_ref;
33551         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33552         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33553         LDKRouteParameters route_params_conv;
33554         route_params_conv.inner = untag_ptr(route_params);
33555         route_params_conv.is_owned = ptr_is_owned(route_params);
33556         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
33557         route_params_conv = RouteParameters_clone(&route_params_conv);
33558         void* retry_strategy_ptr = untag_ptr(retry_strategy);
33559         CHECK_ACCESS(retry_strategy_ptr);
33560         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
33561         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
33562         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
33563         *ret_conv = ChannelManager_send_spontaneous_payment_with_retry(&this_arg_conv, payment_preimage_ref, recipient_onion_conv, payment_id_ref, route_params_conv, retry_strategy_conv);
33564         return tag_ptr(ret_conv, true);
33565 }
33566
33567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path) {
33568         LDKChannelManager this_arg_conv;
33569         this_arg_conv.inner = untag_ptr(this_arg);
33570         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33572         this_arg_conv.is_owned = false;
33573         LDKPath path_conv;
33574         path_conv.inner = untag_ptr(path);
33575         path_conv.is_owned = ptr_is_owned(path);
33576         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
33577         path_conv = Path_clone(&path_conv);
33578         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
33579         *ret_conv = ChannelManager_send_probe(&this_arg_conv, path_conv);
33580         return tag_ptr(ret_conv, true);
33581 }
33582
33583 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) {
33584         LDKChannelManager this_arg_conv;
33585         this_arg_conv.inner = untag_ptr(this_arg);
33586         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33588         this_arg_conv.is_owned = false;
33589         uint8_t temporary_channel_id_arr[32];
33590         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33591         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33592         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33593         LDKPublicKey counterparty_node_id_ref;
33594         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33595         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33596         LDKTransaction funding_transaction_ref;
33597         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
33598         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
33599         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
33600         funding_transaction_ref.data_is_owned = true;
33601         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33602         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
33603         return tag_ptr(ret_conv, true);
33604 }
33605
33606 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) {
33607         LDKChannelManager this_arg_conv;
33608         this_arg_conv.inner = untag_ptr(this_arg);
33609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33611         this_arg_conv.is_owned = false;
33612         LDKPublicKey counterparty_node_id_ref;
33613         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33614         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33615         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
33616         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
33617         if (channel_ids_constr.datalen > 0)
33618                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
33619         else
33620                 channel_ids_constr.data = NULL;
33621         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
33622                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
33623                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
33624                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
33625                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
33626                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
33627         }
33628         LDKChannelConfig config_conv;
33629         config_conv.inner = untag_ptr(config);
33630         config_conv.is_owned = ptr_is_owned(config);
33631         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
33632         config_conv.is_owned = false;
33633         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33634         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
33635         return tag_ptr(ret_conv, true);
33636 }
33637
33638 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) {
33639         LDKChannelManager this_arg_conv;
33640         this_arg_conv.inner = untag_ptr(this_arg);
33641         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33643         this_arg_conv.is_owned = false;
33644         LDKThirtyTwoBytes intercept_id_ref;
33645         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33646         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33647         uint8_t next_hop_channel_id_arr[32];
33648         CHECK((*env)->GetArrayLength(env, next_hop_channel_id) == 32);
33649         (*env)->GetByteArrayRegion(env, next_hop_channel_id, 0, 32, next_hop_channel_id_arr);
33650         uint8_t (*next_hop_channel_id_ref)[32] = &next_hop_channel_id_arr;
33651         LDKPublicKey next_node_id_ref;
33652         CHECK((*env)->GetArrayLength(env, next_node_id) == 33);
33653         (*env)->GetByteArrayRegion(env, next_node_id, 0, 33, next_node_id_ref.compressed_form);
33654         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33655         *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);
33656         return tag_ptr(ret_conv, true);
33657 }
33658
33659 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) {
33660         LDKChannelManager this_arg_conv;
33661         this_arg_conv.inner = untag_ptr(this_arg);
33662         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33664         this_arg_conv.is_owned = false;
33665         LDKThirtyTwoBytes intercept_id_ref;
33666         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33667         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33668         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33669         *ret_conv = ChannelManager_fail_intercepted_htlc(&this_arg_conv, intercept_id_ref);
33670         return tag_ptr(ret_conv, true);
33671 }
33672
33673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
33674         LDKChannelManager this_arg_conv;
33675         this_arg_conv.inner = untag_ptr(this_arg);
33676         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33678         this_arg_conv.is_owned = false;
33679         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
33680 }
33681
33682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
33683         LDKChannelManager this_arg_conv;
33684         this_arg_conv.inner = untag_ptr(this_arg);
33685         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33687         this_arg_conv.is_owned = false;
33688         ChannelManager_timer_tick_occurred(&this_arg_conv);
33689 }
33690
33691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
33692         LDKChannelManager this_arg_conv;
33693         this_arg_conv.inner = untag_ptr(this_arg);
33694         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33696         this_arg_conv.is_owned = false;
33697         uint8_t payment_hash_arr[32];
33698         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33699         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
33700         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
33701         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
33702 }
33703
33704 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) {
33705         LDKChannelManager this_arg_conv;
33706         this_arg_conv.inner = untag_ptr(this_arg);
33707         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33709         this_arg_conv.is_owned = false;
33710         uint8_t payment_hash_arr[32];
33711         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33712         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
33713         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
33714         LDKFailureCode failure_code_conv = LDKFailureCode_from_java(env, failure_code);
33715         ChannelManager_fail_htlc_backwards_with_reason(&this_arg_conv, payment_hash_ref, failure_code_conv);
33716 }
33717
33718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
33719         LDKChannelManager this_arg_conv;
33720         this_arg_conv.inner = untag_ptr(this_arg);
33721         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33723         this_arg_conv.is_owned = false;
33724         LDKThirtyTwoBytes payment_preimage_ref;
33725         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33726         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33727         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
33728 }
33729
33730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
33731         LDKChannelManager this_arg_conv;
33732         this_arg_conv.inner = untag_ptr(this_arg);
33733         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33735         this_arg_conv.is_owned = false;
33736         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33737         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
33738         return ret_arr;
33739 }
33740
33741 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) {
33742         LDKChannelManager this_arg_conv;
33743         this_arg_conv.inner = untag_ptr(this_arg);
33744         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33746         this_arg_conv.is_owned = false;
33747         uint8_t temporary_channel_id_arr[32];
33748         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33749         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33750         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33751         LDKPublicKey counterparty_node_id_ref;
33752         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33753         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33754         LDKU128 user_channel_id_ref;
33755         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33756         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33757         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33758         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id_ref);
33759         return tag_ptr(ret_conv, true);
33760 }
33761
33762 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) {
33763         LDKChannelManager this_arg_conv;
33764         this_arg_conv.inner = untag_ptr(this_arg);
33765         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33767         this_arg_conv.is_owned = false;
33768         uint8_t temporary_channel_id_arr[32];
33769         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33770         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33771         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33772         LDKPublicKey counterparty_node_id_ref;
33773         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33774         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33775         LDKU128 user_channel_id_ref;
33776         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33777         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33778         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33779         *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);
33780         return tag_ptr(ret_conv, true);
33781 }
33782
33783 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) {
33784         LDKChannelManager this_arg_conv;
33785         this_arg_conv.inner = untag_ptr(this_arg);
33786         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33788         this_arg_conv.is_owned = false;
33789         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33790         CHECK_ACCESS(min_value_msat_ptr);
33791         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33792         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33793         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
33794         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
33795         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
33796         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
33797         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
33798         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
33799         return tag_ptr(ret_conv, true);
33800 }
33801
33802 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) {
33803         LDKChannelManager this_arg_conv;
33804         this_arg_conv.inner = untag_ptr(this_arg);
33805         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33807         this_arg_conv.is_owned = false;
33808         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33809         CHECK_ACCESS(min_value_msat_ptr);
33810         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33811         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33812         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
33813         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
33814         return tag_ptr(ret_conv, true);
33815 }
33816
33817 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) {
33818         LDKChannelManager this_arg_conv;
33819         this_arg_conv.inner = untag_ptr(this_arg);
33820         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33822         this_arg_conv.is_owned = false;
33823         LDKThirtyTwoBytes payment_hash_ref;
33824         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33825         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33826         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33827         CHECK_ACCESS(min_value_msat_ptr);
33828         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33829         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33830         void* min_final_cltv_expiry_ptr = untag_ptr(min_final_cltv_expiry);
33831         CHECK_ACCESS(min_final_cltv_expiry_ptr);
33832         LDKCOption_u16Z min_final_cltv_expiry_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_ptr);
33833         min_final_cltv_expiry_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry));
33834         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
33835         *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);
33836         return tag_ptr(ret_conv, true);
33837 }
33838
33839 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) {
33840         LDKChannelManager this_arg_conv;
33841         this_arg_conv.inner = untag_ptr(this_arg);
33842         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33844         this_arg_conv.is_owned = false;
33845         LDKThirtyTwoBytes payment_hash_ref;
33846         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33847         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33848         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33849         CHECK_ACCESS(min_value_msat_ptr);
33850         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33851         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33852         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
33853         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
33854         return tag_ptr(ret_conv, true);
33855 }
33856
33857 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) {
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         LDKThirtyTwoBytes payment_hash_ref;
33864         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33865         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33866         LDKThirtyTwoBytes payment_secret_ref;
33867         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
33868         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
33869         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
33870         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
33871         return tag_ptr(ret_conv, true);
33872 }
33873
33874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33875         LDKChannelManager this_arg_conv;
33876         this_arg_conv.inner = untag_ptr(this_arg);
33877         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33879         this_arg_conv.is_owned = false;
33880         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
33881         return ret_conv;
33882 }
33883
33884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
33885         LDKChannelManager this_arg_conv;
33886         this_arg_conv.inner = untag_ptr(this_arg);
33887         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33889         this_arg_conv.is_owned = false;
33890         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
33891         int64_t ret_ref = 0;
33892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33893         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33894         return ret_ref;
33895 }
33896
33897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1intercept_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33898         LDKChannelManager this_arg_conv;
33899         this_arg_conv.inner = untag_ptr(this_arg);
33900         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33902         this_arg_conv.is_owned = false;
33903         int64_t ret_conv = ChannelManager_get_intercept_scid(&this_arg_conv);
33904         return ret_conv;
33905 }
33906
33907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1compute_1inflight_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg) {
33908         LDKChannelManager this_arg_conv;
33909         this_arg_conv.inner = untag_ptr(this_arg);
33910         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33912         this_arg_conv.is_owned = false;
33913         LDKInFlightHtlcs ret_var = ChannelManager_compute_inflight_htlcs(&this_arg_conv);
33914         int64_t ret_ref = 0;
33915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33916         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33917         return ret_ref;
33918 }
33919
33920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33921         LDKChannelManager this_arg_conv;
33922         this_arg_conv.inner = untag_ptr(this_arg);
33923         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33925         this_arg_conv.is_owned = false;
33926         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33927         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
33928         return tag_ptr(ret_ret, true);
33929 }
33930
33931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33932         LDKChannelManager this_arg_conv;
33933         this_arg_conv.inner = untag_ptr(this_arg);
33934         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33936         this_arg_conv.is_owned = false;
33937         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
33938         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
33939         return tag_ptr(ret_ret, true);
33940 }
33941
33942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
33943         LDKChannelManager this_arg_conv;
33944         this_arg_conv.inner = untag_ptr(this_arg);
33945         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33947         this_arg_conv.is_owned = false;
33948         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
33949         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
33950         return tag_ptr(ret_ret, true);
33951 }
33952
33953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
33954         LDKChannelManager this_arg_conv;
33955         this_arg_conv.inner = untag_ptr(this_arg);
33956         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33958         this_arg_conv.is_owned = false;
33959         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
33960         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
33961         return tag_ptr(ret_ret, true);
33962 }
33963
33964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1persistable_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
33965         LDKChannelManager this_arg_conv;
33966         this_arg_conv.inner = untag_ptr(this_arg);
33967         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33969         this_arg_conv.is_owned = false;
33970         LDKFuture ret_var = ChannelManager_get_persistable_update_future(&this_arg_conv);
33971         int64_t ret_ref = 0;
33972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33973         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33974         return ret_ref;
33975 }
33976
33977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
33978         LDKChannelManager this_arg_conv;
33979         this_arg_conv.inner = untag_ptr(this_arg);
33980         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33982         this_arg_conv.is_owned = false;
33983         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
33984         int64_t ret_ref = 0;
33985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33986         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33987         return ret_ref;
33988 }
33989
33990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
33991         LDKChannelManager this_arg_conv;
33992         this_arg_conv.inner = untag_ptr(this_arg);
33993         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33995         this_arg_conv.is_owned = false;
33996         LDKNodeFeatures ret_var = ChannelManager_node_features(&this_arg_conv);
33997         int64_t ret_ref = 0;
33998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33999         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34000         return ret_ref;
34001 }
34002
34003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
34004         LDKChannelManager this_arg_conv;
34005         this_arg_conv.inner = untag_ptr(this_arg);
34006         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34008         this_arg_conv.is_owned = false;
34009         LDKChannelFeatures ret_var = ChannelManager_channel_features(&this_arg_conv);
34010         int64_t ret_ref = 0;
34011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34012         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34013         return ret_ref;
34014 }
34015
34016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1type_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
34017         LDKChannelManager this_arg_conv;
34018         this_arg_conv.inner = untag_ptr(this_arg);
34019         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34021         this_arg_conv.is_owned = false;
34022         LDKChannelTypeFeatures ret_var = ChannelManager_channel_type_features(&this_arg_conv);
34023         int64_t ret_ref = 0;
34024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34025         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34026         return ret_ref;
34027 }
34028
34029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
34030         LDKChannelManager this_arg_conv;
34031         this_arg_conv.inner = untag_ptr(this_arg);
34032         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34034         this_arg_conv.is_owned = false;
34035         LDKInitFeatures ret_var = ChannelManager_init_features(&this_arg_conv);
34036         int64_t ret_ref = 0;
34037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34038         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34039         return ret_ref;
34040 }
34041
34042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
34043         LDKChannelManager this_arg_conv;
34044         this_arg_conv.inner = untag_ptr(this_arg);
34045         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34047         this_arg_conv.is_owned = false;
34048         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
34049         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
34050         return tag_ptr(ret_ret, true);
34051 }
34052
34053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1init_1features(JNIEnv *env, jclass clz, int64_t _config) {
34054         LDKUserConfig _config_conv;
34055         _config_conv.inner = untag_ptr(_config);
34056         _config_conv.is_owned = ptr_is_owned(_config);
34057         CHECK_INNER_FIELD_ACCESS_OR_NULL(_config_conv);
34058         _config_conv.is_owned = false;
34059         LDKInitFeatures ret_var = provided_init_features(&_config_conv);
34060         int64_t ret_ref = 0;
34061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34062         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34063         return ret_ref;
34064 }
34065
34066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
34067         LDKCounterpartyForwardingInfo obj_conv;
34068         obj_conv.inner = untag_ptr(obj);
34069         obj_conv.is_owned = ptr_is_owned(obj);
34070         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34071         obj_conv.is_owned = false;
34072         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
34073         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34074         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34075         CVec_u8Z_free(ret_var);
34076         return ret_arr;
34077 }
34078
34079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34080         LDKu8slice ser_ref;
34081         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34082         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34083         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
34084         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
34085         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34086         return tag_ptr(ret_conv, true);
34087 }
34088
34089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
34090         LDKChannelCounterparty obj_conv;
34091         obj_conv.inner = untag_ptr(obj);
34092         obj_conv.is_owned = ptr_is_owned(obj);
34093         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34094         obj_conv.is_owned = false;
34095         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
34096         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34097         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34098         CVec_u8Z_free(ret_var);
34099         return ret_arr;
34100 }
34101
34102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34103         LDKu8slice ser_ref;
34104         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34105         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34106         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
34107         *ret_conv = ChannelCounterparty_read(ser_ref);
34108         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34109         return tag_ptr(ret_conv, true);
34110 }
34111
34112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
34113         LDKChannelDetails obj_conv;
34114         obj_conv.inner = untag_ptr(obj);
34115         obj_conv.is_owned = ptr_is_owned(obj);
34116         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34117         obj_conv.is_owned = false;
34118         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
34119         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34120         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34121         CVec_u8Z_free(ret_var);
34122         return ret_arr;
34123 }
34124
34125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34126         LDKu8slice ser_ref;
34127         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34128         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34129         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
34130         *ret_conv = ChannelDetails_read(ser_ref);
34131         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34132         return tag_ptr(ret_conv, true);
34133 }
34134
34135 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
34136         LDKPhantomRouteHints obj_conv;
34137         obj_conv.inner = untag_ptr(obj);
34138         obj_conv.is_owned = ptr_is_owned(obj);
34139         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34140         obj_conv.is_owned = false;
34141         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
34142         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34143         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34144         CVec_u8Z_free(ret_var);
34145         return ret_arr;
34146 }
34147
34148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34149         LDKu8slice ser_ref;
34150         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34151         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34152         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
34153         *ret_conv = PhantomRouteHints_read(ser_ref);
34154         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34155         return tag_ptr(ret_conv, true);
34156 }
34157
34158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
34159         LDKChannelManager obj_conv;
34160         obj_conv.inner = untag_ptr(obj);
34161         obj_conv.is_owned = ptr_is_owned(obj);
34162         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34163         obj_conv.is_owned = false;
34164         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
34165         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34166         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34167         CVec_u8Z_free(ret_var);
34168         return ret_arr;
34169 }
34170
34171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34172         LDKChannelManagerReadArgs this_obj_conv;
34173         this_obj_conv.inner = untag_ptr(this_obj);
34174         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34176         ChannelManagerReadArgs_free(this_obj_conv);
34177 }
34178
34179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1entropy_1source(JNIEnv *env, jclass clz, int64_t this_ptr) {
34180         LDKChannelManagerReadArgs this_ptr_conv;
34181         this_ptr_conv.inner = untag_ptr(this_ptr);
34182         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34184         this_ptr_conv.is_owned = false;
34185         // WARNING: This object doesn't live past this scope, needs clone!
34186         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_entropy_source(&this_ptr_conv), false);
34187         return ret_ret;
34188 }
34189
34190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1entropy_1source(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34191         LDKChannelManagerReadArgs this_ptr_conv;
34192         this_ptr_conv.inner = untag_ptr(this_ptr);
34193         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34195         this_ptr_conv.is_owned = false;
34196         void* val_ptr = untag_ptr(val);
34197         CHECK_ACCESS(val_ptr);
34198         LDKEntropySource val_conv = *(LDKEntropySource*)(val_ptr);
34199         if (val_conv.free == LDKEntropySource_JCalls_free) {
34200                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34201                 LDKEntropySource_JCalls_cloned(&val_conv);
34202         }
34203         ChannelManagerReadArgs_set_entropy_source(&this_ptr_conv, val_conv);
34204 }
34205
34206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1node_1signer(JNIEnv *env, jclass clz, int64_t this_ptr) {
34207         LDKChannelManagerReadArgs this_ptr_conv;
34208         this_ptr_conv.inner = untag_ptr(this_ptr);
34209         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34211         this_ptr_conv.is_owned = false;
34212         // WARNING: This object doesn't live past this scope, needs clone!
34213         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_node_signer(&this_ptr_conv), false);
34214         return ret_ret;
34215 }
34216
34217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1node_1signer(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34218         LDKChannelManagerReadArgs this_ptr_conv;
34219         this_ptr_conv.inner = untag_ptr(this_ptr);
34220         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34222         this_ptr_conv.is_owned = false;
34223         void* val_ptr = untag_ptr(val);
34224         CHECK_ACCESS(val_ptr);
34225         LDKNodeSigner val_conv = *(LDKNodeSigner*)(val_ptr);
34226         if (val_conv.free == LDKNodeSigner_JCalls_free) {
34227                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34228                 LDKNodeSigner_JCalls_cloned(&val_conv);
34229         }
34230         ChannelManagerReadArgs_set_node_signer(&this_ptr_conv, val_conv);
34231 }
34232
34233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1signer_1provider(JNIEnv *env, jclass clz, int64_t this_ptr) {
34234         LDKChannelManagerReadArgs this_ptr_conv;
34235         this_ptr_conv.inner = untag_ptr(this_ptr);
34236         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34238         this_ptr_conv.is_owned = false;
34239         // WARNING: This object doesn't live past this scope, needs clone!
34240         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_signer_provider(&this_ptr_conv), false);
34241         return ret_ret;
34242 }
34243
34244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1signer_1provider(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34245         LDKChannelManagerReadArgs this_ptr_conv;
34246         this_ptr_conv.inner = untag_ptr(this_ptr);
34247         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34249         this_ptr_conv.is_owned = false;
34250         void* val_ptr = untag_ptr(val);
34251         CHECK_ACCESS(val_ptr);
34252         LDKSignerProvider val_conv = *(LDKSignerProvider*)(val_ptr);
34253         if (val_conv.free == LDKSignerProvider_JCalls_free) {
34254                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34255                 LDKSignerProvider_JCalls_cloned(&val_conv);
34256         }
34257         ChannelManagerReadArgs_set_signer_provider(&this_ptr_conv, val_conv);
34258 }
34259
34260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
34261         LDKChannelManagerReadArgs this_ptr_conv;
34262         this_ptr_conv.inner = untag_ptr(this_ptr);
34263         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34265         this_ptr_conv.is_owned = false;
34266         // WARNING: This object doesn't live past this scope, needs clone!
34267         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
34268         return ret_ret;
34269 }
34270
34271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34272         LDKChannelManagerReadArgs this_ptr_conv;
34273         this_ptr_conv.inner = untag_ptr(this_ptr);
34274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34276         this_ptr_conv.is_owned = false;
34277         void* val_ptr = untag_ptr(val);
34278         CHECK_ACCESS(val_ptr);
34279         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
34280         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
34281                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34282                 LDKFeeEstimator_JCalls_cloned(&val_conv);
34283         }
34284         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
34285 }
34286
34287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
34288         LDKChannelManagerReadArgs this_ptr_conv;
34289         this_ptr_conv.inner = untag_ptr(this_ptr);
34290         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34292         this_ptr_conv.is_owned = false;
34293         // WARNING: This object doesn't live past this scope, needs clone!
34294         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
34295         return ret_ret;
34296 }
34297
34298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34299         LDKChannelManagerReadArgs this_ptr_conv;
34300         this_ptr_conv.inner = untag_ptr(this_ptr);
34301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34303         this_ptr_conv.is_owned = false;
34304         void* val_ptr = untag_ptr(val);
34305         CHECK_ACCESS(val_ptr);
34306         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
34307         if (val_conv.free == LDKWatch_JCalls_free) {
34308                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34309                 LDKWatch_JCalls_cloned(&val_conv);
34310         }
34311         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
34312 }
34313
34314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
34315         LDKChannelManagerReadArgs this_ptr_conv;
34316         this_ptr_conv.inner = untag_ptr(this_ptr);
34317         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34319         this_ptr_conv.is_owned = false;
34320         // WARNING: This object doesn't live past this scope, needs clone!
34321         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
34322         return ret_ret;
34323 }
34324
34325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34326         LDKChannelManagerReadArgs this_ptr_conv;
34327         this_ptr_conv.inner = untag_ptr(this_ptr);
34328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34330         this_ptr_conv.is_owned = false;
34331         void* val_ptr = untag_ptr(val);
34332         CHECK_ACCESS(val_ptr);
34333         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
34334         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
34335                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34336                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
34337         }
34338         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
34339 }
34340
34341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1router(JNIEnv *env, jclass clz, int64_t this_ptr) {
34342         LDKChannelManagerReadArgs this_ptr_conv;
34343         this_ptr_conv.inner = untag_ptr(this_ptr);
34344         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34346         this_ptr_conv.is_owned = false;
34347         // WARNING: This object doesn't live past this scope, needs clone!
34348         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_router(&this_ptr_conv), false);
34349         return ret_ret;
34350 }
34351
34352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1router(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34353         LDKChannelManagerReadArgs this_ptr_conv;
34354         this_ptr_conv.inner = untag_ptr(this_ptr);
34355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34357         this_ptr_conv.is_owned = false;
34358         void* val_ptr = untag_ptr(val);
34359         CHECK_ACCESS(val_ptr);
34360         LDKRouter val_conv = *(LDKRouter*)(val_ptr);
34361         if (val_conv.free == LDKRouter_JCalls_free) {
34362                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34363                 LDKRouter_JCalls_cloned(&val_conv);
34364         }
34365         ChannelManagerReadArgs_set_router(&this_ptr_conv, val_conv);
34366 }
34367
34368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
34369         LDKChannelManagerReadArgs this_ptr_conv;
34370         this_ptr_conv.inner = untag_ptr(this_ptr);
34371         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34373         this_ptr_conv.is_owned = false;
34374         // WARNING: This object doesn't live past this scope, needs clone!
34375         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
34376         return ret_ret;
34377 }
34378
34379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34380         LDKChannelManagerReadArgs this_ptr_conv;
34381         this_ptr_conv.inner = untag_ptr(this_ptr);
34382         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34384         this_ptr_conv.is_owned = false;
34385         void* val_ptr = untag_ptr(val);
34386         CHECK_ACCESS(val_ptr);
34387         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
34388         if (val_conv.free == LDKLogger_JCalls_free) {
34389                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34390                 LDKLogger_JCalls_cloned(&val_conv);
34391         }
34392         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
34393 }
34394
34395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
34396         LDKChannelManagerReadArgs this_ptr_conv;
34397         this_ptr_conv.inner = untag_ptr(this_ptr);
34398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34400         this_ptr_conv.is_owned = false;
34401         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
34402         int64_t ret_ref = 0;
34403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34404         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34405         return ret_ref;
34406 }
34407
34408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34409         LDKChannelManagerReadArgs this_ptr_conv;
34410         this_ptr_conv.inner = untag_ptr(this_ptr);
34411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34413         this_ptr_conv.is_owned = false;
34414         LDKUserConfig val_conv;
34415         val_conv.inner = untag_ptr(val);
34416         val_conv.is_owned = ptr_is_owned(val);
34417         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34418         val_conv = UserConfig_clone(&val_conv);
34419         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
34420 }
34421
34422 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) {
34423         void* entropy_source_ptr = untag_ptr(entropy_source);
34424         CHECK_ACCESS(entropy_source_ptr);
34425         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
34426         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
34427                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34428                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
34429         }
34430         void* node_signer_ptr = untag_ptr(node_signer);
34431         CHECK_ACCESS(node_signer_ptr);
34432         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
34433         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
34434                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34435                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
34436         }
34437         void* signer_provider_ptr = untag_ptr(signer_provider);
34438         CHECK_ACCESS(signer_provider_ptr);
34439         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
34440         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
34441                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34442                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
34443         }
34444         void* fee_estimator_ptr = untag_ptr(fee_estimator);
34445         CHECK_ACCESS(fee_estimator_ptr);
34446         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
34447         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
34448                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34449                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
34450         }
34451         void* chain_monitor_ptr = untag_ptr(chain_monitor);
34452         CHECK_ACCESS(chain_monitor_ptr);
34453         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
34454         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
34455                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34456                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
34457         }
34458         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
34459         CHECK_ACCESS(tx_broadcaster_ptr);
34460         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
34461         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
34462                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34463                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
34464         }
34465         void* router_ptr = untag_ptr(router);
34466         CHECK_ACCESS(router_ptr);
34467         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
34468         if (router_conv.free == LDKRouter_JCalls_free) {
34469                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34470                 LDKRouter_JCalls_cloned(&router_conv);
34471         }
34472         void* logger_ptr = untag_ptr(logger);
34473         CHECK_ACCESS(logger_ptr);
34474         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34475         if (logger_conv.free == LDKLogger_JCalls_free) {
34476                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34477                 LDKLogger_JCalls_cloned(&logger_conv);
34478         }
34479         LDKUserConfig default_config_conv;
34480         default_config_conv.inner = untag_ptr(default_config);
34481         default_config_conv.is_owned = ptr_is_owned(default_config);
34482         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
34483         default_config_conv = UserConfig_clone(&default_config_conv);
34484         LDKCVec_ChannelMonitorZ channel_monitors_constr;
34485         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
34486         if (channel_monitors_constr.datalen > 0)
34487                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
34488         else
34489                 channel_monitors_constr.data = NULL;
34490         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
34491         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
34492                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
34493                 LDKChannelMonitor channel_monitors_conv_16_conv;
34494                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
34495                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
34496                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
34497                 channel_monitors_conv_16_conv.is_owned = false;
34498                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
34499         }
34500         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
34501         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);
34502         int64_t ret_ref = 0;
34503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34504         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34505         return ret_ref;
34506 }
34507
34508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
34509         LDKu8slice ser_ref;
34510         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34511         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34512         LDKChannelManagerReadArgs arg_conv;
34513         arg_conv.inner = untag_ptr(arg);
34514         arg_conv.is_owned = ptr_is_owned(arg);
34515         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34516         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
34517         
34518         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
34519         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
34520         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34521         return tag_ptr(ret_conv, true);
34522 }
34523
34524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34525         LDKExpandedKey this_obj_conv;
34526         this_obj_conv.inner = untag_ptr(this_obj);
34527         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34529         ExpandedKey_free(this_obj_conv);
34530 }
34531
34532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
34533         uint8_t key_material_arr[32];
34534         CHECK((*env)->GetArrayLength(env, key_material) == 32);
34535         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
34536         uint8_t (*key_material_ref)[32] = &key_material_arr;
34537         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
34538         int64_t ret_ref = 0;
34539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34540         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34541         return ret_ref;
34542 }
34543
34544 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) {
34545         LDKExpandedKey keys_conv;
34546         keys_conv.inner = untag_ptr(keys);
34547         keys_conv.is_owned = ptr_is_owned(keys);
34548         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
34549         keys_conv.is_owned = false;
34550         void* min_value_msat_ptr = untag_ptr(min_value_msat);
34551         CHECK_ACCESS(min_value_msat_ptr);
34552         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
34553         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
34554         void* entropy_source_ptr = untag_ptr(entropy_source);
34555         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
34556         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
34557         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
34558         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
34559         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
34560         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
34561         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
34562         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, entropy_source_conv, current_time, min_final_cltv_expiry_delta_conv);
34563         return tag_ptr(ret_conv, true);
34564 }
34565
34566 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) {
34567         LDKExpandedKey keys_conv;
34568         keys_conv.inner = untag_ptr(keys);
34569         keys_conv.is_owned = ptr_is_owned(keys);
34570         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
34571         keys_conv.is_owned = false;
34572         void* min_value_msat_ptr = untag_ptr(min_value_msat);
34573         CHECK_ACCESS(min_value_msat_ptr);
34574         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
34575         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
34576         LDKThirtyTwoBytes payment_hash_ref;
34577         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
34578         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
34579         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
34580         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
34581         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
34582         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
34583         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
34584         *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);
34585         return tag_ptr(ret_conv, true);
34586 }
34587
34588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34589         if (!ptr_is_owned(this_ptr)) return;
34590         void* this_ptr_ptr = untag_ptr(this_ptr);
34591         CHECK_ACCESS(this_ptr_ptr);
34592         LDKDecodeError this_ptr_conv = *(LDKDecodeError*)(this_ptr_ptr);
34593         FREE(untag_ptr(this_ptr));
34594         DecodeError_free(this_ptr_conv);
34595 }
34596
34597 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
34598         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34599         *ret_copy = DecodeError_clone(arg);
34600         int64_t ret_ref = tag_ptr(ret_copy, true);
34601         return ret_ref;
34602 }
34603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34604         LDKDecodeError* arg_conv = (LDKDecodeError*)untag_ptr(arg);
34605         int64_t ret_conv = DecodeError_clone_ptr(arg_conv);
34606         return ret_conv;
34607 }
34608
34609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34610         LDKDecodeError* orig_conv = (LDKDecodeError*)untag_ptr(orig);
34611         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34612         *ret_copy = DecodeError_clone(orig_conv);
34613         int64_t ret_ref = tag_ptr(ret_copy, true);
34614         return ret_ref;
34615 }
34616
34617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1version(JNIEnv *env, jclass clz) {
34618         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34619         *ret_copy = DecodeError_unknown_version();
34620         int64_t ret_ref = tag_ptr(ret_copy, true);
34621         return ret_ref;
34622 }
34623
34624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1required_1feature(JNIEnv *env, jclass clz) {
34625         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34626         *ret_copy = DecodeError_unknown_required_feature();
34627         int64_t ret_ref = tag_ptr(ret_copy, true);
34628         return ret_ref;
34629 }
34630
34631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1invalid_1value(JNIEnv *env, jclass clz) {
34632         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34633         *ret_copy = DecodeError_invalid_value();
34634         int64_t ret_ref = tag_ptr(ret_copy, true);
34635         return ret_ref;
34636 }
34637
34638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1short_1read(JNIEnv *env, jclass clz) {
34639         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34640         *ret_copy = DecodeError_short_read();
34641         int64_t ret_ref = tag_ptr(ret_copy, true);
34642         return ret_ref;
34643 }
34644
34645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1bad_1length_1descriptor(JNIEnv *env, jclass clz) {
34646         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34647         *ret_copy = DecodeError_bad_length_descriptor();
34648         int64_t ret_ref = tag_ptr(ret_copy, true);
34649         return ret_ref;
34650 }
34651
34652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1io(JNIEnv *env, jclass clz, jclass a) {
34653         LDKIOError a_conv = LDKIOError_from_java(env, a);
34654         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34655         *ret_copy = DecodeError_io(a_conv);
34656         int64_t ret_ref = tag_ptr(ret_copy, true);
34657         return ret_ref;
34658 }
34659
34660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unsupported_1compression(JNIEnv *env, jclass clz) {
34661         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34662         *ret_copy = DecodeError_unsupported_compression();
34663         int64_t ret_ref = tag_ptr(ret_copy, true);
34664         return ret_ref;
34665 }
34666
34667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DecodeError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34668         LDKDecodeError* a_conv = (LDKDecodeError*)untag_ptr(a);
34669         LDKDecodeError* b_conv = (LDKDecodeError*)untag_ptr(b);
34670         jboolean ret_conv = DecodeError_eq(a_conv, b_conv);
34671         return ret_conv;
34672 }
34673
34674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34675         LDKInit this_obj_conv;
34676         this_obj_conv.inner = untag_ptr(this_obj);
34677         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34679         Init_free(this_obj_conv);
34680 }
34681
34682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
34683         LDKInit this_ptr_conv;
34684         this_ptr_conv.inner = untag_ptr(this_ptr);
34685         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34687         this_ptr_conv.is_owned = false;
34688         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
34689         int64_t ret_ref = 0;
34690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34692         return ret_ref;
34693 }
34694
34695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34696         LDKInit this_ptr_conv;
34697         this_ptr_conv.inner = untag_ptr(this_ptr);
34698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34700         this_ptr_conv.is_owned = false;
34701         LDKInitFeatures val_conv;
34702         val_conv.inner = untag_ptr(val);
34703         val_conv.is_owned = ptr_is_owned(val);
34704         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34705         val_conv = InitFeatures_clone(&val_conv);
34706         Init_set_features(&this_ptr_conv, val_conv);
34707 }
34708
34709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
34710         LDKInit this_ptr_conv;
34711         this_ptr_conv.inner = untag_ptr(this_ptr);
34712         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34714         this_ptr_conv.is_owned = false;
34715         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
34716         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
34717         int64_t ret_ref = tag_ptr(ret_copy, true);
34718         return ret_ref;
34719 }
34720
34721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34722         LDKInit this_ptr_conv;
34723         this_ptr_conv.inner = untag_ptr(this_ptr);
34724         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34726         this_ptr_conv.is_owned = false;
34727         void* val_ptr = untag_ptr(val);
34728         CHECK_ACCESS(val_ptr);
34729         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
34730         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(val));
34731         Init_set_remote_network_address(&this_ptr_conv, val_conv);
34732 }
34733
34734 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) {
34735         LDKInitFeatures features_arg_conv;
34736         features_arg_conv.inner = untag_ptr(features_arg);
34737         features_arg_conv.is_owned = ptr_is_owned(features_arg);
34738         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
34739         features_arg_conv = InitFeatures_clone(&features_arg_conv);
34740         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
34741         CHECK_ACCESS(remote_network_address_arg_ptr);
34742         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
34743         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
34744         int64_t ret_ref = 0;
34745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34746         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34747         return ret_ref;
34748 }
34749
34750 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
34751         LDKInit ret_var = Init_clone(arg);
34752         int64_t ret_ref = 0;
34753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34754         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34755         return ret_ref;
34756 }
34757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34758         LDKInit arg_conv;
34759         arg_conv.inner = untag_ptr(arg);
34760         arg_conv.is_owned = ptr_is_owned(arg);
34761         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34762         arg_conv.is_owned = false;
34763         int64_t ret_conv = Init_clone_ptr(&arg_conv);
34764         return ret_conv;
34765 }
34766
34767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34768         LDKInit orig_conv;
34769         orig_conv.inner = untag_ptr(orig);
34770         orig_conv.is_owned = ptr_is_owned(orig);
34771         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34772         orig_conv.is_owned = false;
34773         LDKInit ret_var = Init_clone(&orig_conv);
34774         int64_t ret_ref = 0;
34775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34777         return ret_ref;
34778 }
34779
34780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Init_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34781         LDKInit a_conv;
34782         a_conv.inner = untag_ptr(a);
34783         a_conv.is_owned = ptr_is_owned(a);
34784         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34785         a_conv.is_owned = false;
34786         LDKInit b_conv;
34787         b_conv.inner = untag_ptr(b);
34788         b_conv.is_owned = ptr_is_owned(b);
34789         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34790         b_conv.is_owned = false;
34791         jboolean ret_conv = Init_eq(&a_conv, &b_conv);
34792         return ret_conv;
34793 }
34794
34795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34796         LDKErrorMessage this_obj_conv;
34797         this_obj_conv.inner = untag_ptr(this_obj);
34798         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34800         ErrorMessage_free(this_obj_conv);
34801 }
34802
34803 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34804         LDKErrorMessage this_ptr_conv;
34805         this_ptr_conv.inner = untag_ptr(this_ptr);
34806         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34808         this_ptr_conv.is_owned = false;
34809         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34810         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
34811         return ret_arr;
34812 }
34813
34814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34815         LDKErrorMessage this_ptr_conv;
34816         this_ptr_conv.inner = untag_ptr(this_ptr);
34817         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34819         this_ptr_conv.is_owned = false;
34820         LDKThirtyTwoBytes val_ref;
34821         CHECK((*env)->GetArrayLength(env, val) == 32);
34822         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34823         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
34824 }
34825
34826 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34827         LDKErrorMessage this_ptr_conv;
34828         this_ptr_conv.inner = untag_ptr(this_ptr);
34829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34831         this_ptr_conv.is_owned = false;
34832         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
34833         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34834         Str_free(ret_str);
34835         return ret_conv;
34836 }
34837
34838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34839         LDKErrorMessage this_ptr_conv;
34840         this_ptr_conv.inner = untag_ptr(this_ptr);
34841         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34843         this_ptr_conv.is_owned = false;
34844         LDKStr val_conv = java_to_owned_str(env, val);
34845         ErrorMessage_set_data(&this_ptr_conv, val_conv);
34846 }
34847
34848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34849         LDKThirtyTwoBytes channel_id_arg_ref;
34850         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34851         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34852         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34853         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
34854         int64_t ret_ref = 0;
34855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34856         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34857         return ret_ref;
34858 }
34859
34860 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
34861         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
34862         int64_t ret_ref = 0;
34863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34864         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34865         return ret_ref;
34866 }
34867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34868         LDKErrorMessage arg_conv;
34869         arg_conv.inner = untag_ptr(arg);
34870         arg_conv.is_owned = ptr_is_owned(arg);
34871         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34872         arg_conv.is_owned = false;
34873         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
34874         return ret_conv;
34875 }
34876
34877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34878         LDKErrorMessage orig_conv;
34879         orig_conv.inner = untag_ptr(orig);
34880         orig_conv.is_owned = ptr_is_owned(orig);
34881         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34882         orig_conv.is_owned = false;
34883         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
34884         int64_t ret_ref = 0;
34885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34886         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34887         return ret_ref;
34888 }
34889
34890 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34891         LDKErrorMessage a_conv;
34892         a_conv.inner = untag_ptr(a);
34893         a_conv.is_owned = ptr_is_owned(a);
34894         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34895         a_conv.is_owned = false;
34896         LDKErrorMessage b_conv;
34897         b_conv.inner = untag_ptr(b);
34898         b_conv.is_owned = ptr_is_owned(b);
34899         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34900         b_conv.is_owned = false;
34901         jboolean ret_conv = ErrorMessage_eq(&a_conv, &b_conv);
34902         return ret_conv;
34903 }
34904
34905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34906         LDKWarningMessage this_obj_conv;
34907         this_obj_conv.inner = untag_ptr(this_obj);
34908         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34910         WarningMessage_free(this_obj_conv);
34911 }
34912
34913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34914         LDKWarningMessage this_ptr_conv;
34915         this_ptr_conv.inner = untag_ptr(this_ptr);
34916         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34918         this_ptr_conv.is_owned = false;
34919         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34920         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
34921         return ret_arr;
34922 }
34923
34924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34925         LDKWarningMessage this_ptr_conv;
34926         this_ptr_conv.inner = untag_ptr(this_ptr);
34927         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34929         this_ptr_conv.is_owned = false;
34930         LDKThirtyTwoBytes val_ref;
34931         CHECK((*env)->GetArrayLength(env, val) == 32);
34932         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34933         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
34934 }
34935
34936 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34937         LDKWarningMessage this_ptr_conv;
34938         this_ptr_conv.inner = untag_ptr(this_ptr);
34939         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34941         this_ptr_conv.is_owned = false;
34942         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
34943         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34944         Str_free(ret_str);
34945         return ret_conv;
34946 }
34947
34948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34949         LDKWarningMessage this_ptr_conv;
34950         this_ptr_conv.inner = untag_ptr(this_ptr);
34951         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34953         this_ptr_conv.is_owned = false;
34954         LDKStr val_conv = java_to_owned_str(env, val);
34955         WarningMessage_set_data(&this_ptr_conv, val_conv);
34956 }
34957
34958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34959         LDKThirtyTwoBytes channel_id_arg_ref;
34960         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34961         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34962         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34963         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
34964         int64_t ret_ref = 0;
34965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34967         return ret_ref;
34968 }
34969
34970 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
34971         LDKWarningMessage ret_var = WarningMessage_clone(arg);
34972         int64_t ret_ref = 0;
34973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34974         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34975         return ret_ref;
34976 }
34977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34978         LDKWarningMessage arg_conv;
34979         arg_conv.inner = untag_ptr(arg);
34980         arg_conv.is_owned = ptr_is_owned(arg);
34981         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34982         arg_conv.is_owned = false;
34983         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
34984         return ret_conv;
34985 }
34986
34987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34988         LDKWarningMessage orig_conv;
34989         orig_conv.inner = untag_ptr(orig);
34990         orig_conv.is_owned = ptr_is_owned(orig);
34991         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34992         orig_conv.is_owned = false;
34993         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
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
35000 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WarningMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35001         LDKWarningMessage a_conv;
35002         a_conv.inner = untag_ptr(a);
35003         a_conv.is_owned = ptr_is_owned(a);
35004         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35005         a_conv.is_owned = false;
35006         LDKWarningMessage b_conv;
35007         b_conv.inner = untag_ptr(b);
35008         b_conv.is_owned = ptr_is_owned(b);
35009         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35010         b_conv.is_owned = false;
35011         jboolean ret_conv = WarningMessage_eq(&a_conv, &b_conv);
35012         return ret_conv;
35013 }
35014
35015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35016         LDKPing this_obj_conv;
35017         this_obj_conv.inner = untag_ptr(this_obj);
35018         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35020         Ping_free(this_obj_conv);
35021 }
35022
35023 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
35024         LDKPing this_ptr_conv;
35025         this_ptr_conv.inner = untag_ptr(this_ptr);
35026         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35028         this_ptr_conv.is_owned = false;
35029         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
35030         return ret_conv;
35031 }
35032
35033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35034         LDKPing this_ptr_conv;
35035         this_ptr_conv.inner = untag_ptr(this_ptr);
35036         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35038         this_ptr_conv.is_owned = false;
35039         Ping_set_ponglen(&this_ptr_conv, val);
35040 }
35041
35042 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
35043         LDKPing this_ptr_conv;
35044         this_ptr_conv.inner = untag_ptr(this_ptr);
35045         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35047         this_ptr_conv.is_owned = false;
35048         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
35049         return ret_conv;
35050 }
35051
35052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35053         LDKPing this_ptr_conv;
35054         this_ptr_conv.inner = untag_ptr(this_ptr);
35055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35057         this_ptr_conv.is_owned = false;
35058         Ping_set_byteslen(&this_ptr_conv, val);
35059 }
35060
35061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
35062         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
35063         int64_t ret_ref = 0;
35064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35065         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35066         return ret_ref;
35067 }
35068
35069 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
35070         LDKPing ret_var = Ping_clone(arg);
35071         int64_t ret_ref = 0;
35072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35073         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35074         return ret_ref;
35075 }
35076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35077         LDKPing arg_conv;
35078         arg_conv.inner = untag_ptr(arg);
35079         arg_conv.is_owned = ptr_is_owned(arg);
35080         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35081         arg_conv.is_owned = false;
35082         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
35083         return ret_conv;
35084 }
35085
35086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35087         LDKPing orig_conv;
35088         orig_conv.inner = untag_ptr(orig);
35089         orig_conv.is_owned = ptr_is_owned(orig);
35090         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35091         orig_conv.is_owned = false;
35092         LDKPing ret_var = Ping_clone(&orig_conv);
35093         int64_t ret_ref = 0;
35094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35095         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35096         return ret_ref;
35097 }
35098
35099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Ping_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35100         LDKPing a_conv;
35101         a_conv.inner = untag_ptr(a);
35102         a_conv.is_owned = ptr_is_owned(a);
35103         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35104         a_conv.is_owned = false;
35105         LDKPing b_conv;
35106         b_conv.inner = untag_ptr(b);
35107         b_conv.is_owned = ptr_is_owned(b);
35108         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35109         b_conv.is_owned = false;
35110         jboolean ret_conv = Ping_eq(&a_conv, &b_conv);
35111         return ret_conv;
35112 }
35113
35114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35115         LDKPong this_obj_conv;
35116         this_obj_conv.inner = untag_ptr(this_obj);
35117         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35119         Pong_free(this_obj_conv);
35120 }
35121
35122 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
35123         LDKPong this_ptr_conv;
35124         this_ptr_conv.inner = untag_ptr(this_ptr);
35125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35127         this_ptr_conv.is_owned = false;
35128         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
35129         return ret_conv;
35130 }
35131
35132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35133         LDKPong this_ptr_conv;
35134         this_ptr_conv.inner = untag_ptr(this_ptr);
35135         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35137         this_ptr_conv.is_owned = false;
35138         Pong_set_byteslen(&this_ptr_conv, val);
35139 }
35140
35141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
35142         LDKPong ret_var = Pong_new(byteslen_arg);
35143         int64_t ret_ref = 0;
35144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35145         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35146         return ret_ref;
35147 }
35148
35149 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
35150         LDKPong ret_var = Pong_clone(arg);
35151         int64_t ret_ref = 0;
35152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35153         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35154         return ret_ref;
35155 }
35156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35157         LDKPong arg_conv;
35158         arg_conv.inner = untag_ptr(arg);
35159         arg_conv.is_owned = ptr_is_owned(arg);
35160         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35161         arg_conv.is_owned = false;
35162         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
35163         return ret_conv;
35164 }
35165
35166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35167         LDKPong orig_conv;
35168         orig_conv.inner = untag_ptr(orig);
35169         orig_conv.is_owned = ptr_is_owned(orig);
35170         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35171         orig_conv.is_owned = false;
35172         LDKPong ret_var = Pong_clone(&orig_conv);
35173         int64_t ret_ref = 0;
35174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35175         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35176         return ret_ref;
35177 }
35178
35179 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Pong_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35180         LDKPong a_conv;
35181         a_conv.inner = untag_ptr(a);
35182         a_conv.is_owned = ptr_is_owned(a);
35183         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35184         a_conv.is_owned = false;
35185         LDKPong b_conv;
35186         b_conv.inner = untag_ptr(b);
35187         b_conv.is_owned = ptr_is_owned(b);
35188         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35189         b_conv.is_owned = false;
35190         jboolean ret_conv = Pong_eq(&a_conv, &b_conv);
35191         return ret_conv;
35192 }
35193
35194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35195         LDKOpenChannel this_obj_conv;
35196         this_obj_conv.inner = untag_ptr(this_obj);
35197         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35199         OpenChannel_free(this_obj_conv);
35200 }
35201
35202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35203         LDKOpenChannel this_ptr_conv;
35204         this_ptr_conv.inner = untag_ptr(this_ptr);
35205         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35207         this_ptr_conv.is_owned = false;
35208         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35209         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
35210         return ret_arr;
35211 }
35212
35213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35214         LDKOpenChannel this_ptr_conv;
35215         this_ptr_conv.inner = untag_ptr(this_ptr);
35216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35218         this_ptr_conv.is_owned = false;
35219         LDKThirtyTwoBytes val_ref;
35220         CHECK((*env)->GetArrayLength(env, val) == 32);
35221         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35222         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
35223 }
35224
35225 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35226         LDKOpenChannel this_ptr_conv;
35227         this_ptr_conv.inner = untag_ptr(this_ptr);
35228         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35230         this_ptr_conv.is_owned = false;
35231         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35232         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
35233         return ret_arr;
35234 }
35235
35236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35237         LDKOpenChannel this_ptr_conv;
35238         this_ptr_conv.inner = untag_ptr(this_ptr);
35239         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35241         this_ptr_conv.is_owned = false;
35242         LDKThirtyTwoBytes val_ref;
35243         CHECK((*env)->GetArrayLength(env, val) == 32);
35244         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35245         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
35246 }
35247
35248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35249         LDKOpenChannel this_ptr_conv;
35250         this_ptr_conv.inner = untag_ptr(this_ptr);
35251         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35253         this_ptr_conv.is_owned = false;
35254         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
35255         return ret_conv;
35256 }
35257
35258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35259         LDKOpenChannel this_ptr_conv;
35260         this_ptr_conv.inner = untag_ptr(this_ptr);
35261         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35263         this_ptr_conv.is_owned = false;
35264         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
35265 }
35266
35267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35268         LDKOpenChannel this_ptr_conv;
35269         this_ptr_conv.inner = untag_ptr(this_ptr);
35270         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35272         this_ptr_conv.is_owned = false;
35273         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
35274         return ret_conv;
35275 }
35276
35277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35278         LDKOpenChannel this_ptr_conv;
35279         this_ptr_conv.inner = untag_ptr(this_ptr);
35280         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35282         this_ptr_conv.is_owned = false;
35283         OpenChannel_set_push_msat(&this_ptr_conv, val);
35284 }
35285
35286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35287         LDKOpenChannel this_ptr_conv;
35288         this_ptr_conv.inner = untag_ptr(this_ptr);
35289         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35291         this_ptr_conv.is_owned = false;
35292         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
35293         return ret_conv;
35294 }
35295
35296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35297         LDKOpenChannel this_ptr_conv;
35298         this_ptr_conv.inner = untag_ptr(this_ptr);
35299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35301         this_ptr_conv.is_owned = false;
35302         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
35303 }
35304
35305 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) {
35306         LDKOpenChannel this_ptr_conv;
35307         this_ptr_conv.inner = untag_ptr(this_ptr);
35308         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35310         this_ptr_conv.is_owned = false;
35311         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
35312         return ret_conv;
35313 }
35314
35315 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) {
35316         LDKOpenChannel this_ptr_conv;
35317         this_ptr_conv.inner = untag_ptr(this_ptr);
35318         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35320         this_ptr_conv.is_owned = false;
35321         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
35322 }
35323
35324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35325         LDKOpenChannel this_ptr_conv;
35326         this_ptr_conv.inner = untag_ptr(this_ptr);
35327         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35329         this_ptr_conv.is_owned = false;
35330         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
35331         return ret_conv;
35332 }
35333
35334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35335         LDKOpenChannel this_ptr_conv;
35336         this_ptr_conv.inner = untag_ptr(this_ptr);
35337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35339         this_ptr_conv.is_owned = false;
35340         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
35341 }
35342
35343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35344         LDKOpenChannel this_ptr_conv;
35345         this_ptr_conv.inner = untag_ptr(this_ptr);
35346         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35348         this_ptr_conv.is_owned = false;
35349         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
35350         return ret_conv;
35351 }
35352
35353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t 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         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
35360 }
35361
35362 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
35363         LDKOpenChannel this_ptr_conv;
35364         this_ptr_conv.inner = untag_ptr(this_ptr);
35365         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35367         this_ptr_conv.is_owned = false;
35368         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
35369         return ret_conv;
35370 }
35371
35372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35373         LDKOpenChannel this_ptr_conv;
35374         this_ptr_conv.inner = untag_ptr(this_ptr);
35375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35377         this_ptr_conv.is_owned = false;
35378         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
35379 }
35380
35381 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
35382         LDKOpenChannel this_ptr_conv;
35383         this_ptr_conv.inner = untag_ptr(this_ptr);
35384         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35386         this_ptr_conv.is_owned = false;
35387         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
35388         return ret_conv;
35389 }
35390
35391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35392         LDKOpenChannel this_ptr_conv;
35393         this_ptr_conv.inner = untag_ptr(this_ptr);
35394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35396         this_ptr_conv.is_owned = false;
35397         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
35398 }
35399
35400 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35401         LDKOpenChannel this_ptr_conv;
35402         this_ptr_conv.inner = untag_ptr(this_ptr);
35403         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35405         this_ptr_conv.is_owned = false;
35406         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
35407         return ret_conv;
35408 }
35409
35410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35411         LDKOpenChannel this_ptr_conv;
35412         this_ptr_conv.inner = untag_ptr(this_ptr);
35413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35415         this_ptr_conv.is_owned = false;
35416         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
35417 }
35418
35419 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35420         LDKOpenChannel this_ptr_conv;
35421         this_ptr_conv.inner = untag_ptr(this_ptr);
35422         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35424         this_ptr_conv.is_owned = false;
35425         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35426         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
35427         return ret_arr;
35428 }
35429
35430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35431         LDKOpenChannel this_ptr_conv;
35432         this_ptr_conv.inner = untag_ptr(this_ptr);
35433         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35435         this_ptr_conv.is_owned = false;
35436         LDKPublicKey val_ref;
35437         CHECK((*env)->GetArrayLength(env, val) == 33);
35438         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35439         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
35440 }
35441
35442 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35443         LDKOpenChannel this_ptr_conv;
35444         this_ptr_conv.inner = untag_ptr(this_ptr);
35445         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35447         this_ptr_conv.is_owned = false;
35448         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35449         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
35450         return ret_arr;
35451 }
35452
35453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35454         LDKOpenChannel this_ptr_conv;
35455         this_ptr_conv.inner = untag_ptr(this_ptr);
35456         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35458         this_ptr_conv.is_owned = false;
35459         LDKPublicKey val_ref;
35460         CHECK((*env)->GetArrayLength(env, val) == 33);
35461         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35462         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
35463 }
35464
35465 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35466         LDKOpenChannel this_ptr_conv;
35467         this_ptr_conv.inner = untag_ptr(this_ptr);
35468         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35470         this_ptr_conv.is_owned = false;
35471         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35472         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
35473         return ret_arr;
35474 }
35475
35476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35477         LDKOpenChannel this_ptr_conv;
35478         this_ptr_conv.inner = untag_ptr(this_ptr);
35479         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35481         this_ptr_conv.is_owned = false;
35482         LDKPublicKey val_ref;
35483         CHECK((*env)->GetArrayLength(env, val) == 33);
35484         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35485         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
35486 }
35487
35488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35489         LDKOpenChannel this_ptr_conv;
35490         this_ptr_conv.inner = untag_ptr(this_ptr);
35491         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35493         this_ptr_conv.is_owned = false;
35494         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35495         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
35496         return ret_arr;
35497 }
35498
35499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
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         LDKPublicKey val_ref;
35506         CHECK((*env)->GetArrayLength(env, val) == 33);
35507         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35508         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35509 }
35510
35511 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35512         LDKOpenChannel this_ptr_conv;
35513         this_ptr_conv.inner = untag_ptr(this_ptr);
35514         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35516         this_ptr_conv.is_owned = false;
35517         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35518         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
35519         return ret_arr;
35520 }
35521
35522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35523         LDKOpenChannel this_ptr_conv;
35524         this_ptr_conv.inner = untag_ptr(this_ptr);
35525         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35527         this_ptr_conv.is_owned = false;
35528         LDKPublicKey val_ref;
35529         CHECK((*env)->GetArrayLength(env, val) == 33);
35530         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35531         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
35532 }
35533
35534 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35535         LDKOpenChannel this_ptr_conv;
35536         this_ptr_conv.inner = untag_ptr(this_ptr);
35537         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35539         this_ptr_conv.is_owned = false;
35540         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35541         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
35542         return ret_arr;
35543 }
35544
35545 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) {
35546         LDKOpenChannel this_ptr_conv;
35547         this_ptr_conv.inner = untag_ptr(this_ptr);
35548         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35550         this_ptr_conv.is_owned = false;
35551         LDKPublicKey val_ref;
35552         CHECK((*env)->GetArrayLength(env, val) == 33);
35553         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35554         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
35555 }
35556
35557 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
35558         LDKOpenChannel this_ptr_conv;
35559         this_ptr_conv.inner = untag_ptr(this_ptr);
35560         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35562         this_ptr_conv.is_owned = false;
35563         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
35564         return ret_conv;
35565 }
35566
35567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
35568         LDKOpenChannel this_ptr_conv;
35569         this_ptr_conv.inner = untag_ptr(this_ptr);
35570         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35572         this_ptr_conv.is_owned = false;
35573         OpenChannel_set_channel_flags(&this_ptr_conv, val);
35574 }
35575
35576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
35577         LDKOpenChannel this_ptr_conv;
35578         this_ptr_conv.inner = untag_ptr(this_ptr);
35579         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35581         this_ptr_conv.is_owned = false;
35582         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
35583         int64_t ret_ref = 0;
35584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35585         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35586         return ret_ref;
35587 }
35588
35589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35590         LDKOpenChannel this_ptr_conv;
35591         this_ptr_conv.inner = untag_ptr(this_ptr);
35592         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35594         this_ptr_conv.is_owned = false;
35595         LDKChannelTypeFeatures val_conv;
35596         val_conv.inner = untag_ptr(val);
35597         val_conv.is_owned = ptr_is_owned(val);
35598         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35599         val_conv = ChannelTypeFeatures_clone(&val_conv);
35600         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
35601 }
35602
35603 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
35604         LDKOpenChannel ret_var = OpenChannel_clone(arg);
35605         int64_t ret_ref = 0;
35606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35607         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35608         return ret_ref;
35609 }
35610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35611         LDKOpenChannel arg_conv;
35612         arg_conv.inner = untag_ptr(arg);
35613         arg_conv.is_owned = ptr_is_owned(arg);
35614         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35615         arg_conv.is_owned = false;
35616         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
35617         return ret_conv;
35618 }
35619
35620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35621         LDKOpenChannel orig_conv;
35622         orig_conv.inner = untag_ptr(orig);
35623         orig_conv.is_owned = ptr_is_owned(orig);
35624         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35625         orig_conv.is_owned = false;
35626         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
35627         int64_t ret_ref = 0;
35628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35629         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35630         return ret_ref;
35631 }
35632
35633 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OpenChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35634         LDKOpenChannel a_conv;
35635         a_conv.inner = untag_ptr(a);
35636         a_conv.is_owned = ptr_is_owned(a);
35637         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35638         a_conv.is_owned = false;
35639         LDKOpenChannel b_conv;
35640         b_conv.inner = untag_ptr(b);
35641         b_conv.is_owned = ptr_is_owned(b);
35642         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35643         b_conv.is_owned = false;
35644         jboolean ret_conv = OpenChannel_eq(&a_conv, &b_conv);
35645         return ret_conv;
35646 }
35647
35648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35649         LDKAcceptChannel this_obj_conv;
35650         this_obj_conv.inner = untag_ptr(this_obj);
35651         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35653         AcceptChannel_free(this_obj_conv);
35654 }
35655
35656 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35657         LDKAcceptChannel this_ptr_conv;
35658         this_ptr_conv.inner = untag_ptr(this_ptr);
35659         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35661         this_ptr_conv.is_owned = false;
35662         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35663         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
35664         return ret_arr;
35665 }
35666
35667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35668         LDKAcceptChannel this_ptr_conv;
35669         this_ptr_conv.inner = untag_ptr(this_ptr);
35670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35672         this_ptr_conv.is_owned = false;
35673         LDKThirtyTwoBytes val_ref;
35674         CHECK((*env)->GetArrayLength(env, val) == 32);
35675         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35676         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
35677 }
35678
35679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35680         LDKAcceptChannel this_ptr_conv;
35681         this_ptr_conv.inner = untag_ptr(this_ptr);
35682         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35684         this_ptr_conv.is_owned = false;
35685         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
35686         return ret_conv;
35687 }
35688
35689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35690         LDKAcceptChannel this_ptr_conv;
35691         this_ptr_conv.inner = untag_ptr(this_ptr);
35692         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35694         this_ptr_conv.is_owned = false;
35695         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
35696 }
35697
35698 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) {
35699         LDKAcceptChannel this_ptr_conv;
35700         this_ptr_conv.inner = untag_ptr(this_ptr);
35701         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35703         this_ptr_conv.is_owned = false;
35704         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
35705         return ret_conv;
35706 }
35707
35708 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) {
35709         LDKAcceptChannel this_ptr_conv;
35710         this_ptr_conv.inner = untag_ptr(this_ptr);
35711         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35713         this_ptr_conv.is_owned = false;
35714         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
35715 }
35716
35717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35718         LDKAcceptChannel this_ptr_conv;
35719         this_ptr_conv.inner = untag_ptr(this_ptr);
35720         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35722         this_ptr_conv.is_owned = false;
35723         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
35724         return ret_conv;
35725 }
35726
35727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35728         LDKAcceptChannel this_ptr_conv;
35729         this_ptr_conv.inner = untag_ptr(this_ptr);
35730         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35732         this_ptr_conv.is_owned = false;
35733         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
35734 }
35735
35736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35737         LDKAcceptChannel this_ptr_conv;
35738         this_ptr_conv.inner = untag_ptr(this_ptr);
35739         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35741         this_ptr_conv.is_owned = false;
35742         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
35743         return ret_conv;
35744 }
35745
35746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t 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         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
35753 }
35754
35755 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
35756         LDKAcceptChannel this_ptr_conv;
35757         this_ptr_conv.inner = untag_ptr(this_ptr);
35758         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35760         this_ptr_conv.is_owned = false;
35761         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
35762         return ret_conv;
35763 }
35764
35765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35766         LDKAcceptChannel this_ptr_conv;
35767         this_ptr_conv.inner = untag_ptr(this_ptr);
35768         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35770         this_ptr_conv.is_owned = false;
35771         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
35772 }
35773
35774 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
35775         LDKAcceptChannel this_ptr_conv;
35776         this_ptr_conv.inner = untag_ptr(this_ptr);
35777         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35779         this_ptr_conv.is_owned = false;
35780         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
35781         return ret_conv;
35782 }
35783
35784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35785         LDKAcceptChannel this_ptr_conv;
35786         this_ptr_conv.inner = untag_ptr(this_ptr);
35787         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35789         this_ptr_conv.is_owned = false;
35790         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
35791 }
35792
35793 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35794         LDKAcceptChannel this_ptr_conv;
35795         this_ptr_conv.inner = untag_ptr(this_ptr);
35796         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35798         this_ptr_conv.is_owned = false;
35799         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
35800         return ret_conv;
35801 }
35802
35803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35804         LDKAcceptChannel this_ptr_conv;
35805         this_ptr_conv.inner = untag_ptr(this_ptr);
35806         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35808         this_ptr_conv.is_owned = false;
35809         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
35810 }
35811
35812 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35813         LDKAcceptChannel this_ptr_conv;
35814         this_ptr_conv.inner = untag_ptr(this_ptr);
35815         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35817         this_ptr_conv.is_owned = false;
35818         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35819         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
35820         return ret_arr;
35821 }
35822
35823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35824         LDKAcceptChannel this_ptr_conv;
35825         this_ptr_conv.inner = untag_ptr(this_ptr);
35826         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35828         this_ptr_conv.is_owned = false;
35829         LDKPublicKey val_ref;
35830         CHECK((*env)->GetArrayLength(env, val) == 33);
35831         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35832         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
35833 }
35834
35835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35836         LDKAcceptChannel this_ptr_conv;
35837         this_ptr_conv.inner = untag_ptr(this_ptr);
35838         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35840         this_ptr_conv.is_owned = false;
35841         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35842         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
35843         return ret_arr;
35844 }
35845
35846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35847         LDKAcceptChannel this_ptr_conv;
35848         this_ptr_conv.inner = untag_ptr(this_ptr);
35849         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35851         this_ptr_conv.is_owned = false;
35852         LDKPublicKey val_ref;
35853         CHECK((*env)->GetArrayLength(env, val) == 33);
35854         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35855         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
35856 }
35857
35858 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35859         LDKAcceptChannel this_ptr_conv;
35860         this_ptr_conv.inner = untag_ptr(this_ptr);
35861         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35863         this_ptr_conv.is_owned = false;
35864         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35865         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
35866         return ret_arr;
35867 }
35868
35869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35870         LDKAcceptChannel this_ptr_conv;
35871         this_ptr_conv.inner = untag_ptr(this_ptr);
35872         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35874         this_ptr_conv.is_owned = false;
35875         LDKPublicKey val_ref;
35876         CHECK((*env)->GetArrayLength(env, val) == 33);
35877         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35878         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
35879 }
35880
35881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35882         LDKAcceptChannel this_ptr_conv;
35883         this_ptr_conv.inner = untag_ptr(this_ptr);
35884         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35886         this_ptr_conv.is_owned = false;
35887         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35888         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
35889         return ret_arr;
35890 }
35891
35892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35893         LDKAcceptChannel this_ptr_conv;
35894         this_ptr_conv.inner = untag_ptr(this_ptr);
35895         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35897         this_ptr_conv.is_owned = false;
35898         LDKPublicKey val_ref;
35899         CHECK((*env)->GetArrayLength(env, val) == 33);
35900         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35901         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35902 }
35903
35904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35905         LDKAcceptChannel this_ptr_conv;
35906         this_ptr_conv.inner = untag_ptr(this_ptr);
35907         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35909         this_ptr_conv.is_owned = false;
35910         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35911         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
35912         return ret_arr;
35913 }
35914
35915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35916         LDKAcceptChannel this_ptr_conv;
35917         this_ptr_conv.inner = untag_ptr(this_ptr);
35918         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35920         this_ptr_conv.is_owned = false;
35921         LDKPublicKey val_ref;
35922         CHECK((*env)->GetArrayLength(env, val) == 33);
35923         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35924         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
35925 }
35926
35927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35928         LDKAcceptChannel this_ptr_conv;
35929         this_ptr_conv.inner = untag_ptr(this_ptr);
35930         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35932         this_ptr_conv.is_owned = false;
35933         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35934         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
35935         return ret_arr;
35936 }
35937
35938 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) {
35939         LDKAcceptChannel this_ptr_conv;
35940         this_ptr_conv.inner = untag_ptr(this_ptr);
35941         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35943         this_ptr_conv.is_owned = false;
35944         LDKPublicKey val_ref;
35945         CHECK((*env)->GetArrayLength(env, val) == 33);
35946         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35947         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
35948 }
35949
35950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
35951         LDKAcceptChannel this_ptr_conv;
35952         this_ptr_conv.inner = untag_ptr(this_ptr);
35953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35955         this_ptr_conv.is_owned = false;
35956         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
35957         int64_t ret_ref = 0;
35958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35959         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35960         return ret_ref;
35961 }
35962
35963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35964         LDKAcceptChannel this_ptr_conv;
35965         this_ptr_conv.inner = untag_ptr(this_ptr);
35966         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35968         this_ptr_conv.is_owned = false;
35969         LDKChannelTypeFeatures val_conv;
35970         val_conv.inner = untag_ptr(val);
35971         val_conv.is_owned = ptr_is_owned(val);
35972         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35973         val_conv = ChannelTypeFeatures_clone(&val_conv);
35974         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
35975 }
35976
35977 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
35978         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
35979         int64_t ret_ref = 0;
35980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35981         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35982         return ret_ref;
35983 }
35984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35985         LDKAcceptChannel arg_conv;
35986         arg_conv.inner = untag_ptr(arg);
35987         arg_conv.is_owned = ptr_is_owned(arg);
35988         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35989         arg_conv.is_owned = false;
35990         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
35991         return ret_conv;
35992 }
35993
35994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35995         LDKAcceptChannel orig_conv;
35996         orig_conv.inner = untag_ptr(orig);
35997         orig_conv.is_owned = ptr_is_owned(orig);
35998         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35999         orig_conv.is_owned = false;
36000         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
36001         int64_t ret_ref = 0;
36002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36003         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36004         return ret_ref;
36005 }
36006
36007 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36008         LDKAcceptChannel a_conv;
36009         a_conv.inner = untag_ptr(a);
36010         a_conv.is_owned = ptr_is_owned(a);
36011         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36012         a_conv.is_owned = false;
36013         LDKAcceptChannel b_conv;
36014         b_conv.inner = untag_ptr(b);
36015         b_conv.is_owned = ptr_is_owned(b);
36016         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36017         b_conv.is_owned = false;
36018         jboolean ret_conv = AcceptChannel_eq(&a_conv, &b_conv);
36019         return ret_conv;
36020 }
36021
36022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36023         LDKFundingCreated this_obj_conv;
36024         this_obj_conv.inner = untag_ptr(this_obj);
36025         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36027         FundingCreated_free(this_obj_conv);
36028 }
36029
36030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36031         LDKFundingCreated this_ptr_conv;
36032         this_ptr_conv.inner = untag_ptr(this_ptr);
36033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36035         this_ptr_conv.is_owned = false;
36036         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36037         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
36038         return ret_arr;
36039 }
36040
36041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36042         LDKFundingCreated this_ptr_conv;
36043         this_ptr_conv.inner = untag_ptr(this_ptr);
36044         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36046         this_ptr_conv.is_owned = false;
36047         LDKThirtyTwoBytes val_ref;
36048         CHECK((*env)->GetArrayLength(env, val) == 32);
36049         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36050         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
36051 }
36052
36053 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
36054         LDKFundingCreated this_ptr_conv;
36055         this_ptr_conv.inner = untag_ptr(this_ptr);
36056         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36058         this_ptr_conv.is_owned = false;
36059         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36060         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
36061         return ret_arr;
36062 }
36063
36064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36065         LDKFundingCreated this_ptr_conv;
36066         this_ptr_conv.inner = untag_ptr(this_ptr);
36067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36069         this_ptr_conv.is_owned = false;
36070         LDKThirtyTwoBytes val_ref;
36071         CHECK((*env)->GetArrayLength(env, val) == 32);
36072         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36073         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
36074 }
36075
36076 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
36077         LDKFundingCreated this_ptr_conv;
36078         this_ptr_conv.inner = untag_ptr(this_ptr);
36079         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36081         this_ptr_conv.is_owned = false;
36082         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
36083         return ret_conv;
36084 }
36085
36086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
36087         LDKFundingCreated this_ptr_conv;
36088         this_ptr_conv.inner = untag_ptr(this_ptr);
36089         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36091         this_ptr_conv.is_owned = false;
36092         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
36093 }
36094
36095 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36096         LDKFundingCreated this_ptr_conv;
36097         this_ptr_conv.inner = untag_ptr(this_ptr);
36098         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36100         this_ptr_conv.is_owned = false;
36101         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36102         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
36103         return ret_arr;
36104 }
36105
36106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36107         LDKFundingCreated this_ptr_conv;
36108         this_ptr_conv.inner = untag_ptr(this_ptr);
36109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36111         this_ptr_conv.is_owned = false;
36112         LDKSignature val_ref;
36113         CHECK((*env)->GetArrayLength(env, val) == 64);
36114         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36115         FundingCreated_set_signature(&this_ptr_conv, val_ref);
36116 }
36117
36118 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) {
36119         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
36120         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
36121         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
36122         LDKThirtyTwoBytes funding_txid_arg_ref;
36123         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
36124         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
36125         LDKSignature signature_arg_ref;
36126         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36127         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36128         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
36129         int64_t ret_ref = 0;
36130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36131         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36132         return ret_ref;
36133 }
36134
36135 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
36136         LDKFundingCreated ret_var = FundingCreated_clone(arg);
36137         int64_t ret_ref = 0;
36138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36139         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36140         return ret_ref;
36141 }
36142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36143         LDKFundingCreated arg_conv;
36144         arg_conv.inner = untag_ptr(arg);
36145         arg_conv.is_owned = ptr_is_owned(arg);
36146         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36147         arg_conv.is_owned = false;
36148         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
36149         return ret_conv;
36150 }
36151
36152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36153         LDKFundingCreated orig_conv;
36154         orig_conv.inner = untag_ptr(orig);
36155         orig_conv.is_owned = ptr_is_owned(orig);
36156         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36157         orig_conv.is_owned = false;
36158         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
36159         int64_t ret_ref = 0;
36160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36161         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36162         return ret_ref;
36163 }
36164
36165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingCreated_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36166         LDKFundingCreated a_conv;
36167         a_conv.inner = untag_ptr(a);
36168         a_conv.is_owned = ptr_is_owned(a);
36169         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36170         a_conv.is_owned = false;
36171         LDKFundingCreated b_conv;
36172         b_conv.inner = untag_ptr(b);
36173         b_conv.is_owned = ptr_is_owned(b);
36174         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36175         b_conv.is_owned = false;
36176         jboolean ret_conv = FundingCreated_eq(&a_conv, &b_conv);
36177         return ret_conv;
36178 }
36179
36180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36181         LDKFundingSigned this_obj_conv;
36182         this_obj_conv.inner = untag_ptr(this_obj);
36183         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36185         FundingSigned_free(this_obj_conv);
36186 }
36187
36188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36189         LDKFundingSigned this_ptr_conv;
36190         this_ptr_conv.inner = untag_ptr(this_ptr);
36191         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36193         this_ptr_conv.is_owned = false;
36194         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36195         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
36196         return ret_arr;
36197 }
36198
36199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36200         LDKFundingSigned this_ptr_conv;
36201         this_ptr_conv.inner = untag_ptr(this_ptr);
36202         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36204         this_ptr_conv.is_owned = false;
36205         LDKThirtyTwoBytes val_ref;
36206         CHECK((*env)->GetArrayLength(env, val) == 32);
36207         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36208         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
36209 }
36210
36211 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36212         LDKFundingSigned this_ptr_conv;
36213         this_ptr_conv.inner = untag_ptr(this_ptr);
36214         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36216         this_ptr_conv.is_owned = false;
36217         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36218         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
36219         return ret_arr;
36220 }
36221
36222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36223         LDKFundingSigned this_ptr_conv;
36224         this_ptr_conv.inner = untag_ptr(this_ptr);
36225         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36227         this_ptr_conv.is_owned = false;
36228         LDKSignature val_ref;
36229         CHECK((*env)->GetArrayLength(env, val) == 64);
36230         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36231         FundingSigned_set_signature(&this_ptr_conv, val_ref);
36232 }
36233
36234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
36235         LDKThirtyTwoBytes channel_id_arg_ref;
36236         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36237         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36238         LDKSignature signature_arg_ref;
36239         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36240         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36241         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
36242         int64_t ret_ref = 0;
36243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36244         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36245         return ret_ref;
36246 }
36247
36248 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
36249         LDKFundingSigned ret_var = FundingSigned_clone(arg);
36250         int64_t ret_ref = 0;
36251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36252         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36253         return ret_ref;
36254 }
36255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36256         LDKFundingSigned arg_conv;
36257         arg_conv.inner = untag_ptr(arg);
36258         arg_conv.is_owned = ptr_is_owned(arg);
36259         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36260         arg_conv.is_owned = false;
36261         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
36262         return ret_conv;
36263 }
36264
36265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36266         LDKFundingSigned orig_conv;
36267         orig_conv.inner = untag_ptr(orig);
36268         orig_conv.is_owned = ptr_is_owned(orig);
36269         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36270         orig_conv.is_owned = false;
36271         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
36272         int64_t ret_ref = 0;
36273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36274         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36275         return ret_ref;
36276 }
36277
36278 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36279         LDKFundingSigned a_conv;
36280         a_conv.inner = untag_ptr(a);
36281         a_conv.is_owned = ptr_is_owned(a);
36282         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36283         a_conv.is_owned = false;
36284         LDKFundingSigned b_conv;
36285         b_conv.inner = untag_ptr(b);
36286         b_conv.is_owned = ptr_is_owned(b);
36287         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36288         b_conv.is_owned = false;
36289         jboolean ret_conv = FundingSigned_eq(&a_conv, &b_conv);
36290         return ret_conv;
36291 }
36292
36293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36294         LDKChannelReady this_obj_conv;
36295         this_obj_conv.inner = untag_ptr(this_obj);
36296         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36298         ChannelReady_free(this_obj_conv);
36299 }
36300
36301 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36302         LDKChannelReady this_ptr_conv;
36303         this_ptr_conv.inner = untag_ptr(this_ptr);
36304         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36306         this_ptr_conv.is_owned = false;
36307         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36308         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
36309         return ret_arr;
36310 }
36311
36312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36313         LDKChannelReady this_ptr_conv;
36314         this_ptr_conv.inner = untag_ptr(this_ptr);
36315         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36317         this_ptr_conv.is_owned = false;
36318         LDKThirtyTwoBytes val_ref;
36319         CHECK((*env)->GetArrayLength(env, val) == 32);
36320         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36321         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
36322 }
36323
36324 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36325         LDKChannelReady this_ptr_conv;
36326         this_ptr_conv.inner = untag_ptr(this_ptr);
36327         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36329         this_ptr_conv.is_owned = false;
36330         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36331         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
36332         return ret_arr;
36333 }
36334
36335 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) {
36336         LDKChannelReady this_ptr_conv;
36337         this_ptr_conv.inner = untag_ptr(this_ptr);
36338         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36340         this_ptr_conv.is_owned = false;
36341         LDKPublicKey val_ref;
36342         CHECK((*env)->GetArrayLength(env, val) == 33);
36343         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36344         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
36345 }
36346
36347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
36348         LDKChannelReady this_ptr_conv;
36349         this_ptr_conv.inner = untag_ptr(this_ptr);
36350         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36352         this_ptr_conv.is_owned = false;
36353         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36354         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
36355         int64_t ret_ref = tag_ptr(ret_copy, true);
36356         return ret_ref;
36357 }
36358
36359 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) {
36360         LDKChannelReady this_ptr_conv;
36361         this_ptr_conv.inner = untag_ptr(this_ptr);
36362         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36364         this_ptr_conv.is_owned = false;
36365         void* val_ptr = untag_ptr(val);
36366         CHECK_ACCESS(val_ptr);
36367         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36368         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
36369         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
36370 }
36371
36372 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) {
36373         LDKThirtyTwoBytes channel_id_arg_ref;
36374         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36375         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36376         LDKPublicKey next_per_commitment_point_arg_ref;
36377         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
36378         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
36379         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
36380         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
36381         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
36382         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
36383         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
36384         int64_t ret_ref = 0;
36385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36386         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36387         return ret_ref;
36388 }
36389
36390 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
36391         LDKChannelReady ret_var = ChannelReady_clone(arg);
36392         int64_t ret_ref = 0;
36393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36394         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36395         return ret_ref;
36396 }
36397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36398         LDKChannelReady arg_conv;
36399         arg_conv.inner = untag_ptr(arg);
36400         arg_conv.is_owned = ptr_is_owned(arg);
36401         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36402         arg_conv.is_owned = false;
36403         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
36404         return ret_conv;
36405 }
36406
36407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36408         LDKChannelReady orig_conv;
36409         orig_conv.inner = untag_ptr(orig);
36410         orig_conv.is_owned = ptr_is_owned(orig);
36411         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36412         orig_conv.is_owned = false;
36413         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
36414         int64_t ret_ref = 0;
36415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36416         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36417         return ret_ref;
36418 }
36419
36420 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReady_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36421         LDKChannelReady a_conv;
36422         a_conv.inner = untag_ptr(a);
36423         a_conv.is_owned = ptr_is_owned(a);
36424         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36425         a_conv.is_owned = false;
36426         LDKChannelReady b_conv;
36427         b_conv.inner = untag_ptr(b);
36428         b_conv.is_owned = ptr_is_owned(b);
36429         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36430         b_conv.is_owned = false;
36431         jboolean ret_conv = ChannelReady_eq(&a_conv, &b_conv);
36432         return ret_conv;
36433 }
36434
36435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36436         LDKShutdown this_obj_conv;
36437         this_obj_conv.inner = untag_ptr(this_obj);
36438         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36440         Shutdown_free(this_obj_conv);
36441 }
36442
36443 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36444         LDKShutdown this_ptr_conv;
36445         this_ptr_conv.inner = untag_ptr(this_ptr);
36446         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36448         this_ptr_conv.is_owned = false;
36449         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36450         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
36451         return ret_arr;
36452 }
36453
36454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36455         LDKShutdown this_ptr_conv;
36456         this_ptr_conv.inner = untag_ptr(this_ptr);
36457         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36459         this_ptr_conv.is_owned = false;
36460         LDKThirtyTwoBytes val_ref;
36461         CHECK((*env)->GetArrayLength(env, val) == 32);
36462         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36463         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
36464 }
36465
36466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
36467         LDKShutdown this_ptr_conv;
36468         this_ptr_conv.inner = untag_ptr(this_ptr);
36469         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36471         this_ptr_conv.is_owned = false;
36472         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
36473         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36474         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36475         return ret_arr;
36476 }
36477
36478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36479         LDKShutdown this_ptr_conv;
36480         this_ptr_conv.inner = untag_ptr(this_ptr);
36481         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36483         this_ptr_conv.is_owned = false;
36484         LDKCVec_u8Z val_ref;
36485         val_ref.datalen = (*env)->GetArrayLength(env, val);
36486         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
36487         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
36488         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
36489 }
36490
36491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
36492         LDKThirtyTwoBytes channel_id_arg_ref;
36493         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36494         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36495         LDKCVec_u8Z scriptpubkey_arg_ref;
36496         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
36497         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
36498         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
36499         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
36500         int64_t ret_ref = 0;
36501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36502         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36503         return ret_ref;
36504 }
36505
36506 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
36507         LDKShutdown ret_var = Shutdown_clone(arg);
36508         int64_t ret_ref = 0;
36509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36510         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36511         return ret_ref;
36512 }
36513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36514         LDKShutdown arg_conv;
36515         arg_conv.inner = untag_ptr(arg);
36516         arg_conv.is_owned = ptr_is_owned(arg);
36517         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36518         arg_conv.is_owned = false;
36519         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
36520         return ret_conv;
36521 }
36522
36523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36524         LDKShutdown orig_conv;
36525         orig_conv.inner = untag_ptr(orig);
36526         orig_conv.is_owned = ptr_is_owned(orig);
36527         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36528         orig_conv.is_owned = false;
36529         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
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
36536 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Shutdown_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36537         LDKShutdown a_conv;
36538         a_conv.inner = untag_ptr(a);
36539         a_conv.is_owned = ptr_is_owned(a);
36540         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36541         a_conv.is_owned = false;
36542         LDKShutdown b_conv;
36543         b_conv.inner = untag_ptr(b);
36544         b_conv.is_owned = ptr_is_owned(b);
36545         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36546         b_conv.is_owned = false;
36547         jboolean ret_conv = Shutdown_eq(&a_conv, &b_conv);
36548         return ret_conv;
36549 }
36550
36551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36552         LDKClosingSignedFeeRange this_obj_conv;
36553         this_obj_conv.inner = untag_ptr(this_obj);
36554         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36556         ClosingSignedFeeRange_free(this_obj_conv);
36557 }
36558
36559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36560         LDKClosingSignedFeeRange this_ptr_conv;
36561         this_ptr_conv.inner = untag_ptr(this_ptr);
36562         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36564         this_ptr_conv.is_owned = false;
36565         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
36566         return ret_conv;
36567 }
36568
36569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36570         LDKClosingSignedFeeRange this_ptr_conv;
36571         this_ptr_conv.inner = untag_ptr(this_ptr);
36572         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36574         this_ptr_conv.is_owned = false;
36575         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
36576 }
36577
36578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36579         LDKClosingSignedFeeRange this_ptr_conv;
36580         this_ptr_conv.inner = untag_ptr(this_ptr);
36581         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36583         this_ptr_conv.is_owned = false;
36584         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
36585         return ret_conv;
36586 }
36587
36588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36589         LDKClosingSignedFeeRange this_ptr_conv;
36590         this_ptr_conv.inner = untag_ptr(this_ptr);
36591         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36593         this_ptr_conv.is_owned = false;
36594         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
36595 }
36596
36597 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) {
36598         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
36599         int64_t ret_ref = 0;
36600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36601         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36602         return ret_ref;
36603 }
36604
36605 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
36606         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
36607         int64_t ret_ref = 0;
36608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36609         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36610         return ret_ref;
36611 }
36612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36613         LDKClosingSignedFeeRange arg_conv;
36614         arg_conv.inner = untag_ptr(arg);
36615         arg_conv.is_owned = ptr_is_owned(arg);
36616         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36617         arg_conv.is_owned = false;
36618         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
36619         return ret_conv;
36620 }
36621
36622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36623         LDKClosingSignedFeeRange orig_conv;
36624         orig_conv.inner = untag_ptr(orig);
36625         orig_conv.is_owned = ptr_is_owned(orig);
36626         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36627         orig_conv.is_owned = false;
36628         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
36629         int64_t ret_ref = 0;
36630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36631         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36632         return ret_ref;
36633 }
36634
36635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36636         LDKClosingSignedFeeRange a_conv;
36637         a_conv.inner = untag_ptr(a);
36638         a_conv.is_owned = ptr_is_owned(a);
36639         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36640         a_conv.is_owned = false;
36641         LDKClosingSignedFeeRange b_conv;
36642         b_conv.inner = untag_ptr(b);
36643         b_conv.is_owned = ptr_is_owned(b);
36644         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36645         b_conv.is_owned = false;
36646         jboolean ret_conv = ClosingSignedFeeRange_eq(&a_conv, &b_conv);
36647         return ret_conv;
36648 }
36649
36650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36651         LDKClosingSigned this_obj_conv;
36652         this_obj_conv.inner = untag_ptr(this_obj);
36653         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36655         ClosingSigned_free(this_obj_conv);
36656 }
36657
36658 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36659         LDKClosingSigned this_ptr_conv;
36660         this_ptr_conv.inner = untag_ptr(this_ptr);
36661         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36663         this_ptr_conv.is_owned = false;
36664         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36665         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
36666         return ret_arr;
36667 }
36668
36669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36670         LDKClosingSigned this_ptr_conv;
36671         this_ptr_conv.inner = untag_ptr(this_ptr);
36672         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36674         this_ptr_conv.is_owned = false;
36675         LDKThirtyTwoBytes val_ref;
36676         CHECK((*env)->GetArrayLength(env, val) == 32);
36677         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36678         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
36679 }
36680
36681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36682         LDKClosingSigned this_ptr_conv;
36683         this_ptr_conv.inner = untag_ptr(this_ptr);
36684         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36686         this_ptr_conv.is_owned = false;
36687         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
36688         return ret_conv;
36689 }
36690
36691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36692         LDKClosingSigned this_ptr_conv;
36693         this_ptr_conv.inner = untag_ptr(this_ptr);
36694         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36696         this_ptr_conv.is_owned = false;
36697         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
36698 }
36699
36700 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36701         LDKClosingSigned this_ptr_conv;
36702         this_ptr_conv.inner = untag_ptr(this_ptr);
36703         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36705         this_ptr_conv.is_owned = false;
36706         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36707         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
36708         return ret_arr;
36709 }
36710
36711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36712         LDKClosingSigned this_ptr_conv;
36713         this_ptr_conv.inner = untag_ptr(this_ptr);
36714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36716         this_ptr_conv.is_owned = false;
36717         LDKSignature val_ref;
36718         CHECK((*env)->GetArrayLength(env, val) == 64);
36719         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36720         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
36721 }
36722
36723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
36724         LDKClosingSigned this_ptr_conv;
36725         this_ptr_conv.inner = untag_ptr(this_ptr);
36726         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36728         this_ptr_conv.is_owned = false;
36729         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
36730         int64_t ret_ref = 0;
36731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36732         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36733         return ret_ref;
36734 }
36735
36736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36737         LDKClosingSigned this_ptr_conv;
36738         this_ptr_conv.inner = untag_ptr(this_ptr);
36739         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36741         this_ptr_conv.is_owned = false;
36742         LDKClosingSignedFeeRange val_conv;
36743         val_conv.inner = untag_ptr(val);
36744         val_conv.is_owned = ptr_is_owned(val);
36745         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36746         val_conv = ClosingSignedFeeRange_clone(&val_conv);
36747         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
36748 }
36749
36750 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) {
36751         LDKThirtyTwoBytes channel_id_arg_ref;
36752         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36753         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36754         LDKSignature signature_arg_ref;
36755         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36756         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36757         LDKClosingSignedFeeRange fee_range_arg_conv;
36758         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
36759         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
36760         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
36761         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
36762         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
36763         int64_t ret_ref = 0;
36764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36765         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36766         return ret_ref;
36767 }
36768
36769 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
36770         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
36771         int64_t ret_ref = 0;
36772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36773         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36774         return ret_ref;
36775 }
36776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36777         LDKClosingSigned arg_conv;
36778         arg_conv.inner = untag_ptr(arg);
36779         arg_conv.is_owned = ptr_is_owned(arg);
36780         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36781         arg_conv.is_owned = false;
36782         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
36783         return ret_conv;
36784 }
36785
36786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36787         LDKClosingSigned orig_conv;
36788         orig_conv.inner = untag_ptr(orig);
36789         orig_conv.is_owned = ptr_is_owned(orig);
36790         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36791         orig_conv.is_owned = false;
36792         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
36793         int64_t ret_ref = 0;
36794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36795         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36796         return ret_ref;
36797 }
36798
36799 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36800         LDKClosingSigned a_conv;
36801         a_conv.inner = untag_ptr(a);
36802         a_conv.is_owned = ptr_is_owned(a);
36803         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36804         a_conv.is_owned = false;
36805         LDKClosingSigned b_conv;
36806         b_conv.inner = untag_ptr(b);
36807         b_conv.is_owned = ptr_is_owned(b);
36808         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36809         b_conv.is_owned = false;
36810         jboolean ret_conv = ClosingSigned_eq(&a_conv, &b_conv);
36811         return ret_conv;
36812 }
36813
36814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36815         LDKUpdateAddHTLC this_obj_conv;
36816         this_obj_conv.inner = untag_ptr(this_obj);
36817         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36819         UpdateAddHTLC_free(this_obj_conv);
36820 }
36821
36822 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36823         LDKUpdateAddHTLC this_ptr_conv;
36824         this_ptr_conv.inner = untag_ptr(this_ptr);
36825         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36827         this_ptr_conv.is_owned = false;
36828         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36829         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
36830         return ret_arr;
36831 }
36832
36833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36834         LDKUpdateAddHTLC this_ptr_conv;
36835         this_ptr_conv.inner = untag_ptr(this_ptr);
36836         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36838         this_ptr_conv.is_owned = false;
36839         LDKThirtyTwoBytes val_ref;
36840         CHECK((*env)->GetArrayLength(env, val) == 32);
36841         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36842         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
36843 }
36844
36845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36846         LDKUpdateAddHTLC this_ptr_conv;
36847         this_ptr_conv.inner = untag_ptr(this_ptr);
36848         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36850         this_ptr_conv.is_owned = false;
36851         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
36852         return ret_conv;
36853 }
36854
36855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36856         LDKUpdateAddHTLC this_ptr_conv;
36857         this_ptr_conv.inner = untag_ptr(this_ptr);
36858         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36860         this_ptr_conv.is_owned = false;
36861         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
36862 }
36863
36864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36865         LDKUpdateAddHTLC this_ptr_conv;
36866         this_ptr_conv.inner = untag_ptr(this_ptr);
36867         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36869         this_ptr_conv.is_owned = false;
36870         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
36871         return ret_conv;
36872 }
36873
36874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36875         LDKUpdateAddHTLC this_ptr_conv;
36876         this_ptr_conv.inner = untag_ptr(this_ptr);
36877         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36879         this_ptr_conv.is_owned = false;
36880         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
36881 }
36882
36883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36884         LDKUpdateAddHTLC this_ptr_conv;
36885         this_ptr_conv.inner = untag_ptr(this_ptr);
36886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36888         this_ptr_conv.is_owned = false;
36889         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36890         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
36891         return ret_arr;
36892 }
36893
36894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36895         LDKUpdateAddHTLC this_ptr_conv;
36896         this_ptr_conv.inner = untag_ptr(this_ptr);
36897         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36899         this_ptr_conv.is_owned = false;
36900         LDKThirtyTwoBytes val_ref;
36901         CHECK((*env)->GetArrayLength(env, val) == 32);
36902         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36903         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
36904 }
36905
36906 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
36907         LDKUpdateAddHTLC this_ptr_conv;
36908         this_ptr_conv.inner = untag_ptr(this_ptr);
36909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36911         this_ptr_conv.is_owned = false;
36912         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
36913         return ret_conv;
36914 }
36915
36916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36917         LDKUpdateAddHTLC this_ptr_conv;
36918         this_ptr_conv.inner = untag_ptr(this_ptr);
36919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36921         this_ptr_conv.is_owned = false;
36922         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
36923 }
36924
36925 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
36926         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
36927         int64_t ret_ref = 0;
36928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36929         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36930         return ret_ref;
36931 }
36932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36933         LDKUpdateAddHTLC arg_conv;
36934         arg_conv.inner = untag_ptr(arg);
36935         arg_conv.is_owned = ptr_is_owned(arg);
36936         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36937         arg_conv.is_owned = false;
36938         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
36939         return ret_conv;
36940 }
36941
36942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36943         LDKUpdateAddHTLC orig_conv;
36944         orig_conv.inner = untag_ptr(orig);
36945         orig_conv.is_owned = ptr_is_owned(orig);
36946         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36947         orig_conv.is_owned = false;
36948         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
36949         int64_t ret_ref = 0;
36950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36951         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36952         return ret_ref;
36953 }
36954
36955 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36956         LDKUpdateAddHTLC a_conv;
36957         a_conv.inner = untag_ptr(a);
36958         a_conv.is_owned = ptr_is_owned(a);
36959         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36960         a_conv.is_owned = false;
36961         LDKUpdateAddHTLC b_conv;
36962         b_conv.inner = untag_ptr(b);
36963         b_conv.is_owned = ptr_is_owned(b);
36964         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36965         b_conv.is_owned = false;
36966         jboolean ret_conv = UpdateAddHTLC_eq(&a_conv, &b_conv);
36967         return ret_conv;
36968 }
36969
36970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36971         LDKOnionMessage this_obj_conv;
36972         this_obj_conv.inner = untag_ptr(this_obj);
36973         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36975         OnionMessage_free(this_obj_conv);
36976 }
36977
36978 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36979         LDKOnionMessage this_ptr_conv;
36980         this_ptr_conv.inner = untag_ptr(this_ptr);
36981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36983         this_ptr_conv.is_owned = false;
36984         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36985         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OnionMessage_get_blinding_point(&this_ptr_conv).compressed_form);
36986         return ret_arr;
36987 }
36988
36989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36990         LDKOnionMessage this_ptr_conv;
36991         this_ptr_conv.inner = untag_ptr(this_ptr);
36992         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36994         this_ptr_conv.is_owned = false;
36995         LDKPublicKey val_ref;
36996         CHECK((*env)->GetArrayLength(env, val) == 33);
36997         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36998         OnionMessage_set_blinding_point(&this_ptr_conv, val_ref);
36999 }
37000
37001 static inline uint64_t OnionMessage_clone_ptr(LDKOnionMessage *NONNULL_PTR arg) {
37002         LDKOnionMessage ret_var = OnionMessage_clone(arg);
37003         int64_t ret_ref = 0;
37004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37005         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37006         return ret_ref;
37007 }
37008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37009         LDKOnionMessage arg_conv;
37010         arg_conv.inner = untag_ptr(arg);
37011         arg_conv.is_owned = ptr_is_owned(arg);
37012         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37013         arg_conv.is_owned = false;
37014         int64_t ret_conv = OnionMessage_clone_ptr(&arg_conv);
37015         return ret_conv;
37016 }
37017
37018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37019         LDKOnionMessage orig_conv;
37020         orig_conv.inner = untag_ptr(orig);
37021         orig_conv.is_owned = ptr_is_owned(orig);
37022         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37023         orig_conv.is_owned = false;
37024         LDKOnionMessage ret_var = OnionMessage_clone(&orig_conv);
37025         int64_t ret_ref = 0;
37026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37027         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37028         return ret_ref;
37029 }
37030
37031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OnionMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37032         LDKOnionMessage a_conv;
37033         a_conv.inner = untag_ptr(a);
37034         a_conv.is_owned = ptr_is_owned(a);
37035         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37036         a_conv.is_owned = false;
37037         LDKOnionMessage b_conv;
37038         b_conv.inner = untag_ptr(b);
37039         b_conv.is_owned = ptr_is_owned(b);
37040         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37041         b_conv.is_owned = false;
37042         jboolean ret_conv = OnionMessage_eq(&a_conv, &b_conv);
37043         return ret_conv;
37044 }
37045
37046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37047         LDKUpdateFulfillHTLC this_obj_conv;
37048         this_obj_conv.inner = untag_ptr(this_obj);
37049         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37051         UpdateFulfillHTLC_free(this_obj_conv);
37052 }
37053
37054 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37055         LDKUpdateFulfillHTLC this_ptr_conv;
37056         this_ptr_conv.inner = untag_ptr(this_ptr);
37057         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37059         this_ptr_conv.is_owned = false;
37060         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37061         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
37062         return ret_arr;
37063 }
37064
37065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37066         LDKUpdateFulfillHTLC this_ptr_conv;
37067         this_ptr_conv.inner = untag_ptr(this_ptr);
37068         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37070         this_ptr_conv.is_owned = false;
37071         LDKThirtyTwoBytes val_ref;
37072         CHECK((*env)->GetArrayLength(env, val) == 32);
37073         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37074         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
37075 }
37076
37077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37078         LDKUpdateFulfillHTLC this_ptr_conv;
37079         this_ptr_conv.inner = untag_ptr(this_ptr);
37080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37082         this_ptr_conv.is_owned = false;
37083         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
37084         return ret_conv;
37085 }
37086
37087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37088         LDKUpdateFulfillHTLC this_ptr_conv;
37089         this_ptr_conv.inner = untag_ptr(this_ptr);
37090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37092         this_ptr_conv.is_owned = false;
37093         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
37094 }
37095
37096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
37097         LDKUpdateFulfillHTLC this_ptr_conv;
37098         this_ptr_conv.inner = untag_ptr(this_ptr);
37099         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37101         this_ptr_conv.is_owned = false;
37102         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37103         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
37104         return ret_arr;
37105 }
37106
37107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37108         LDKUpdateFulfillHTLC this_ptr_conv;
37109         this_ptr_conv.inner = untag_ptr(this_ptr);
37110         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37112         this_ptr_conv.is_owned = false;
37113         LDKThirtyTwoBytes val_ref;
37114         CHECK((*env)->GetArrayLength(env, val) == 32);
37115         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37116         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
37117 }
37118
37119 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) {
37120         LDKThirtyTwoBytes channel_id_arg_ref;
37121         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37122         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37123         LDKThirtyTwoBytes payment_preimage_arg_ref;
37124         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
37125         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
37126         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
37127         int64_t ret_ref = 0;
37128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37129         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37130         return ret_ref;
37131 }
37132
37133 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
37134         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
37135         int64_t ret_ref = 0;
37136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37137         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37138         return ret_ref;
37139 }
37140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37141         LDKUpdateFulfillHTLC arg_conv;
37142         arg_conv.inner = untag_ptr(arg);
37143         arg_conv.is_owned = ptr_is_owned(arg);
37144         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37145         arg_conv.is_owned = false;
37146         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
37147         return ret_conv;
37148 }
37149
37150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37151         LDKUpdateFulfillHTLC orig_conv;
37152         orig_conv.inner = untag_ptr(orig);
37153         orig_conv.is_owned = ptr_is_owned(orig);
37154         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37155         orig_conv.is_owned = false;
37156         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
37157         int64_t ret_ref = 0;
37158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37159         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37160         return ret_ref;
37161 }
37162
37163 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37164         LDKUpdateFulfillHTLC a_conv;
37165         a_conv.inner = untag_ptr(a);
37166         a_conv.is_owned = ptr_is_owned(a);
37167         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37168         a_conv.is_owned = false;
37169         LDKUpdateFulfillHTLC b_conv;
37170         b_conv.inner = untag_ptr(b);
37171         b_conv.is_owned = ptr_is_owned(b);
37172         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37173         b_conv.is_owned = false;
37174         jboolean ret_conv = UpdateFulfillHTLC_eq(&a_conv, &b_conv);
37175         return ret_conv;
37176 }
37177
37178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37179         LDKUpdateFailHTLC this_obj_conv;
37180         this_obj_conv.inner = untag_ptr(this_obj);
37181         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37183         UpdateFailHTLC_free(this_obj_conv);
37184 }
37185
37186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37187         LDKUpdateFailHTLC this_ptr_conv;
37188         this_ptr_conv.inner = untag_ptr(this_ptr);
37189         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37191         this_ptr_conv.is_owned = false;
37192         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37193         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
37194         return ret_arr;
37195 }
37196
37197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37198         LDKUpdateFailHTLC this_ptr_conv;
37199         this_ptr_conv.inner = untag_ptr(this_ptr);
37200         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37202         this_ptr_conv.is_owned = false;
37203         LDKThirtyTwoBytes val_ref;
37204         CHECK((*env)->GetArrayLength(env, val) == 32);
37205         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37206         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
37207 }
37208
37209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37210         LDKUpdateFailHTLC this_ptr_conv;
37211         this_ptr_conv.inner = untag_ptr(this_ptr);
37212         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37214         this_ptr_conv.is_owned = false;
37215         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
37216         return ret_conv;
37217 }
37218
37219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37220         LDKUpdateFailHTLC this_ptr_conv;
37221         this_ptr_conv.inner = untag_ptr(this_ptr);
37222         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37224         this_ptr_conv.is_owned = false;
37225         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
37226 }
37227
37228 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
37229         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
37230         int64_t ret_ref = 0;
37231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37232         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37233         return ret_ref;
37234 }
37235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37236         LDKUpdateFailHTLC arg_conv;
37237         arg_conv.inner = untag_ptr(arg);
37238         arg_conv.is_owned = ptr_is_owned(arg);
37239         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37240         arg_conv.is_owned = false;
37241         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
37242         return ret_conv;
37243 }
37244
37245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37246         LDKUpdateFailHTLC orig_conv;
37247         orig_conv.inner = untag_ptr(orig);
37248         orig_conv.is_owned = ptr_is_owned(orig);
37249         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37250         orig_conv.is_owned = false;
37251         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
37252         int64_t ret_ref = 0;
37253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37255         return ret_ref;
37256 }
37257
37258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37259         LDKUpdateFailHTLC a_conv;
37260         a_conv.inner = untag_ptr(a);
37261         a_conv.is_owned = ptr_is_owned(a);
37262         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37263         a_conv.is_owned = false;
37264         LDKUpdateFailHTLC b_conv;
37265         b_conv.inner = untag_ptr(b);
37266         b_conv.is_owned = ptr_is_owned(b);
37267         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37268         b_conv.is_owned = false;
37269         jboolean ret_conv = UpdateFailHTLC_eq(&a_conv, &b_conv);
37270         return ret_conv;
37271 }
37272
37273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37274         LDKUpdateFailMalformedHTLC this_obj_conv;
37275         this_obj_conv.inner = untag_ptr(this_obj);
37276         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37278         UpdateFailMalformedHTLC_free(this_obj_conv);
37279 }
37280
37281 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37282         LDKUpdateFailMalformedHTLC this_ptr_conv;
37283         this_ptr_conv.inner = untag_ptr(this_ptr);
37284         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37286         this_ptr_conv.is_owned = false;
37287         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37288         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
37289         return ret_arr;
37290 }
37291
37292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37293         LDKUpdateFailMalformedHTLC this_ptr_conv;
37294         this_ptr_conv.inner = untag_ptr(this_ptr);
37295         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37297         this_ptr_conv.is_owned = false;
37298         LDKThirtyTwoBytes val_ref;
37299         CHECK((*env)->GetArrayLength(env, val) == 32);
37300         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37301         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
37302 }
37303
37304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37305         LDKUpdateFailMalformedHTLC this_ptr_conv;
37306         this_ptr_conv.inner = untag_ptr(this_ptr);
37307         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37309         this_ptr_conv.is_owned = false;
37310         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
37311         return ret_conv;
37312 }
37313
37314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37315         LDKUpdateFailMalformedHTLC this_ptr_conv;
37316         this_ptr_conv.inner = untag_ptr(this_ptr);
37317         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37319         this_ptr_conv.is_owned = false;
37320         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
37321 }
37322
37323 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
37324         LDKUpdateFailMalformedHTLC this_ptr_conv;
37325         this_ptr_conv.inner = untag_ptr(this_ptr);
37326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37328         this_ptr_conv.is_owned = false;
37329         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
37330         return ret_conv;
37331 }
37332
37333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37334         LDKUpdateFailMalformedHTLC this_ptr_conv;
37335         this_ptr_conv.inner = untag_ptr(this_ptr);
37336         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37338         this_ptr_conv.is_owned = false;
37339         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
37340 }
37341
37342 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
37343         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
37344         int64_t ret_ref = 0;
37345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37346         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37347         return ret_ref;
37348 }
37349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37350         LDKUpdateFailMalformedHTLC arg_conv;
37351         arg_conv.inner = untag_ptr(arg);
37352         arg_conv.is_owned = ptr_is_owned(arg);
37353         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37354         arg_conv.is_owned = false;
37355         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
37356         return ret_conv;
37357 }
37358
37359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37360         LDKUpdateFailMalformedHTLC orig_conv;
37361         orig_conv.inner = untag_ptr(orig);
37362         orig_conv.is_owned = ptr_is_owned(orig);
37363         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37364         orig_conv.is_owned = false;
37365         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
37366         int64_t ret_ref = 0;
37367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37368         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37369         return ret_ref;
37370 }
37371
37372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37373         LDKUpdateFailMalformedHTLC a_conv;
37374         a_conv.inner = untag_ptr(a);
37375         a_conv.is_owned = ptr_is_owned(a);
37376         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37377         a_conv.is_owned = false;
37378         LDKUpdateFailMalformedHTLC b_conv;
37379         b_conv.inner = untag_ptr(b);
37380         b_conv.is_owned = ptr_is_owned(b);
37381         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37382         b_conv.is_owned = false;
37383         jboolean ret_conv = UpdateFailMalformedHTLC_eq(&a_conv, &b_conv);
37384         return ret_conv;
37385 }
37386
37387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37388         LDKCommitmentSigned this_obj_conv;
37389         this_obj_conv.inner = untag_ptr(this_obj);
37390         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37392         CommitmentSigned_free(this_obj_conv);
37393 }
37394
37395 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37396         LDKCommitmentSigned this_ptr_conv;
37397         this_ptr_conv.inner = untag_ptr(this_ptr);
37398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37400         this_ptr_conv.is_owned = false;
37401         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37402         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
37403         return ret_arr;
37404 }
37405
37406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37407         LDKCommitmentSigned this_ptr_conv;
37408         this_ptr_conv.inner = untag_ptr(this_ptr);
37409         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37411         this_ptr_conv.is_owned = false;
37412         LDKThirtyTwoBytes val_ref;
37413         CHECK((*env)->GetArrayLength(env, val) == 32);
37414         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37415         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
37416 }
37417
37418 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
37419         LDKCommitmentSigned this_ptr_conv;
37420         this_ptr_conv.inner = untag_ptr(this_ptr);
37421         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37423         this_ptr_conv.is_owned = false;
37424         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37425         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
37426         return ret_arr;
37427 }
37428
37429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37430         LDKCommitmentSigned this_ptr_conv;
37431         this_ptr_conv.inner = untag_ptr(this_ptr);
37432         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37434         this_ptr_conv.is_owned = false;
37435         LDKSignature val_ref;
37436         CHECK((*env)->GetArrayLength(env, val) == 64);
37437         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37438         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
37439 }
37440
37441 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr) {
37442         LDKCommitmentSigned this_ptr_conv;
37443         this_ptr_conv.inner = untag_ptr(this_ptr);
37444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37446         this_ptr_conv.is_owned = false;
37447         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
37448         jobjectArray ret_arr = NULL;
37449         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
37450         ;
37451         for (size_t i = 0; i < ret_var.datalen; i++) {
37452                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
37453                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
37454                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
37455         }
37456         
37457         FREE(ret_var.data);
37458         return ret_arr;
37459 }
37460
37461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
37462         LDKCommitmentSigned this_ptr_conv;
37463         this_ptr_conv.inner = untag_ptr(this_ptr);
37464         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37466         this_ptr_conv.is_owned = false;
37467         LDKCVec_SignatureZ val_constr;
37468         val_constr.datalen = (*env)->GetArrayLength(env, val);
37469         if (val_constr.datalen > 0)
37470                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37471         else
37472                 val_constr.data = NULL;
37473         for (size_t i = 0; i < val_constr.datalen; i++) {
37474                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
37475                 LDKSignature val_conv_8_ref;
37476                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
37477                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
37478                 val_constr.data[i] = val_conv_8_ref;
37479         }
37480         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
37481 }
37482
37483 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) {
37484         LDKThirtyTwoBytes channel_id_arg_ref;
37485         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37486         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37487         LDKSignature signature_arg_ref;
37488         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
37489         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
37490         LDKCVec_SignatureZ htlc_signatures_arg_constr;
37491         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
37492         if (htlc_signatures_arg_constr.datalen > 0)
37493                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37494         else
37495                 htlc_signatures_arg_constr.data = NULL;
37496         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
37497                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
37498                 LDKSignature htlc_signatures_arg_conv_8_ref;
37499                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
37500                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
37501                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
37502         }
37503         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
37504         int64_t ret_ref = 0;
37505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37506         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37507         return ret_ref;
37508 }
37509
37510 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
37511         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
37512         int64_t ret_ref = 0;
37513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37514         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37515         return ret_ref;
37516 }
37517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37518         LDKCommitmentSigned arg_conv;
37519         arg_conv.inner = untag_ptr(arg);
37520         arg_conv.is_owned = ptr_is_owned(arg);
37521         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37522         arg_conv.is_owned = false;
37523         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
37524         return ret_conv;
37525 }
37526
37527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37528         LDKCommitmentSigned orig_conv;
37529         orig_conv.inner = untag_ptr(orig);
37530         orig_conv.is_owned = ptr_is_owned(orig);
37531         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37532         orig_conv.is_owned = false;
37533         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
37534         int64_t ret_ref = 0;
37535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37536         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37537         return ret_ref;
37538 }
37539
37540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37541         LDKCommitmentSigned a_conv;
37542         a_conv.inner = untag_ptr(a);
37543         a_conv.is_owned = ptr_is_owned(a);
37544         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37545         a_conv.is_owned = false;
37546         LDKCommitmentSigned b_conv;
37547         b_conv.inner = untag_ptr(b);
37548         b_conv.is_owned = ptr_is_owned(b);
37549         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37550         b_conv.is_owned = false;
37551         jboolean ret_conv = CommitmentSigned_eq(&a_conv, &b_conv);
37552         return ret_conv;
37553 }
37554
37555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37556         LDKRevokeAndACK this_obj_conv;
37557         this_obj_conv.inner = untag_ptr(this_obj);
37558         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37560         RevokeAndACK_free(this_obj_conv);
37561 }
37562
37563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37564         LDKRevokeAndACK this_ptr_conv;
37565         this_ptr_conv.inner = untag_ptr(this_ptr);
37566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37568         this_ptr_conv.is_owned = false;
37569         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37570         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
37571         return ret_arr;
37572 }
37573
37574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37575         LDKRevokeAndACK this_ptr_conv;
37576         this_ptr_conv.inner = untag_ptr(this_ptr);
37577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37579         this_ptr_conv.is_owned = false;
37580         LDKThirtyTwoBytes val_ref;
37581         CHECK((*env)->GetArrayLength(env, val) == 32);
37582         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37583         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
37584 }
37585
37586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
37587         LDKRevokeAndACK this_ptr_conv;
37588         this_ptr_conv.inner = untag_ptr(this_ptr);
37589         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37591         this_ptr_conv.is_owned = false;
37592         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37593         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
37594         return ret_arr;
37595 }
37596
37597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37598         LDKRevokeAndACK this_ptr_conv;
37599         this_ptr_conv.inner = untag_ptr(this_ptr);
37600         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37602         this_ptr_conv.is_owned = false;
37603         LDKThirtyTwoBytes val_ref;
37604         CHECK((*env)->GetArrayLength(env, val) == 32);
37605         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37606         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
37607 }
37608
37609 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37610         LDKRevokeAndACK this_ptr_conv;
37611         this_ptr_conv.inner = untag_ptr(this_ptr);
37612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37614         this_ptr_conv.is_owned = false;
37615         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37616         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
37617         return ret_arr;
37618 }
37619
37620 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) {
37621         LDKRevokeAndACK this_ptr_conv;
37622         this_ptr_conv.inner = untag_ptr(this_ptr);
37623         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37625         this_ptr_conv.is_owned = false;
37626         LDKPublicKey val_ref;
37627         CHECK((*env)->GetArrayLength(env, val) == 33);
37628         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37629         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
37630 }
37631
37632 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) {
37633         LDKThirtyTwoBytes channel_id_arg_ref;
37634         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37635         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37636         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
37637         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
37638         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
37639         LDKPublicKey next_per_commitment_point_arg_ref;
37640         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
37641         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
37642         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
37643         int64_t ret_ref = 0;
37644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37645         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37646         return ret_ref;
37647 }
37648
37649 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
37650         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
37651         int64_t ret_ref = 0;
37652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37653         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37654         return ret_ref;
37655 }
37656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37657         LDKRevokeAndACK arg_conv;
37658         arg_conv.inner = untag_ptr(arg);
37659         arg_conv.is_owned = ptr_is_owned(arg);
37660         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37661         arg_conv.is_owned = false;
37662         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
37663         return ret_conv;
37664 }
37665
37666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37667         LDKRevokeAndACK orig_conv;
37668         orig_conv.inner = untag_ptr(orig);
37669         orig_conv.is_owned = ptr_is_owned(orig);
37670         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37671         orig_conv.is_owned = false;
37672         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
37673         int64_t ret_ref = 0;
37674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37675         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37676         return ret_ref;
37677 }
37678
37679 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37680         LDKRevokeAndACK a_conv;
37681         a_conv.inner = untag_ptr(a);
37682         a_conv.is_owned = ptr_is_owned(a);
37683         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37684         a_conv.is_owned = false;
37685         LDKRevokeAndACK b_conv;
37686         b_conv.inner = untag_ptr(b);
37687         b_conv.is_owned = ptr_is_owned(b);
37688         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37689         b_conv.is_owned = false;
37690         jboolean ret_conv = RevokeAndACK_eq(&a_conv, &b_conv);
37691         return ret_conv;
37692 }
37693
37694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37695         LDKUpdateFee this_obj_conv;
37696         this_obj_conv.inner = untag_ptr(this_obj);
37697         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37699         UpdateFee_free(this_obj_conv);
37700 }
37701
37702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37703         LDKUpdateFee this_ptr_conv;
37704         this_ptr_conv.inner = untag_ptr(this_ptr);
37705         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37707         this_ptr_conv.is_owned = false;
37708         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37709         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
37710         return ret_arr;
37711 }
37712
37713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37714         LDKUpdateFee this_ptr_conv;
37715         this_ptr_conv.inner = untag_ptr(this_ptr);
37716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37718         this_ptr_conv.is_owned = false;
37719         LDKThirtyTwoBytes val_ref;
37720         CHECK((*env)->GetArrayLength(env, val) == 32);
37721         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37722         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
37723 }
37724
37725 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
37726         LDKUpdateFee this_ptr_conv;
37727         this_ptr_conv.inner = untag_ptr(this_ptr);
37728         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37730         this_ptr_conv.is_owned = false;
37731         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
37732         return ret_conv;
37733 }
37734
37735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37736         LDKUpdateFee this_ptr_conv;
37737         this_ptr_conv.inner = untag_ptr(this_ptr);
37738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37740         this_ptr_conv.is_owned = false;
37741         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
37742 }
37743
37744 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) {
37745         LDKThirtyTwoBytes channel_id_arg_ref;
37746         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37747         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37748         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
37749         int64_t ret_ref = 0;
37750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37751         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37752         return ret_ref;
37753 }
37754
37755 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
37756         LDKUpdateFee ret_var = UpdateFee_clone(arg);
37757         int64_t ret_ref = 0;
37758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37759         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37760         return ret_ref;
37761 }
37762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37763         LDKUpdateFee arg_conv;
37764         arg_conv.inner = untag_ptr(arg);
37765         arg_conv.is_owned = ptr_is_owned(arg);
37766         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37767         arg_conv.is_owned = false;
37768         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
37769         return ret_conv;
37770 }
37771
37772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37773         LDKUpdateFee orig_conv;
37774         orig_conv.inner = untag_ptr(orig);
37775         orig_conv.is_owned = ptr_is_owned(orig);
37776         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37777         orig_conv.is_owned = false;
37778         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
37779         int64_t ret_ref = 0;
37780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37781         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37782         return ret_ref;
37783 }
37784
37785 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37786         LDKUpdateFee a_conv;
37787         a_conv.inner = untag_ptr(a);
37788         a_conv.is_owned = ptr_is_owned(a);
37789         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37790         a_conv.is_owned = false;
37791         LDKUpdateFee b_conv;
37792         b_conv.inner = untag_ptr(b);
37793         b_conv.is_owned = ptr_is_owned(b);
37794         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37795         b_conv.is_owned = false;
37796         jboolean ret_conv = UpdateFee_eq(&a_conv, &b_conv);
37797         return ret_conv;
37798 }
37799
37800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37801         LDKDataLossProtect this_obj_conv;
37802         this_obj_conv.inner = untag_ptr(this_obj);
37803         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37805         DataLossProtect_free(this_obj_conv);
37806 }
37807
37808 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
37809         LDKDataLossProtect this_ptr_conv;
37810         this_ptr_conv.inner = untag_ptr(this_ptr);
37811         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37813         this_ptr_conv.is_owned = false;
37814         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37815         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
37816         return ret_arr;
37817 }
37818
37819 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) {
37820         LDKDataLossProtect this_ptr_conv;
37821         this_ptr_conv.inner = untag_ptr(this_ptr);
37822         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37824         this_ptr_conv.is_owned = false;
37825         LDKThirtyTwoBytes val_ref;
37826         CHECK((*env)->GetArrayLength(env, val) == 32);
37827         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37828         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
37829 }
37830
37831 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37832         LDKDataLossProtect this_ptr_conv;
37833         this_ptr_conv.inner = untag_ptr(this_ptr);
37834         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37836         this_ptr_conv.is_owned = false;
37837         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37838         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
37839         return ret_arr;
37840 }
37841
37842 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) {
37843         LDKDataLossProtect this_ptr_conv;
37844         this_ptr_conv.inner = untag_ptr(this_ptr);
37845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37847         this_ptr_conv.is_owned = false;
37848         LDKPublicKey val_ref;
37849         CHECK((*env)->GetArrayLength(env, val) == 33);
37850         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37851         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
37852 }
37853
37854 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) {
37855         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
37856         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
37857         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
37858         LDKPublicKey my_current_per_commitment_point_arg_ref;
37859         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
37860         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
37861         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
37862         int64_t ret_ref = 0;
37863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37864         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37865         return ret_ref;
37866 }
37867
37868 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
37869         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
37870         int64_t ret_ref = 0;
37871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37872         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37873         return ret_ref;
37874 }
37875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37876         LDKDataLossProtect arg_conv;
37877         arg_conv.inner = untag_ptr(arg);
37878         arg_conv.is_owned = ptr_is_owned(arg);
37879         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37880         arg_conv.is_owned = false;
37881         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
37882         return ret_conv;
37883 }
37884
37885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37886         LDKDataLossProtect orig_conv;
37887         orig_conv.inner = untag_ptr(orig);
37888         orig_conv.is_owned = ptr_is_owned(orig);
37889         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37890         orig_conv.is_owned = false;
37891         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
37892         int64_t ret_ref = 0;
37893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37894         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37895         return ret_ref;
37896 }
37897
37898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37899         LDKDataLossProtect a_conv;
37900         a_conv.inner = untag_ptr(a);
37901         a_conv.is_owned = ptr_is_owned(a);
37902         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37903         a_conv.is_owned = false;
37904         LDKDataLossProtect b_conv;
37905         b_conv.inner = untag_ptr(b);
37906         b_conv.is_owned = ptr_is_owned(b);
37907         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37908         b_conv.is_owned = false;
37909         jboolean ret_conv = DataLossProtect_eq(&a_conv, &b_conv);
37910         return ret_conv;
37911 }
37912
37913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37914         LDKChannelReestablish this_obj_conv;
37915         this_obj_conv.inner = untag_ptr(this_obj);
37916         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37918         ChannelReestablish_free(this_obj_conv);
37919 }
37920
37921 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37922         LDKChannelReestablish this_ptr_conv;
37923         this_ptr_conv.inner = untag_ptr(this_ptr);
37924         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37926         this_ptr_conv.is_owned = false;
37927         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37928         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
37929         return ret_arr;
37930 }
37931
37932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37933         LDKChannelReestablish this_ptr_conv;
37934         this_ptr_conv.inner = untag_ptr(this_ptr);
37935         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37937         this_ptr_conv.is_owned = false;
37938         LDKThirtyTwoBytes val_ref;
37939         CHECK((*env)->GetArrayLength(env, val) == 32);
37940         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37941         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
37942 }
37943
37944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37945         LDKChannelReestablish this_ptr_conv;
37946         this_ptr_conv.inner = untag_ptr(this_ptr);
37947         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37949         this_ptr_conv.is_owned = false;
37950         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
37951         return ret_conv;
37952 }
37953
37954 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) {
37955         LDKChannelReestablish this_ptr_conv;
37956         this_ptr_conv.inner = untag_ptr(this_ptr);
37957         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37959         this_ptr_conv.is_owned = false;
37960         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
37961 }
37962
37963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37964         LDKChannelReestablish this_ptr_conv;
37965         this_ptr_conv.inner = untag_ptr(this_ptr);
37966         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37968         this_ptr_conv.is_owned = false;
37969         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
37970         return ret_conv;
37971 }
37972
37973 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) {
37974         LDKChannelReestablish this_ptr_conv;
37975         this_ptr_conv.inner = untag_ptr(this_ptr);
37976         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37978         this_ptr_conv.is_owned = false;
37979         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
37980 }
37981
37982 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
37983         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
37984         int64_t ret_ref = 0;
37985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37986         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37987         return ret_ref;
37988 }
37989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37990         LDKChannelReestablish arg_conv;
37991         arg_conv.inner = untag_ptr(arg);
37992         arg_conv.is_owned = ptr_is_owned(arg);
37993         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37994         arg_conv.is_owned = false;
37995         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
37996         return ret_conv;
37997 }
37998
37999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38000         LDKChannelReestablish orig_conv;
38001         orig_conv.inner = untag_ptr(orig);
38002         orig_conv.is_owned = ptr_is_owned(orig);
38003         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38004         orig_conv.is_owned = false;
38005         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
38006         int64_t ret_ref = 0;
38007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38008         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38009         return ret_ref;
38010 }
38011
38012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38013         LDKChannelReestablish a_conv;
38014         a_conv.inner = untag_ptr(a);
38015         a_conv.is_owned = ptr_is_owned(a);
38016         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38017         a_conv.is_owned = false;
38018         LDKChannelReestablish b_conv;
38019         b_conv.inner = untag_ptr(b);
38020         b_conv.is_owned = ptr_is_owned(b);
38021         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38022         b_conv.is_owned = false;
38023         jboolean ret_conv = ChannelReestablish_eq(&a_conv, &b_conv);
38024         return ret_conv;
38025 }
38026
38027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38028         LDKAnnouncementSignatures this_obj_conv;
38029         this_obj_conv.inner = untag_ptr(this_obj);
38030         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38032         AnnouncementSignatures_free(this_obj_conv);
38033 }
38034
38035 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38036         LDKAnnouncementSignatures this_ptr_conv;
38037         this_ptr_conv.inner = untag_ptr(this_ptr);
38038         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38040         this_ptr_conv.is_owned = false;
38041         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38042         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
38043         return ret_arr;
38044 }
38045
38046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38047         LDKAnnouncementSignatures this_ptr_conv;
38048         this_ptr_conv.inner = untag_ptr(this_ptr);
38049         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38051         this_ptr_conv.is_owned = false;
38052         LDKThirtyTwoBytes val_ref;
38053         CHECK((*env)->GetArrayLength(env, val) == 32);
38054         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38055         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
38056 }
38057
38058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38059         LDKAnnouncementSignatures this_ptr_conv;
38060         this_ptr_conv.inner = untag_ptr(this_ptr);
38061         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38063         this_ptr_conv.is_owned = false;
38064         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
38065         return ret_conv;
38066 }
38067
38068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38069         LDKAnnouncementSignatures this_ptr_conv;
38070         this_ptr_conv.inner = untag_ptr(this_ptr);
38071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38073         this_ptr_conv.is_owned = false;
38074         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
38075 }
38076
38077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38078         LDKAnnouncementSignatures this_ptr_conv;
38079         this_ptr_conv.inner = untag_ptr(this_ptr);
38080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38082         this_ptr_conv.is_owned = false;
38083         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38084         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
38085         return ret_arr;
38086 }
38087
38088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38089         LDKAnnouncementSignatures this_ptr_conv;
38090         this_ptr_conv.inner = untag_ptr(this_ptr);
38091         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38093         this_ptr_conv.is_owned = false;
38094         LDKSignature val_ref;
38095         CHECK((*env)->GetArrayLength(env, val) == 64);
38096         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38097         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
38098 }
38099
38100 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38101         LDKAnnouncementSignatures this_ptr_conv;
38102         this_ptr_conv.inner = untag_ptr(this_ptr);
38103         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38105         this_ptr_conv.is_owned = false;
38106         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38107         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
38108         return ret_arr;
38109 }
38110
38111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38112         LDKAnnouncementSignatures this_ptr_conv;
38113         this_ptr_conv.inner = untag_ptr(this_ptr);
38114         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38116         this_ptr_conv.is_owned = false;
38117         LDKSignature val_ref;
38118         CHECK((*env)->GetArrayLength(env, val) == 64);
38119         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38120         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
38121 }
38122
38123 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) {
38124         LDKThirtyTwoBytes channel_id_arg_ref;
38125         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
38126         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
38127         LDKSignature node_signature_arg_ref;
38128         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
38129         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
38130         LDKSignature bitcoin_signature_arg_ref;
38131         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
38132         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
38133         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
38134         int64_t ret_ref = 0;
38135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38136         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38137         return ret_ref;
38138 }
38139
38140 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
38141         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
38142         int64_t ret_ref = 0;
38143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38144         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38145         return ret_ref;
38146 }
38147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38148         LDKAnnouncementSignatures arg_conv;
38149         arg_conv.inner = untag_ptr(arg);
38150         arg_conv.is_owned = ptr_is_owned(arg);
38151         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38152         arg_conv.is_owned = false;
38153         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
38154         return ret_conv;
38155 }
38156
38157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38158         LDKAnnouncementSignatures orig_conv;
38159         orig_conv.inner = untag_ptr(orig);
38160         orig_conv.is_owned = ptr_is_owned(orig);
38161         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38162         orig_conv.is_owned = false;
38163         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
38164         int64_t ret_ref = 0;
38165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38166         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38167         return ret_ref;
38168 }
38169
38170 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38171         LDKAnnouncementSignatures a_conv;
38172         a_conv.inner = untag_ptr(a);
38173         a_conv.is_owned = ptr_is_owned(a);
38174         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38175         a_conv.is_owned = false;
38176         LDKAnnouncementSignatures b_conv;
38177         b_conv.inner = untag_ptr(b);
38178         b_conv.is_owned = ptr_is_owned(b);
38179         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38180         b_conv.is_owned = false;
38181         jboolean ret_conv = AnnouncementSignatures_eq(&a_conv, &b_conv);
38182         return ret_conv;
38183 }
38184
38185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38186         if (!ptr_is_owned(this_ptr)) return;
38187         void* this_ptr_ptr = untag_ptr(this_ptr);
38188         CHECK_ACCESS(this_ptr_ptr);
38189         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
38190         FREE(untag_ptr(this_ptr));
38191         NetAddress_free(this_ptr_conv);
38192 }
38193
38194 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
38195         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38196         *ret_copy = NetAddress_clone(arg);
38197         int64_t ret_ref = tag_ptr(ret_copy, true);
38198         return ret_ref;
38199 }
38200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38201         LDKNetAddress* arg_conv = (LDKNetAddress*)untag_ptr(arg);
38202         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
38203         return ret_conv;
38204 }
38205
38206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38207         LDKNetAddress* orig_conv = (LDKNetAddress*)untag_ptr(orig);
38208         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38209         *ret_copy = NetAddress_clone(orig_conv);
38210         int64_t ret_ref = tag_ptr(ret_copy, true);
38211         return ret_ref;
38212 }
38213
38214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
38215         LDKFourBytes addr_ref;
38216         CHECK((*env)->GetArrayLength(env, addr) == 4);
38217         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
38218         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38219         *ret_copy = NetAddress_ipv4(addr_ref, port);
38220         int64_t ret_ref = tag_ptr(ret_copy, true);
38221         return ret_ref;
38222 }
38223
38224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
38225         LDKSixteenBytes addr_ref;
38226         CHECK((*env)->GetArrayLength(env, addr) == 16);
38227         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
38228         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38229         *ret_copy = NetAddress_ipv6(addr_ref, port);
38230         int64_t ret_ref = tag_ptr(ret_copy, true);
38231         return ret_ref;
38232 }
38233
38234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
38235         LDKTwelveBytes a_ref;
38236         CHECK((*env)->GetArrayLength(env, a) == 12);
38237         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
38238         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38239         *ret_copy = NetAddress_onion_v2(a_ref);
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_NetAddress_1onion_1v3(JNIEnv *env, jclass clz, int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
38245         LDKThirtyTwoBytes ed25519_pubkey_ref;
38246         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
38247         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
38248         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38249         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
38250         int64_t ret_ref = tag_ptr(ret_copy, true);
38251         return ret_ref;
38252 }
38253
38254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
38255         LDKHostname hostname_conv;
38256         hostname_conv.inner = untag_ptr(hostname);
38257         hostname_conv.is_owned = ptr_is_owned(hostname);
38258         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
38259         hostname_conv = Hostname_clone(&hostname_conv);
38260         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38261         *ret_copy = NetAddress_hostname(hostname_conv, port);
38262         int64_t ret_ref = tag_ptr(ret_copy, true);
38263         return ret_ref;
38264 }
38265
38266 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetAddress_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38267         LDKNetAddress* a_conv = (LDKNetAddress*)untag_ptr(a);
38268         LDKNetAddress* b_conv = (LDKNetAddress*)untag_ptr(b);
38269         jboolean ret_conv = NetAddress_eq(a_conv, b_conv);
38270         return ret_conv;
38271 }
38272
38273 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
38274         LDKNetAddress* obj_conv = (LDKNetAddress*)untag_ptr(obj);
38275         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
38276         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38277         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38278         CVec_u8Z_free(ret_var);
38279         return ret_arr;
38280 }
38281
38282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38283         LDKu8slice ser_ref;
38284         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38285         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38286         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
38287         *ret_conv = NetAddress_read(ser_ref);
38288         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38289         return tag_ptr(ret_conv, true);
38290 }
38291
38292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38293         if (!ptr_is_owned(this_ptr)) return;
38294         void* this_ptr_ptr = untag_ptr(this_ptr);
38295         CHECK_ACCESS(this_ptr_ptr);
38296         LDKUnsignedGossipMessage this_ptr_conv = *(LDKUnsignedGossipMessage*)(this_ptr_ptr);
38297         FREE(untag_ptr(this_ptr));
38298         UnsignedGossipMessage_free(this_ptr_conv);
38299 }
38300
38301 static inline uint64_t UnsignedGossipMessage_clone_ptr(LDKUnsignedGossipMessage *NONNULL_PTR arg) {
38302         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38303         *ret_copy = UnsignedGossipMessage_clone(arg);
38304         int64_t ret_ref = tag_ptr(ret_copy, true);
38305         return ret_ref;
38306 }
38307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38308         LDKUnsignedGossipMessage* arg_conv = (LDKUnsignedGossipMessage*)untag_ptr(arg);
38309         int64_t ret_conv = UnsignedGossipMessage_clone_ptr(arg_conv);
38310         return ret_conv;
38311 }
38312
38313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38314         LDKUnsignedGossipMessage* orig_conv = (LDKUnsignedGossipMessage*)untag_ptr(orig);
38315         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38316         *ret_copy = UnsignedGossipMessage_clone(orig_conv);
38317         int64_t ret_ref = tag_ptr(ret_copy, true);
38318         return ret_ref;
38319 }
38320
38321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1channel_1announcement(JNIEnv *env, jclass clz, int64_t a) {
38322         LDKUnsignedChannelAnnouncement a_conv;
38323         a_conv.inner = untag_ptr(a);
38324         a_conv.is_owned = ptr_is_owned(a);
38325         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38326         a_conv = UnsignedChannelAnnouncement_clone(&a_conv);
38327         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38328         *ret_copy = UnsignedGossipMessage_channel_announcement(a_conv);
38329         int64_t ret_ref = tag_ptr(ret_copy, true);
38330         return ret_ref;
38331 }
38332
38333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1channel_1update(JNIEnv *env, jclass clz, int64_t a) {
38334         LDKUnsignedChannelUpdate a_conv;
38335         a_conv.inner = untag_ptr(a);
38336         a_conv.is_owned = ptr_is_owned(a);
38337         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38338         a_conv = UnsignedChannelUpdate_clone(&a_conv);
38339         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38340         *ret_copy = UnsignedGossipMessage_channel_update(a_conv);
38341         int64_t ret_ref = tag_ptr(ret_copy, true);
38342         return ret_ref;
38343 }
38344
38345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1node_1announcement(JNIEnv *env, jclass clz, int64_t a) {
38346         LDKUnsignedNodeAnnouncement a_conv;
38347         a_conv.inner = untag_ptr(a);
38348         a_conv.is_owned = ptr_is_owned(a);
38349         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38350         a_conv = UnsignedNodeAnnouncement_clone(&a_conv);
38351         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38352         *ret_copy = UnsignedGossipMessage_node_announcement(a_conv);
38353         int64_t ret_ref = tag_ptr(ret_copy, true);
38354         return ret_ref;
38355 }
38356
38357 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
38358         LDKUnsignedGossipMessage* obj_conv = (LDKUnsignedGossipMessage*)untag_ptr(obj);
38359         LDKCVec_u8Z ret_var = UnsignedGossipMessage_write(obj_conv);
38360         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38361         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38362         CVec_u8Z_free(ret_var);
38363         return ret_arr;
38364 }
38365
38366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38367         LDKUnsignedNodeAnnouncement this_obj_conv;
38368         this_obj_conv.inner = untag_ptr(this_obj);
38369         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38371         UnsignedNodeAnnouncement_free(this_obj_conv);
38372 }
38373
38374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
38375         LDKUnsignedNodeAnnouncement this_ptr_conv;
38376         this_ptr_conv.inner = untag_ptr(this_ptr);
38377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38379         this_ptr_conv.is_owned = false;
38380         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
38381         int64_t ret_ref = 0;
38382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38383         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38384         return ret_ref;
38385 }
38386
38387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38388         LDKUnsignedNodeAnnouncement this_ptr_conv;
38389         this_ptr_conv.inner = untag_ptr(this_ptr);
38390         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38392         this_ptr_conv.is_owned = false;
38393         LDKNodeFeatures val_conv;
38394         val_conv.inner = untag_ptr(val);
38395         val_conv.is_owned = ptr_is_owned(val);
38396         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38397         val_conv = NodeFeatures_clone(&val_conv);
38398         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
38399 }
38400
38401 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
38402         LDKUnsignedNodeAnnouncement this_ptr_conv;
38403         this_ptr_conv.inner = untag_ptr(this_ptr);
38404         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38406         this_ptr_conv.is_owned = false;
38407         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
38408         return ret_conv;
38409 }
38410
38411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38412         LDKUnsignedNodeAnnouncement this_ptr_conv;
38413         this_ptr_conv.inner = untag_ptr(this_ptr);
38414         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38416         this_ptr_conv.is_owned = false;
38417         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
38418 }
38419
38420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38421         LDKUnsignedNodeAnnouncement this_ptr_conv;
38422         this_ptr_conv.inner = untag_ptr(this_ptr);
38423         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38425         this_ptr_conv.is_owned = false;
38426         LDKNodeId ret_var = UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv);
38427         int64_t ret_ref = 0;
38428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38429         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38430         return ret_ref;
38431 }
38432
38433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38434         LDKUnsignedNodeAnnouncement this_ptr_conv;
38435         this_ptr_conv.inner = untag_ptr(this_ptr);
38436         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38438         this_ptr_conv.is_owned = false;
38439         LDKNodeId val_conv;
38440         val_conv.inner = untag_ptr(val);
38441         val_conv.is_owned = ptr_is_owned(val);
38442         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38443         val_conv = NodeId_clone(&val_conv);
38444         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_conv);
38445 }
38446
38447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
38448         LDKUnsignedNodeAnnouncement this_ptr_conv;
38449         this_ptr_conv.inner = untag_ptr(this_ptr);
38450         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38452         this_ptr_conv.is_owned = false;
38453         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
38454         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
38455         return ret_arr;
38456 }
38457
38458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38459         LDKUnsignedNodeAnnouncement this_ptr_conv;
38460         this_ptr_conv.inner = untag_ptr(this_ptr);
38461         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38463         this_ptr_conv.is_owned = false;
38464         LDKThreeBytes val_ref;
38465         CHECK((*env)->GetArrayLength(env, val) == 3);
38466         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
38467         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
38468 }
38469
38470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
38471         LDKUnsignedNodeAnnouncement this_ptr_conv;
38472         this_ptr_conv.inner = untag_ptr(this_ptr);
38473         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38475         this_ptr_conv.is_owned = false;
38476         LDKNodeAlias ret_var = UnsignedNodeAnnouncement_get_alias(&this_ptr_conv);
38477         int64_t ret_ref = 0;
38478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38479         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38480         return ret_ref;
38481 }
38482
38483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38484         LDKUnsignedNodeAnnouncement this_ptr_conv;
38485         this_ptr_conv.inner = untag_ptr(this_ptr);
38486         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38488         this_ptr_conv.is_owned = false;
38489         LDKNodeAlias val_conv;
38490         val_conv.inner = untag_ptr(val);
38491         val_conv.is_owned = ptr_is_owned(val);
38492         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38493         val_conv = NodeAlias_clone(&val_conv);
38494         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_conv);
38495 }
38496
38497 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
38498         LDKUnsignedNodeAnnouncement this_ptr_conv;
38499         this_ptr_conv.inner = untag_ptr(this_ptr);
38500         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38502         this_ptr_conv.is_owned = false;
38503         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
38504         int64_tArray ret_arr = NULL;
38505         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38506         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38507         for (size_t m = 0; m < ret_var.datalen; m++) {
38508                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38509                 *ret_conv_12_copy = ret_var.data[m];
38510                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
38511                 ret_arr_ptr[m] = ret_conv_12_ref;
38512         }
38513         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38514         FREE(ret_var.data);
38515         return ret_arr;
38516 }
38517
38518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38519         LDKUnsignedNodeAnnouncement this_ptr_conv;
38520         this_ptr_conv.inner = untag_ptr(this_ptr);
38521         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38523         this_ptr_conv.is_owned = false;
38524         LDKCVec_NetAddressZ val_constr;
38525         val_constr.datalen = (*env)->GetArrayLength(env, val);
38526         if (val_constr.datalen > 0)
38527                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
38528         else
38529                 val_constr.data = NULL;
38530         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38531         for (size_t m = 0; m < val_constr.datalen; m++) {
38532                 int64_t val_conv_12 = val_vals[m];
38533                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
38534                 CHECK_ACCESS(val_conv_12_ptr);
38535                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
38536                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
38537                 val_constr.data[m] = val_conv_12_conv;
38538         }
38539         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38540         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
38541 }
38542
38543 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
38544         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38551         LDKUnsignedNodeAnnouncement arg_conv;
38552         arg_conv.inner = untag_ptr(arg);
38553         arg_conv.is_owned = ptr_is_owned(arg);
38554         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38555         arg_conv.is_owned = false;
38556         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
38557         return ret_conv;
38558 }
38559
38560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38561         LDKUnsignedNodeAnnouncement orig_conv;
38562         orig_conv.inner = untag_ptr(orig);
38563         orig_conv.is_owned = ptr_is_owned(orig);
38564         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38565         orig_conv.is_owned = false;
38566         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
38567         int64_t ret_ref = 0;
38568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38569         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38570         return ret_ref;
38571 }
38572
38573 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38574         LDKUnsignedNodeAnnouncement a_conv;
38575         a_conv.inner = untag_ptr(a);
38576         a_conv.is_owned = ptr_is_owned(a);
38577         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38578         a_conv.is_owned = false;
38579         LDKUnsignedNodeAnnouncement b_conv;
38580         b_conv.inner = untag_ptr(b);
38581         b_conv.is_owned = ptr_is_owned(b);
38582         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38583         b_conv.is_owned = false;
38584         jboolean ret_conv = UnsignedNodeAnnouncement_eq(&a_conv, &b_conv);
38585         return ret_conv;
38586 }
38587
38588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38589         LDKNodeAnnouncement this_obj_conv;
38590         this_obj_conv.inner = untag_ptr(this_obj);
38591         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38593         NodeAnnouncement_free(this_obj_conv);
38594 }
38595
38596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38597         LDKNodeAnnouncement this_ptr_conv;
38598         this_ptr_conv.inner = untag_ptr(this_ptr);
38599         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38601         this_ptr_conv.is_owned = false;
38602         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38603         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
38604         return ret_arr;
38605 }
38606
38607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38608         LDKNodeAnnouncement this_ptr_conv;
38609         this_ptr_conv.inner = untag_ptr(this_ptr);
38610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38612         this_ptr_conv.is_owned = false;
38613         LDKSignature val_ref;
38614         CHECK((*env)->GetArrayLength(env, val) == 64);
38615         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38616         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
38617 }
38618
38619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
38620         LDKNodeAnnouncement this_ptr_conv;
38621         this_ptr_conv.inner = untag_ptr(this_ptr);
38622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38624         this_ptr_conv.is_owned = false;
38625         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
38626         int64_t ret_ref = 0;
38627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38628         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38629         return ret_ref;
38630 }
38631
38632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38633         LDKNodeAnnouncement this_ptr_conv;
38634         this_ptr_conv.inner = untag_ptr(this_ptr);
38635         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38637         this_ptr_conv.is_owned = false;
38638         LDKUnsignedNodeAnnouncement val_conv;
38639         val_conv.inner = untag_ptr(val);
38640         val_conv.is_owned = ptr_is_owned(val);
38641         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38642         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
38643         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
38644 }
38645
38646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
38647         LDKSignature signature_arg_ref;
38648         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
38649         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
38650         LDKUnsignedNodeAnnouncement contents_arg_conv;
38651         contents_arg_conv.inner = untag_ptr(contents_arg);
38652         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
38653         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
38654         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
38655         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
38656         int64_t ret_ref = 0;
38657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38658         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38659         return ret_ref;
38660 }
38661
38662 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
38663         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
38664         int64_t ret_ref = 0;
38665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38666         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38667         return ret_ref;
38668 }
38669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38670         LDKNodeAnnouncement arg_conv;
38671         arg_conv.inner = untag_ptr(arg);
38672         arg_conv.is_owned = ptr_is_owned(arg);
38673         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38674         arg_conv.is_owned = false;
38675         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
38676         return ret_conv;
38677 }
38678
38679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38680         LDKNodeAnnouncement orig_conv;
38681         orig_conv.inner = untag_ptr(orig);
38682         orig_conv.is_owned = ptr_is_owned(orig);
38683         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38684         orig_conv.is_owned = false;
38685         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
38686         int64_t ret_ref = 0;
38687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38688         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38689         return ret_ref;
38690 }
38691
38692 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38693         LDKNodeAnnouncement a_conv;
38694         a_conv.inner = untag_ptr(a);
38695         a_conv.is_owned = ptr_is_owned(a);
38696         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38697         a_conv.is_owned = false;
38698         LDKNodeAnnouncement b_conv;
38699         b_conv.inner = untag_ptr(b);
38700         b_conv.is_owned = ptr_is_owned(b);
38701         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38702         b_conv.is_owned = false;
38703         jboolean ret_conv = NodeAnnouncement_eq(&a_conv, &b_conv);
38704         return ret_conv;
38705 }
38706
38707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38708         LDKUnsignedChannelAnnouncement this_obj_conv;
38709         this_obj_conv.inner = untag_ptr(this_obj);
38710         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38712         UnsignedChannelAnnouncement_free(this_obj_conv);
38713 }
38714
38715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
38716         LDKUnsignedChannelAnnouncement this_ptr_conv;
38717         this_ptr_conv.inner = untag_ptr(this_ptr);
38718         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38720         this_ptr_conv.is_owned = false;
38721         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
38722         int64_t ret_ref = 0;
38723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38724         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38725         return ret_ref;
38726 }
38727
38728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38729         LDKUnsignedChannelAnnouncement this_ptr_conv;
38730         this_ptr_conv.inner = untag_ptr(this_ptr);
38731         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38733         this_ptr_conv.is_owned = false;
38734         LDKChannelFeatures val_conv;
38735         val_conv.inner = untag_ptr(val);
38736         val_conv.is_owned = ptr_is_owned(val);
38737         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38738         val_conv = ChannelFeatures_clone(&val_conv);
38739         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
38740 }
38741
38742 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38743         LDKUnsignedChannelAnnouncement this_ptr_conv;
38744         this_ptr_conv.inner = untag_ptr(this_ptr);
38745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38747         this_ptr_conv.is_owned = false;
38748         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38749         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
38750         return ret_arr;
38751 }
38752
38753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38754         LDKUnsignedChannelAnnouncement this_ptr_conv;
38755         this_ptr_conv.inner = untag_ptr(this_ptr);
38756         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38758         this_ptr_conv.is_owned = false;
38759         LDKThirtyTwoBytes val_ref;
38760         CHECK((*env)->GetArrayLength(env, val) == 32);
38761         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38762         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
38763 }
38764
38765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38766         LDKUnsignedChannelAnnouncement this_ptr_conv;
38767         this_ptr_conv.inner = untag_ptr(this_ptr);
38768         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38770         this_ptr_conv.is_owned = false;
38771         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
38772         return ret_conv;
38773 }
38774
38775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38776         LDKUnsignedChannelAnnouncement this_ptr_conv;
38777         this_ptr_conv.inner = untag_ptr(this_ptr);
38778         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38780         this_ptr_conv.is_owned = false;
38781         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
38782 }
38783
38784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(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_node_id_1(&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_1node_1id_11(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_node_id_1(&this_ptr_conv, val_conv);
38809 }
38810
38811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38812         LDKUnsignedChannelAnnouncement this_ptr_conv;
38813         this_ptr_conv.inner = untag_ptr(this_ptr);
38814         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38816         this_ptr_conv.is_owned = false;
38817         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv);
38818         int64_t ret_ref = 0;
38819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38820         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38821         return ret_ref;
38822 }
38823
38824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38825         LDKUnsignedChannelAnnouncement this_ptr_conv;
38826         this_ptr_conv.inner = untag_ptr(this_ptr);
38827         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38829         this_ptr_conv.is_owned = false;
38830         LDKNodeId val_conv;
38831         val_conv.inner = untag_ptr(val);
38832         val_conv.is_owned = ptr_is_owned(val);
38833         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38834         val_conv = NodeId_clone(&val_conv);
38835         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_conv);
38836 }
38837
38838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38839         LDKUnsignedChannelAnnouncement this_ptr_conv;
38840         this_ptr_conv.inner = untag_ptr(this_ptr);
38841         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38843         this_ptr_conv.is_owned = false;
38844         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv);
38845         int64_t ret_ref = 0;
38846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38848         return ret_ref;
38849 }
38850
38851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38852         LDKUnsignedChannelAnnouncement this_ptr_conv;
38853         this_ptr_conv.inner = untag_ptr(this_ptr);
38854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38856         this_ptr_conv.is_owned = false;
38857         LDKNodeId val_conv;
38858         val_conv.inner = untag_ptr(val);
38859         val_conv.is_owned = ptr_is_owned(val);
38860         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38861         val_conv = NodeId_clone(&val_conv);
38862         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_conv);
38863 }
38864
38865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38866         LDKUnsignedChannelAnnouncement this_ptr_conv;
38867         this_ptr_conv.inner = untag_ptr(this_ptr);
38868         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38870         this_ptr_conv.is_owned = false;
38871         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv);
38872         int64_t ret_ref = 0;
38873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38874         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38875         return ret_ref;
38876 }
38877
38878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38879         LDKUnsignedChannelAnnouncement this_ptr_conv;
38880         this_ptr_conv.inner = untag_ptr(this_ptr);
38881         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38883         this_ptr_conv.is_owned = false;
38884         LDKNodeId val_conv;
38885         val_conv.inner = untag_ptr(val);
38886         val_conv.is_owned = ptr_is_owned(val);
38887         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38888         val_conv = NodeId_clone(&val_conv);
38889         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_conv);
38890 }
38891
38892 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
38893         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
38894         int64_t ret_ref = 0;
38895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38896         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38897         return ret_ref;
38898 }
38899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38900         LDKUnsignedChannelAnnouncement arg_conv;
38901         arg_conv.inner = untag_ptr(arg);
38902         arg_conv.is_owned = ptr_is_owned(arg);
38903         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38904         arg_conv.is_owned = false;
38905         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
38906         return ret_conv;
38907 }
38908
38909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38910         LDKUnsignedChannelAnnouncement orig_conv;
38911         orig_conv.inner = untag_ptr(orig);
38912         orig_conv.is_owned = ptr_is_owned(orig);
38913         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38914         orig_conv.is_owned = false;
38915         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
38916         int64_t ret_ref = 0;
38917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38918         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38919         return ret_ref;
38920 }
38921
38922 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38923         LDKUnsignedChannelAnnouncement a_conv;
38924         a_conv.inner = untag_ptr(a);
38925         a_conv.is_owned = ptr_is_owned(a);
38926         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38927         a_conv.is_owned = false;
38928         LDKUnsignedChannelAnnouncement b_conv;
38929         b_conv.inner = untag_ptr(b);
38930         b_conv.is_owned = ptr_is_owned(b);
38931         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38932         b_conv.is_owned = false;
38933         jboolean ret_conv = UnsignedChannelAnnouncement_eq(&a_conv, &b_conv);
38934         return ret_conv;
38935 }
38936
38937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38938         LDKChannelAnnouncement this_obj_conv;
38939         this_obj_conv.inner = untag_ptr(this_obj);
38940         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38942         ChannelAnnouncement_free(this_obj_conv);
38943 }
38944
38945 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38946         LDKChannelAnnouncement this_ptr_conv;
38947         this_ptr_conv.inner = untag_ptr(this_ptr);
38948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38950         this_ptr_conv.is_owned = false;
38951         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38952         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
38953         return ret_arr;
38954 }
38955
38956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
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         LDKSignature val_ref;
38963         CHECK((*env)->GetArrayLength(env, val) == 64);
38964         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38965         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
38966 }
38967
38968 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38969         LDKChannelAnnouncement this_ptr_conv;
38970         this_ptr_conv.inner = untag_ptr(this_ptr);
38971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38973         this_ptr_conv.is_owned = false;
38974         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38975         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
38976         return ret_arr;
38977 }
38978
38979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38980         LDKChannelAnnouncement this_ptr_conv;
38981         this_ptr_conv.inner = untag_ptr(this_ptr);
38982         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38984         this_ptr_conv.is_owned = false;
38985         LDKSignature val_ref;
38986         CHECK((*env)->GetArrayLength(env, val) == 64);
38987         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38988         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
38989 }
38990
38991 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38992         LDKChannelAnnouncement this_ptr_conv;
38993         this_ptr_conv.inner = untag_ptr(this_ptr);
38994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38996         this_ptr_conv.is_owned = false;
38997         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38998         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
38999         return ret_arr;
39000 }
39001
39002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39003         LDKChannelAnnouncement this_ptr_conv;
39004         this_ptr_conv.inner = untag_ptr(this_ptr);
39005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39007         this_ptr_conv.is_owned = false;
39008         LDKSignature val_ref;
39009         CHECK((*env)->GetArrayLength(env, val) == 64);
39010         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
39011         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
39012 }
39013
39014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
39015         LDKChannelAnnouncement this_ptr_conv;
39016         this_ptr_conv.inner = untag_ptr(this_ptr);
39017         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39019         this_ptr_conv.is_owned = false;
39020         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39021         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
39022         return ret_arr;
39023 }
39024
39025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39026         LDKChannelAnnouncement this_ptr_conv;
39027         this_ptr_conv.inner = untag_ptr(this_ptr);
39028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39030         this_ptr_conv.is_owned = false;
39031         LDKSignature val_ref;
39032         CHECK((*env)->GetArrayLength(env, val) == 64);
39033         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
39034         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
39035 }
39036
39037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
39038         LDKChannelAnnouncement this_ptr_conv;
39039         this_ptr_conv.inner = untag_ptr(this_ptr);
39040         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39042         this_ptr_conv.is_owned = false;
39043         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
39044         int64_t ret_ref = 0;
39045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39046         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39047         return ret_ref;
39048 }
39049
39050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39051         LDKChannelAnnouncement this_ptr_conv;
39052         this_ptr_conv.inner = untag_ptr(this_ptr);
39053         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39055         this_ptr_conv.is_owned = false;
39056         LDKUnsignedChannelAnnouncement val_conv;
39057         val_conv.inner = untag_ptr(val);
39058         val_conv.is_owned = ptr_is_owned(val);
39059         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39060         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
39061         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
39062 }
39063
39064 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) {
39065         LDKSignature node_signature_1_arg_ref;
39066         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
39067         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
39068         LDKSignature node_signature_2_arg_ref;
39069         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
39070         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
39071         LDKSignature bitcoin_signature_1_arg_ref;
39072         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
39073         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
39074         LDKSignature bitcoin_signature_2_arg_ref;
39075         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
39076         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
39077         LDKUnsignedChannelAnnouncement contents_arg_conv;
39078         contents_arg_conv.inner = untag_ptr(contents_arg);
39079         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
39080         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
39081         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
39082         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);
39083         int64_t ret_ref = 0;
39084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39085         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39086         return ret_ref;
39087 }
39088
39089 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
39090         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
39091         int64_t ret_ref = 0;
39092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39093         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39094         return ret_ref;
39095 }
39096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39097         LDKChannelAnnouncement arg_conv;
39098         arg_conv.inner = untag_ptr(arg);
39099         arg_conv.is_owned = ptr_is_owned(arg);
39100         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39101         arg_conv.is_owned = false;
39102         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
39103         return ret_conv;
39104 }
39105
39106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39107         LDKChannelAnnouncement orig_conv;
39108         orig_conv.inner = untag_ptr(orig);
39109         orig_conv.is_owned = ptr_is_owned(orig);
39110         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39111         orig_conv.is_owned = false;
39112         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
39113         int64_t ret_ref = 0;
39114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39115         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39116         return ret_ref;
39117 }
39118
39119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39120         LDKChannelAnnouncement a_conv;
39121         a_conv.inner = untag_ptr(a);
39122         a_conv.is_owned = ptr_is_owned(a);
39123         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39124         a_conv.is_owned = false;
39125         LDKChannelAnnouncement b_conv;
39126         b_conv.inner = untag_ptr(b);
39127         b_conv.is_owned = ptr_is_owned(b);
39128         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39129         b_conv.is_owned = false;
39130         jboolean ret_conv = ChannelAnnouncement_eq(&a_conv, &b_conv);
39131         return ret_conv;
39132 }
39133
39134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39135         LDKUnsignedChannelUpdate this_obj_conv;
39136         this_obj_conv.inner = untag_ptr(this_obj);
39137         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39139         UnsignedChannelUpdate_free(this_obj_conv);
39140 }
39141
39142 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39143         LDKUnsignedChannelUpdate this_ptr_conv;
39144         this_ptr_conv.inner = untag_ptr(this_ptr);
39145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39147         this_ptr_conv.is_owned = false;
39148         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39149         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
39150         return ret_arr;
39151 }
39152
39153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39154         LDKUnsignedChannelUpdate this_ptr_conv;
39155         this_ptr_conv.inner = untag_ptr(this_ptr);
39156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39158         this_ptr_conv.is_owned = false;
39159         LDKThirtyTwoBytes val_ref;
39160         CHECK((*env)->GetArrayLength(env, val) == 32);
39161         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39162         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
39163 }
39164
39165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
39166         LDKUnsignedChannelUpdate this_ptr_conv;
39167         this_ptr_conv.inner = untag_ptr(this_ptr);
39168         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39170         this_ptr_conv.is_owned = false;
39171         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
39172         return ret_conv;
39173 }
39174
39175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39176         LDKUnsignedChannelUpdate this_ptr_conv;
39177         this_ptr_conv.inner = untag_ptr(this_ptr);
39178         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39180         this_ptr_conv.is_owned = false;
39181         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
39182 }
39183
39184 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
39185         LDKUnsignedChannelUpdate this_ptr_conv;
39186         this_ptr_conv.inner = untag_ptr(this_ptr);
39187         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39189         this_ptr_conv.is_owned = false;
39190         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
39191         return ret_conv;
39192 }
39193
39194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39195         LDKUnsignedChannelUpdate this_ptr_conv;
39196         this_ptr_conv.inner = untag_ptr(this_ptr);
39197         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39199         this_ptr_conv.is_owned = false;
39200         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
39201 }
39202
39203 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
39204         LDKUnsignedChannelUpdate this_ptr_conv;
39205         this_ptr_conv.inner = untag_ptr(this_ptr);
39206         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39208         this_ptr_conv.is_owned = false;
39209         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
39210         return ret_conv;
39211 }
39212
39213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
39214         LDKUnsignedChannelUpdate this_ptr_conv;
39215         this_ptr_conv.inner = untag_ptr(this_ptr);
39216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39218         this_ptr_conv.is_owned = false;
39219         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
39220 }
39221
39222 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
39223         LDKUnsignedChannelUpdate this_ptr_conv;
39224         this_ptr_conv.inner = untag_ptr(this_ptr);
39225         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39227         this_ptr_conv.is_owned = false;
39228         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
39229         return ret_conv;
39230 }
39231
39232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39233         LDKUnsignedChannelUpdate this_ptr_conv;
39234         this_ptr_conv.inner = untag_ptr(this_ptr);
39235         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39237         this_ptr_conv.is_owned = false;
39238         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
39239 }
39240
39241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39242         LDKUnsignedChannelUpdate this_ptr_conv;
39243         this_ptr_conv.inner = untag_ptr(this_ptr);
39244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39246         this_ptr_conv.is_owned = false;
39247         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
39248         return ret_conv;
39249 }
39250
39251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39252         LDKUnsignedChannelUpdate this_ptr_conv;
39253         this_ptr_conv.inner = untag_ptr(this_ptr);
39254         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39256         this_ptr_conv.is_owned = false;
39257         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
39258 }
39259
39260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39261         LDKUnsignedChannelUpdate this_ptr_conv;
39262         this_ptr_conv.inner = untag_ptr(this_ptr);
39263         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39265         this_ptr_conv.is_owned = false;
39266         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
39267         return ret_conv;
39268 }
39269
39270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39271         LDKUnsignedChannelUpdate this_ptr_conv;
39272         this_ptr_conv.inner = untag_ptr(this_ptr);
39273         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39275         this_ptr_conv.is_owned = false;
39276         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
39277 }
39278
39279 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39280         LDKUnsignedChannelUpdate this_ptr_conv;
39281         this_ptr_conv.inner = untag_ptr(this_ptr);
39282         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39284         this_ptr_conv.is_owned = false;
39285         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
39286         return ret_conv;
39287 }
39288
39289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39290         LDKUnsignedChannelUpdate this_ptr_conv;
39291         this_ptr_conv.inner = untag_ptr(this_ptr);
39292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39294         this_ptr_conv.is_owned = false;
39295         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
39296 }
39297
39298 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
39299         LDKUnsignedChannelUpdate this_ptr_conv;
39300         this_ptr_conv.inner = untag_ptr(this_ptr);
39301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39303         this_ptr_conv.is_owned = false;
39304         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
39305         return ret_conv;
39306 }
39307
39308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39309         LDKUnsignedChannelUpdate this_ptr_conv;
39310         this_ptr_conv.inner = untag_ptr(this_ptr);
39311         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39313         this_ptr_conv.is_owned = false;
39314         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
39315 }
39316
39317 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
39318         LDKUnsignedChannelUpdate this_ptr_conv;
39319         this_ptr_conv.inner = untag_ptr(this_ptr);
39320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39322         this_ptr_conv.is_owned = false;
39323         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
39324         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39325         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39326         CVec_u8Z_free(ret_var);
39327         return ret_arr;
39328 }
39329
39330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39331         LDKUnsignedChannelUpdate 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         LDKCVec_u8Z val_ref;
39337         val_ref.datalen = (*env)->GetArrayLength(env, val);
39338         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
39339         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
39340         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
39341 }
39342
39343 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) {
39344         LDKThirtyTwoBytes chain_hash_arg_ref;
39345         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39346         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39347         LDKCVec_u8Z excess_data_arg_ref;
39348         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
39349         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
39350         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
39351         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);
39352         int64_t ret_ref = 0;
39353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39354         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39355         return ret_ref;
39356 }
39357
39358 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
39359         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39366         LDKUnsignedChannelUpdate arg_conv;
39367         arg_conv.inner = untag_ptr(arg);
39368         arg_conv.is_owned = ptr_is_owned(arg);
39369         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39370         arg_conv.is_owned = false;
39371         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
39372         return ret_conv;
39373 }
39374
39375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39376         LDKUnsignedChannelUpdate orig_conv;
39377         orig_conv.inner = untag_ptr(orig);
39378         orig_conv.is_owned = ptr_is_owned(orig);
39379         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39380         orig_conv.is_owned = false;
39381         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
39382         int64_t ret_ref = 0;
39383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39384         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39385         return ret_ref;
39386 }
39387
39388 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39389         LDKUnsignedChannelUpdate a_conv;
39390         a_conv.inner = untag_ptr(a);
39391         a_conv.is_owned = ptr_is_owned(a);
39392         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39393         a_conv.is_owned = false;
39394         LDKUnsignedChannelUpdate b_conv;
39395         b_conv.inner = untag_ptr(b);
39396         b_conv.is_owned = ptr_is_owned(b);
39397         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39398         b_conv.is_owned = false;
39399         jboolean ret_conv = UnsignedChannelUpdate_eq(&a_conv, &b_conv);
39400         return ret_conv;
39401 }
39402
39403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39404         LDKChannelUpdate this_obj_conv;
39405         this_obj_conv.inner = untag_ptr(this_obj);
39406         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39408         ChannelUpdate_free(this_obj_conv);
39409 }
39410
39411 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
39412         LDKChannelUpdate this_ptr_conv;
39413         this_ptr_conv.inner = untag_ptr(this_ptr);
39414         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39416         this_ptr_conv.is_owned = false;
39417         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39418         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
39419         return ret_arr;
39420 }
39421
39422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39423         LDKChannelUpdate this_ptr_conv;
39424         this_ptr_conv.inner = untag_ptr(this_ptr);
39425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39427         this_ptr_conv.is_owned = false;
39428         LDKSignature val_ref;
39429         CHECK((*env)->GetArrayLength(env, val) == 64);
39430         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
39431         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
39432 }
39433
39434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
39435         LDKChannelUpdate this_ptr_conv;
39436         this_ptr_conv.inner = untag_ptr(this_ptr);
39437         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39439         this_ptr_conv.is_owned = false;
39440         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
39441         int64_t ret_ref = 0;
39442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39443         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39444         return ret_ref;
39445 }
39446
39447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39448         LDKChannelUpdate this_ptr_conv;
39449         this_ptr_conv.inner = untag_ptr(this_ptr);
39450         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39452         this_ptr_conv.is_owned = false;
39453         LDKUnsignedChannelUpdate val_conv;
39454         val_conv.inner = untag_ptr(val);
39455         val_conv.is_owned = ptr_is_owned(val);
39456         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39457         val_conv = UnsignedChannelUpdate_clone(&val_conv);
39458         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
39459 }
39460
39461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
39462         LDKSignature signature_arg_ref;
39463         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
39464         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
39465         LDKUnsignedChannelUpdate contents_arg_conv;
39466         contents_arg_conv.inner = untag_ptr(contents_arg);
39467         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
39468         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
39469         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
39470         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
39471         int64_t ret_ref = 0;
39472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39473         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39474         return ret_ref;
39475 }
39476
39477 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
39478         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
39479         int64_t ret_ref = 0;
39480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39481         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39482         return ret_ref;
39483 }
39484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39485         LDKChannelUpdate arg_conv;
39486         arg_conv.inner = untag_ptr(arg);
39487         arg_conv.is_owned = ptr_is_owned(arg);
39488         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39489         arg_conv.is_owned = false;
39490         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
39491         return ret_conv;
39492 }
39493
39494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39495         LDKChannelUpdate orig_conv;
39496         orig_conv.inner = untag_ptr(orig);
39497         orig_conv.is_owned = ptr_is_owned(orig);
39498         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39499         orig_conv.is_owned = false;
39500         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
39501         int64_t ret_ref = 0;
39502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39503         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39504         return ret_ref;
39505 }
39506
39507 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39508         LDKChannelUpdate a_conv;
39509         a_conv.inner = untag_ptr(a);
39510         a_conv.is_owned = ptr_is_owned(a);
39511         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39512         a_conv.is_owned = false;
39513         LDKChannelUpdate b_conv;
39514         b_conv.inner = untag_ptr(b);
39515         b_conv.is_owned = ptr_is_owned(b);
39516         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39517         b_conv.is_owned = false;
39518         jboolean ret_conv = ChannelUpdate_eq(&a_conv, &b_conv);
39519         return ret_conv;
39520 }
39521
39522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39523         LDKQueryChannelRange this_obj_conv;
39524         this_obj_conv.inner = untag_ptr(this_obj);
39525         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39527         QueryChannelRange_free(this_obj_conv);
39528 }
39529
39530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39531         LDKQueryChannelRange this_ptr_conv;
39532         this_ptr_conv.inner = untag_ptr(this_ptr);
39533         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39535         this_ptr_conv.is_owned = false;
39536         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39537         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
39538         return ret_arr;
39539 }
39540
39541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39542         LDKQueryChannelRange this_ptr_conv;
39543         this_ptr_conv.inner = untag_ptr(this_ptr);
39544         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39546         this_ptr_conv.is_owned = false;
39547         LDKThirtyTwoBytes val_ref;
39548         CHECK((*env)->GetArrayLength(env, val) == 32);
39549         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39550         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
39551 }
39552
39553 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
39554         LDKQueryChannelRange this_ptr_conv;
39555         this_ptr_conv.inner = untag_ptr(this_ptr);
39556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39558         this_ptr_conv.is_owned = false;
39559         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
39560         return ret_conv;
39561 }
39562
39563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39564         LDKQueryChannelRange this_ptr_conv;
39565         this_ptr_conv.inner = untag_ptr(this_ptr);
39566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39568         this_ptr_conv.is_owned = false;
39569         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
39570 }
39571
39572 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
39573         LDKQueryChannelRange this_ptr_conv;
39574         this_ptr_conv.inner = untag_ptr(this_ptr);
39575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39577         this_ptr_conv.is_owned = false;
39578         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
39579         return ret_conv;
39580 }
39581
39582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39583         LDKQueryChannelRange this_ptr_conv;
39584         this_ptr_conv.inner = untag_ptr(this_ptr);
39585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39587         this_ptr_conv.is_owned = false;
39588         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
39589 }
39590
39591 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) {
39592         LDKThirtyTwoBytes chain_hash_arg_ref;
39593         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39594         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39595         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
39596         int64_t ret_ref = 0;
39597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39598         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39599         return ret_ref;
39600 }
39601
39602 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
39603         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
39604         int64_t ret_ref = 0;
39605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39606         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39607         return ret_ref;
39608 }
39609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39610         LDKQueryChannelRange arg_conv;
39611         arg_conv.inner = untag_ptr(arg);
39612         arg_conv.is_owned = ptr_is_owned(arg);
39613         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39614         arg_conv.is_owned = false;
39615         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
39616         return ret_conv;
39617 }
39618
39619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39620         LDKQueryChannelRange orig_conv;
39621         orig_conv.inner = untag_ptr(orig);
39622         orig_conv.is_owned = ptr_is_owned(orig);
39623         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39624         orig_conv.is_owned = false;
39625         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
39626         int64_t ret_ref = 0;
39627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39628         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39629         return ret_ref;
39630 }
39631
39632 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39633         LDKQueryChannelRange a_conv;
39634         a_conv.inner = untag_ptr(a);
39635         a_conv.is_owned = ptr_is_owned(a);
39636         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39637         a_conv.is_owned = false;
39638         LDKQueryChannelRange b_conv;
39639         b_conv.inner = untag_ptr(b);
39640         b_conv.is_owned = ptr_is_owned(b);
39641         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39642         b_conv.is_owned = false;
39643         jboolean ret_conv = QueryChannelRange_eq(&a_conv, &b_conv);
39644         return ret_conv;
39645 }
39646
39647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39648         LDKReplyChannelRange this_obj_conv;
39649         this_obj_conv.inner = untag_ptr(this_obj);
39650         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39652         ReplyChannelRange_free(this_obj_conv);
39653 }
39654
39655 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39656         LDKReplyChannelRange this_ptr_conv;
39657         this_ptr_conv.inner = untag_ptr(this_ptr);
39658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39660         this_ptr_conv.is_owned = false;
39661         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39662         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
39663         return ret_arr;
39664 }
39665
39666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39667         LDKReplyChannelRange this_ptr_conv;
39668         this_ptr_conv.inner = untag_ptr(this_ptr);
39669         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39671         this_ptr_conv.is_owned = false;
39672         LDKThirtyTwoBytes val_ref;
39673         CHECK((*env)->GetArrayLength(env, val) == 32);
39674         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39675         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
39676 }
39677
39678 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
39679         LDKReplyChannelRange this_ptr_conv;
39680         this_ptr_conv.inner = untag_ptr(this_ptr);
39681         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39683         this_ptr_conv.is_owned = false;
39684         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
39685         return ret_conv;
39686 }
39687
39688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39689         LDKReplyChannelRange this_ptr_conv;
39690         this_ptr_conv.inner = untag_ptr(this_ptr);
39691         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39693         this_ptr_conv.is_owned = false;
39694         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
39695 }
39696
39697 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
39698         LDKReplyChannelRange this_ptr_conv;
39699         this_ptr_conv.inner = untag_ptr(this_ptr);
39700         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39702         this_ptr_conv.is_owned = false;
39703         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
39704         return ret_conv;
39705 }
39706
39707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39708         LDKReplyChannelRange this_ptr_conv;
39709         this_ptr_conv.inner = untag_ptr(this_ptr);
39710         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39712         this_ptr_conv.is_owned = false;
39713         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
39714 }
39715
39716 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
39717         LDKReplyChannelRange this_ptr_conv;
39718         this_ptr_conv.inner = untag_ptr(this_ptr);
39719         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39721         this_ptr_conv.is_owned = false;
39722         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
39723         return ret_conv;
39724 }
39725
39726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39727         LDKReplyChannelRange this_ptr_conv;
39728         this_ptr_conv.inner = untag_ptr(this_ptr);
39729         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39731         this_ptr_conv.is_owned = false;
39732         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
39733 }
39734
39735 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
39736         LDKReplyChannelRange this_ptr_conv;
39737         this_ptr_conv.inner = untag_ptr(this_ptr);
39738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39740         this_ptr_conv.is_owned = false;
39741         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
39742         int64_tArray ret_arr = NULL;
39743         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39744         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39745         for (size_t g = 0; g < ret_var.datalen; g++) {
39746                 int64_t ret_conv_6_conv = ret_var.data[g];
39747                 ret_arr_ptr[g] = ret_conv_6_conv;
39748         }
39749         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39750         FREE(ret_var.data);
39751         return ret_arr;
39752 }
39753
39754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39755         LDKReplyChannelRange this_ptr_conv;
39756         this_ptr_conv.inner = untag_ptr(this_ptr);
39757         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39759         this_ptr_conv.is_owned = false;
39760         LDKCVec_u64Z val_constr;
39761         val_constr.datalen = (*env)->GetArrayLength(env, val);
39762         if (val_constr.datalen > 0)
39763                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39764         else
39765                 val_constr.data = NULL;
39766         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39767         for (size_t g = 0; g < val_constr.datalen; g++) {
39768                 int64_t val_conv_6 = val_vals[g];
39769                 val_constr.data[g] = val_conv_6;
39770         }
39771         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39772         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
39773 }
39774
39775 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) {
39776         LDKThirtyTwoBytes chain_hash_arg_ref;
39777         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39778         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39779         LDKCVec_u64Z short_channel_ids_arg_constr;
39780         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
39781         if (short_channel_ids_arg_constr.datalen > 0)
39782                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39783         else
39784                 short_channel_ids_arg_constr.data = NULL;
39785         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
39786         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
39787                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
39788                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
39789         }
39790         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
39791         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
39792         int64_t ret_ref = 0;
39793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39794         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39795         return ret_ref;
39796 }
39797
39798 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
39799         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
39800         int64_t ret_ref = 0;
39801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39802         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39803         return ret_ref;
39804 }
39805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39806         LDKReplyChannelRange arg_conv;
39807         arg_conv.inner = untag_ptr(arg);
39808         arg_conv.is_owned = ptr_is_owned(arg);
39809         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39810         arg_conv.is_owned = false;
39811         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
39812         return ret_conv;
39813 }
39814
39815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39816         LDKReplyChannelRange orig_conv;
39817         orig_conv.inner = untag_ptr(orig);
39818         orig_conv.is_owned = ptr_is_owned(orig);
39819         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39820         orig_conv.is_owned = false;
39821         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
39822         int64_t ret_ref = 0;
39823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39824         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39825         return ret_ref;
39826 }
39827
39828 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39829         LDKReplyChannelRange a_conv;
39830         a_conv.inner = untag_ptr(a);
39831         a_conv.is_owned = ptr_is_owned(a);
39832         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39833         a_conv.is_owned = false;
39834         LDKReplyChannelRange b_conv;
39835         b_conv.inner = untag_ptr(b);
39836         b_conv.is_owned = ptr_is_owned(b);
39837         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39838         b_conv.is_owned = false;
39839         jboolean ret_conv = ReplyChannelRange_eq(&a_conv, &b_conv);
39840         return ret_conv;
39841 }
39842
39843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39844         LDKQueryShortChannelIds this_obj_conv;
39845         this_obj_conv.inner = untag_ptr(this_obj);
39846         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39848         QueryShortChannelIds_free(this_obj_conv);
39849 }
39850
39851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39852         LDKQueryShortChannelIds this_ptr_conv;
39853         this_ptr_conv.inner = untag_ptr(this_ptr);
39854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39856         this_ptr_conv.is_owned = false;
39857         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39858         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
39859         return ret_arr;
39860 }
39861
39862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39863         LDKQueryShortChannelIds this_ptr_conv;
39864         this_ptr_conv.inner = untag_ptr(this_ptr);
39865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39867         this_ptr_conv.is_owned = false;
39868         LDKThirtyTwoBytes val_ref;
39869         CHECK((*env)->GetArrayLength(env, val) == 32);
39870         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39871         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
39872 }
39873
39874 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
39875         LDKQueryShortChannelIds this_ptr_conv;
39876         this_ptr_conv.inner = untag_ptr(this_ptr);
39877         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39879         this_ptr_conv.is_owned = false;
39880         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
39881         int64_tArray ret_arr = NULL;
39882         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39883         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39884         for (size_t g = 0; g < ret_var.datalen; g++) {
39885                 int64_t ret_conv_6_conv = ret_var.data[g];
39886                 ret_arr_ptr[g] = ret_conv_6_conv;
39887         }
39888         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39889         FREE(ret_var.data);
39890         return ret_arr;
39891 }
39892
39893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39894         LDKQueryShortChannelIds this_ptr_conv;
39895         this_ptr_conv.inner = untag_ptr(this_ptr);
39896         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39898         this_ptr_conv.is_owned = false;
39899         LDKCVec_u64Z val_constr;
39900         val_constr.datalen = (*env)->GetArrayLength(env, val);
39901         if (val_constr.datalen > 0)
39902                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39903         else
39904                 val_constr.data = NULL;
39905         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39906         for (size_t g = 0; g < val_constr.datalen; g++) {
39907                 int64_t val_conv_6 = val_vals[g];
39908                 val_constr.data[g] = val_conv_6;
39909         }
39910         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39911         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
39912 }
39913
39914 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) {
39915         LDKThirtyTwoBytes chain_hash_arg_ref;
39916         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39917         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39918         LDKCVec_u64Z short_channel_ids_arg_constr;
39919         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
39920         if (short_channel_ids_arg_constr.datalen > 0)
39921                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39922         else
39923                 short_channel_ids_arg_constr.data = NULL;
39924         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
39925         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
39926                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
39927                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
39928         }
39929         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
39930         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
39931         int64_t ret_ref = 0;
39932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39933         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39934         return ret_ref;
39935 }
39936
39937 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
39938         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
39939         int64_t ret_ref = 0;
39940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39941         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39942         return ret_ref;
39943 }
39944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39945         LDKQueryShortChannelIds arg_conv;
39946         arg_conv.inner = untag_ptr(arg);
39947         arg_conv.is_owned = ptr_is_owned(arg);
39948         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39949         arg_conv.is_owned = false;
39950         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
39951         return ret_conv;
39952 }
39953
39954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39955         LDKQueryShortChannelIds orig_conv;
39956         orig_conv.inner = untag_ptr(orig);
39957         orig_conv.is_owned = ptr_is_owned(orig);
39958         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39959         orig_conv.is_owned = false;
39960         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
39961         int64_t ret_ref = 0;
39962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39963         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39964         return ret_ref;
39965 }
39966
39967 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39968         LDKQueryShortChannelIds a_conv;
39969         a_conv.inner = untag_ptr(a);
39970         a_conv.is_owned = ptr_is_owned(a);
39971         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39972         a_conv.is_owned = false;
39973         LDKQueryShortChannelIds b_conv;
39974         b_conv.inner = untag_ptr(b);
39975         b_conv.is_owned = ptr_is_owned(b);
39976         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39977         b_conv.is_owned = false;
39978         jboolean ret_conv = QueryShortChannelIds_eq(&a_conv, &b_conv);
39979         return ret_conv;
39980 }
39981
39982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39983         LDKReplyShortChannelIdsEnd this_obj_conv;
39984         this_obj_conv.inner = untag_ptr(this_obj);
39985         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39987         ReplyShortChannelIdsEnd_free(this_obj_conv);
39988 }
39989
39990 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39991         LDKReplyShortChannelIdsEnd this_ptr_conv;
39992         this_ptr_conv.inner = untag_ptr(this_ptr);
39993         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39995         this_ptr_conv.is_owned = false;
39996         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39997         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
39998         return ret_arr;
39999 }
40000
40001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40002         LDKReplyShortChannelIdsEnd this_ptr_conv;
40003         this_ptr_conv.inner = untag_ptr(this_ptr);
40004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40006         this_ptr_conv.is_owned = false;
40007         LDKThirtyTwoBytes val_ref;
40008         CHECK((*env)->GetArrayLength(env, val) == 32);
40009         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40010         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
40011 }
40012
40013 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
40014         LDKReplyShortChannelIdsEnd this_ptr_conv;
40015         this_ptr_conv.inner = untag_ptr(this_ptr);
40016         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40018         this_ptr_conv.is_owned = false;
40019         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
40020         return ret_conv;
40021 }
40022
40023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
40024         LDKReplyShortChannelIdsEnd this_ptr_conv;
40025         this_ptr_conv.inner = untag_ptr(this_ptr);
40026         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40028         this_ptr_conv.is_owned = false;
40029         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
40030 }
40031
40032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
40033         LDKThirtyTwoBytes chain_hash_arg_ref;
40034         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
40035         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
40036         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
40037         int64_t ret_ref = 0;
40038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40039         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40040         return ret_ref;
40041 }
40042
40043 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
40044         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
40045         int64_t ret_ref = 0;
40046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40047         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40048         return ret_ref;
40049 }
40050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40051         LDKReplyShortChannelIdsEnd arg_conv;
40052         arg_conv.inner = untag_ptr(arg);
40053         arg_conv.is_owned = ptr_is_owned(arg);
40054         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40055         arg_conv.is_owned = false;
40056         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
40057         return ret_conv;
40058 }
40059
40060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40061         LDKReplyShortChannelIdsEnd orig_conv;
40062         orig_conv.inner = untag_ptr(orig);
40063         orig_conv.is_owned = ptr_is_owned(orig);
40064         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40065         orig_conv.is_owned = false;
40066         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
40067         int64_t ret_ref = 0;
40068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40069         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40070         return ret_ref;
40071 }
40072
40073 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40074         LDKReplyShortChannelIdsEnd a_conv;
40075         a_conv.inner = untag_ptr(a);
40076         a_conv.is_owned = ptr_is_owned(a);
40077         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40078         a_conv.is_owned = false;
40079         LDKReplyShortChannelIdsEnd b_conv;
40080         b_conv.inner = untag_ptr(b);
40081         b_conv.is_owned = ptr_is_owned(b);
40082         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40083         b_conv.is_owned = false;
40084         jboolean ret_conv = ReplyShortChannelIdsEnd_eq(&a_conv, &b_conv);
40085         return ret_conv;
40086 }
40087
40088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40089         LDKGossipTimestampFilter this_obj_conv;
40090         this_obj_conv.inner = untag_ptr(this_obj);
40091         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40093         GossipTimestampFilter_free(this_obj_conv);
40094 }
40095
40096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
40097         LDKGossipTimestampFilter this_ptr_conv;
40098         this_ptr_conv.inner = untag_ptr(this_ptr);
40099         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40101         this_ptr_conv.is_owned = false;
40102         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40103         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
40104         return ret_arr;
40105 }
40106
40107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40108         LDKGossipTimestampFilter this_ptr_conv;
40109         this_ptr_conv.inner = untag_ptr(this_ptr);
40110         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40112         this_ptr_conv.is_owned = false;
40113         LDKThirtyTwoBytes val_ref;
40114         CHECK((*env)->GetArrayLength(env, val) == 32);
40115         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40116         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
40117 }
40118
40119 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
40120         LDKGossipTimestampFilter this_ptr_conv;
40121         this_ptr_conv.inner = untag_ptr(this_ptr);
40122         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40124         this_ptr_conv.is_owned = false;
40125         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
40126         return ret_conv;
40127 }
40128
40129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40130         LDKGossipTimestampFilter this_ptr_conv;
40131         this_ptr_conv.inner = untag_ptr(this_ptr);
40132         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40134         this_ptr_conv.is_owned = false;
40135         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
40136 }
40137
40138 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
40139         LDKGossipTimestampFilter this_ptr_conv;
40140         this_ptr_conv.inner = untag_ptr(this_ptr);
40141         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40143         this_ptr_conv.is_owned = false;
40144         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
40145         return ret_conv;
40146 }
40147
40148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40149         LDKGossipTimestampFilter this_ptr_conv;
40150         this_ptr_conv.inner = untag_ptr(this_ptr);
40151         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40153         this_ptr_conv.is_owned = false;
40154         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
40155 }
40156
40157 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) {
40158         LDKThirtyTwoBytes chain_hash_arg_ref;
40159         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
40160         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
40161         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
40162         int64_t ret_ref = 0;
40163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40164         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40165         return ret_ref;
40166 }
40167
40168 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
40169         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
40170         int64_t ret_ref = 0;
40171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40172         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40173         return ret_ref;
40174 }
40175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40176         LDKGossipTimestampFilter arg_conv;
40177         arg_conv.inner = untag_ptr(arg);
40178         arg_conv.is_owned = ptr_is_owned(arg);
40179         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40180         arg_conv.is_owned = false;
40181         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
40182         return ret_conv;
40183 }
40184
40185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40186         LDKGossipTimestampFilter orig_conv;
40187         orig_conv.inner = untag_ptr(orig);
40188         orig_conv.is_owned = ptr_is_owned(orig);
40189         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40190         orig_conv.is_owned = false;
40191         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
40192         int64_t ret_ref = 0;
40193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40194         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40195         return ret_ref;
40196 }
40197
40198 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40199         LDKGossipTimestampFilter a_conv;
40200         a_conv.inner = untag_ptr(a);
40201         a_conv.is_owned = ptr_is_owned(a);
40202         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40203         a_conv.is_owned = false;
40204         LDKGossipTimestampFilter b_conv;
40205         b_conv.inner = untag_ptr(b);
40206         b_conv.is_owned = ptr_is_owned(b);
40207         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40208         b_conv.is_owned = false;
40209         jboolean ret_conv = GossipTimestampFilter_eq(&a_conv, &b_conv);
40210         return ret_conv;
40211 }
40212
40213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40214         if (!ptr_is_owned(this_ptr)) return;
40215         void* this_ptr_ptr = untag_ptr(this_ptr);
40216         CHECK_ACCESS(this_ptr_ptr);
40217         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
40218         FREE(untag_ptr(this_ptr));
40219         ErrorAction_free(this_ptr_conv);
40220 }
40221
40222 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
40223         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40224         *ret_copy = ErrorAction_clone(arg);
40225         int64_t ret_ref = tag_ptr(ret_copy, true);
40226         return ret_ref;
40227 }
40228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40229         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
40230         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
40231         return ret_conv;
40232 }
40233
40234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40235         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
40236         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40237         *ret_copy = ErrorAction_clone(orig_conv);
40238         int64_t ret_ref = tag_ptr(ret_copy, true);
40239         return ret_ref;
40240 }
40241
40242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
40243         LDKErrorMessage msg_conv;
40244         msg_conv.inner = untag_ptr(msg);
40245         msg_conv.is_owned = ptr_is_owned(msg);
40246         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40247         msg_conv = ErrorMessage_clone(&msg_conv);
40248         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40249         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
40250         int64_t ret_ref = tag_ptr(ret_copy, true);
40251         return ret_ref;
40252 }
40253
40254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
40255         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40256         *ret_copy = ErrorAction_ignore_error();
40257         int64_t ret_ref = tag_ptr(ret_copy, true);
40258         return ret_ref;
40259 }
40260
40261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
40262         LDKLevel a_conv = LDKLevel_from_java(env, a);
40263         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40264         *ret_copy = ErrorAction_ignore_and_log(a_conv);
40265         int64_t ret_ref = tag_ptr(ret_copy, true);
40266         return ret_ref;
40267 }
40268
40269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
40270         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40271         *ret_copy = ErrorAction_ignore_duplicate_gossip();
40272         int64_t ret_ref = tag_ptr(ret_copy, true);
40273         return ret_ref;
40274 }
40275
40276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
40277         LDKErrorMessage msg_conv;
40278         msg_conv.inner = untag_ptr(msg);
40279         msg_conv.is_owned = ptr_is_owned(msg);
40280         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40281         msg_conv = ErrorMessage_clone(&msg_conv);
40282         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40283         *ret_copy = ErrorAction_send_error_message(msg_conv);
40284         int64_t ret_ref = tag_ptr(ret_copy, true);
40285         return ret_ref;
40286 }
40287
40288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
40289         LDKWarningMessage msg_conv;
40290         msg_conv.inner = untag_ptr(msg);
40291         msg_conv.is_owned = ptr_is_owned(msg);
40292         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40293         msg_conv = WarningMessage_clone(&msg_conv);
40294         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
40295         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40296         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
40297         int64_t ret_ref = tag_ptr(ret_copy, true);
40298         return ret_ref;
40299 }
40300
40301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40302         LDKLightningError this_obj_conv;
40303         this_obj_conv.inner = untag_ptr(this_obj);
40304         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40306         LightningError_free(this_obj_conv);
40307 }
40308
40309 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
40310         LDKLightningError this_ptr_conv;
40311         this_ptr_conv.inner = untag_ptr(this_ptr);
40312         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40314         this_ptr_conv.is_owned = false;
40315         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
40316         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40317         Str_free(ret_str);
40318         return ret_conv;
40319 }
40320
40321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
40322         LDKLightningError this_ptr_conv;
40323         this_ptr_conv.inner = untag_ptr(this_ptr);
40324         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40326         this_ptr_conv.is_owned = false;
40327         LDKStr val_conv = java_to_owned_str(env, val);
40328         LightningError_set_err(&this_ptr_conv, val_conv);
40329 }
40330
40331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
40332         LDKLightningError this_ptr_conv;
40333         this_ptr_conv.inner = untag_ptr(this_ptr);
40334         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40336         this_ptr_conv.is_owned = false;
40337         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40338         *ret_copy = LightningError_get_action(&this_ptr_conv);
40339         int64_t ret_ref = tag_ptr(ret_copy, true);
40340         return ret_ref;
40341 }
40342
40343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40344         LDKLightningError this_ptr_conv;
40345         this_ptr_conv.inner = untag_ptr(this_ptr);
40346         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40348         this_ptr_conv.is_owned = false;
40349         void* val_ptr = untag_ptr(val);
40350         CHECK_ACCESS(val_ptr);
40351         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
40352         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
40353         LightningError_set_action(&this_ptr_conv, val_conv);
40354 }
40355
40356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
40357         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
40358         void* action_arg_ptr = untag_ptr(action_arg);
40359         CHECK_ACCESS(action_arg_ptr);
40360         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
40361         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
40362         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
40363         int64_t ret_ref = 0;
40364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40366         return ret_ref;
40367 }
40368
40369 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
40370         LDKLightningError ret_var = LightningError_clone(arg);
40371         int64_t ret_ref = 0;
40372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40373         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40374         return ret_ref;
40375 }
40376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40377         LDKLightningError arg_conv;
40378         arg_conv.inner = untag_ptr(arg);
40379         arg_conv.is_owned = ptr_is_owned(arg);
40380         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40381         arg_conv.is_owned = false;
40382         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
40383         return ret_conv;
40384 }
40385
40386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40387         LDKLightningError orig_conv;
40388         orig_conv.inner = untag_ptr(orig);
40389         orig_conv.is_owned = ptr_is_owned(orig);
40390         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40391         orig_conv.is_owned = false;
40392         LDKLightningError ret_var = LightningError_clone(&orig_conv);
40393         int64_t ret_ref = 0;
40394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40395         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40396         return ret_ref;
40397 }
40398
40399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40400         LDKCommitmentUpdate this_obj_conv;
40401         this_obj_conv.inner = untag_ptr(this_obj);
40402         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40404         CommitmentUpdate_free(this_obj_conv);
40405 }
40406
40407 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40408         LDKCommitmentUpdate this_ptr_conv;
40409         this_ptr_conv.inner = untag_ptr(this_ptr);
40410         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40412         this_ptr_conv.is_owned = false;
40413         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
40414         int64_tArray ret_arr = NULL;
40415         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40416         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40417         for (size_t p = 0; p < ret_var.datalen; p++) {
40418                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
40419                 int64_t ret_conv_15_ref = 0;
40420                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
40421                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
40422                 ret_arr_ptr[p] = ret_conv_15_ref;
40423         }
40424         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40425         FREE(ret_var.data);
40426         return ret_arr;
40427 }
40428
40429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40430         LDKCommitmentUpdate this_ptr_conv;
40431         this_ptr_conv.inner = untag_ptr(this_ptr);
40432         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40434         this_ptr_conv.is_owned = false;
40435         LDKCVec_UpdateAddHTLCZ val_constr;
40436         val_constr.datalen = (*env)->GetArrayLength(env, val);
40437         if (val_constr.datalen > 0)
40438                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
40439         else
40440                 val_constr.data = NULL;
40441         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40442         for (size_t p = 0; p < val_constr.datalen; p++) {
40443                 int64_t val_conv_15 = val_vals[p];
40444                 LDKUpdateAddHTLC val_conv_15_conv;
40445                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
40446                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
40447                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
40448                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
40449                 val_constr.data[p] = val_conv_15_conv;
40450         }
40451         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40452         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
40453 }
40454
40455 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40456         LDKCommitmentUpdate this_ptr_conv;
40457         this_ptr_conv.inner = untag_ptr(this_ptr);
40458         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40460         this_ptr_conv.is_owned = false;
40461         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
40462         int64_tArray ret_arr = NULL;
40463         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40464         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40465         for (size_t t = 0; t < ret_var.datalen; t++) {
40466                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
40467                 int64_t ret_conv_19_ref = 0;
40468                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
40469                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
40470                 ret_arr_ptr[t] = ret_conv_19_ref;
40471         }
40472         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40473         FREE(ret_var.data);
40474         return ret_arr;
40475 }
40476
40477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40478         LDKCommitmentUpdate this_ptr_conv;
40479         this_ptr_conv.inner = untag_ptr(this_ptr);
40480         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40482         this_ptr_conv.is_owned = false;
40483         LDKCVec_UpdateFulfillHTLCZ val_constr;
40484         val_constr.datalen = (*env)->GetArrayLength(env, val);
40485         if (val_constr.datalen > 0)
40486                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
40487         else
40488                 val_constr.data = NULL;
40489         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40490         for (size_t t = 0; t < val_constr.datalen; t++) {
40491                 int64_t val_conv_19 = val_vals[t];
40492                 LDKUpdateFulfillHTLC val_conv_19_conv;
40493                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
40494                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
40495                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
40496                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
40497                 val_constr.data[t] = val_conv_19_conv;
40498         }
40499         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40500         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
40501 }
40502
40503 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40504         LDKCommitmentUpdate this_ptr_conv;
40505         this_ptr_conv.inner = untag_ptr(this_ptr);
40506         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40508         this_ptr_conv.is_owned = false;
40509         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
40510         int64_tArray ret_arr = NULL;
40511         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40512         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40513         for (size_t q = 0; q < ret_var.datalen; q++) {
40514                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
40515                 int64_t ret_conv_16_ref = 0;
40516                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
40517                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
40518                 ret_arr_ptr[q] = ret_conv_16_ref;
40519         }
40520         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40521         FREE(ret_var.data);
40522         return ret_arr;
40523 }
40524
40525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40526         LDKCommitmentUpdate this_ptr_conv;
40527         this_ptr_conv.inner = untag_ptr(this_ptr);
40528         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40530         this_ptr_conv.is_owned = false;
40531         LDKCVec_UpdateFailHTLCZ val_constr;
40532         val_constr.datalen = (*env)->GetArrayLength(env, val);
40533         if (val_constr.datalen > 0)
40534                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
40535         else
40536                 val_constr.data = NULL;
40537         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40538         for (size_t q = 0; q < val_constr.datalen; q++) {
40539                 int64_t val_conv_16 = val_vals[q];
40540                 LDKUpdateFailHTLC val_conv_16_conv;
40541                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
40542                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
40543                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
40544                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
40545                 val_constr.data[q] = val_conv_16_conv;
40546         }
40547         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40548         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
40549 }
40550
40551 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40552         LDKCommitmentUpdate this_ptr_conv;
40553         this_ptr_conv.inner = untag_ptr(this_ptr);
40554         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40556         this_ptr_conv.is_owned = false;
40557         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
40558         int64_tArray ret_arr = NULL;
40559         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40560         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40561         for (size_t z = 0; z < ret_var.datalen; z++) {
40562                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
40563                 int64_t ret_conv_25_ref = 0;
40564                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
40565                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
40566                 ret_arr_ptr[z] = ret_conv_25_ref;
40567         }
40568         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40569         FREE(ret_var.data);
40570         return ret_arr;
40571 }
40572
40573 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) {
40574         LDKCommitmentUpdate this_ptr_conv;
40575         this_ptr_conv.inner = untag_ptr(this_ptr);
40576         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40578         this_ptr_conv.is_owned = false;
40579         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
40580         val_constr.datalen = (*env)->GetArrayLength(env, val);
40581         if (val_constr.datalen > 0)
40582                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
40583         else
40584                 val_constr.data = NULL;
40585         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40586         for (size_t z = 0; z < val_constr.datalen; z++) {
40587                 int64_t val_conv_25 = val_vals[z];
40588                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
40589                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
40590                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
40591                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
40592                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
40593                 val_constr.data[z] = val_conv_25_conv;
40594         }
40595         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40596         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
40597 }
40598
40599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
40600         LDKCommitmentUpdate this_ptr_conv;
40601         this_ptr_conv.inner = untag_ptr(this_ptr);
40602         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40604         this_ptr_conv.is_owned = false;
40605         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
40606         int64_t ret_ref = 0;
40607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40608         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40609         return ret_ref;
40610 }
40611
40612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40613         LDKCommitmentUpdate this_ptr_conv;
40614         this_ptr_conv.inner = untag_ptr(this_ptr);
40615         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40617         this_ptr_conv.is_owned = false;
40618         LDKUpdateFee val_conv;
40619         val_conv.inner = untag_ptr(val);
40620         val_conv.is_owned = ptr_is_owned(val);
40621         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40622         val_conv = UpdateFee_clone(&val_conv);
40623         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
40624 }
40625
40626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
40627         LDKCommitmentUpdate this_ptr_conv;
40628         this_ptr_conv.inner = untag_ptr(this_ptr);
40629         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40631         this_ptr_conv.is_owned = false;
40632         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
40633         int64_t ret_ref = 0;
40634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40635         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40636         return ret_ref;
40637 }
40638
40639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40640         LDKCommitmentUpdate this_ptr_conv;
40641         this_ptr_conv.inner = untag_ptr(this_ptr);
40642         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40644         this_ptr_conv.is_owned = false;
40645         LDKCommitmentSigned val_conv;
40646         val_conv.inner = untag_ptr(val);
40647         val_conv.is_owned = ptr_is_owned(val);
40648         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40649         val_conv = CommitmentSigned_clone(&val_conv);
40650         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
40651 }
40652
40653 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) {
40654         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
40655         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
40656         if (update_add_htlcs_arg_constr.datalen > 0)
40657                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
40658         else
40659                 update_add_htlcs_arg_constr.data = NULL;
40660         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
40661         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
40662                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
40663                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
40664                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
40665                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
40666                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
40667                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
40668                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
40669         }
40670         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
40671         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
40672         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
40673         if (update_fulfill_htlcs_arg_constr.datalen > 0)
40674                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
40675         else
40676                 update_fulfill_htlcs_arg_constr.data = NULL;
40677         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
40678         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
40679                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
40680                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
40681                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
40682                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
40683                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
40684                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
40685                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
40686         }
40687         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
40688         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
40689         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
40690         if (update_fail_htlcs_arg_constr.datalen > 0)
40691                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
40692         else
40693                 update_fail_htlcs_arg_constr.data = NULL;
40694         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
40695         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
40696                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
40697                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
40698                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
40699                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
40700                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
40701                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
40702                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
40703         }
40704         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
40705         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
40706         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
40707         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
40708                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
40709         else
40710                 update_fail_malformed_htlcs_arg_constr.data = NULL;
40711         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
40712         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
40713                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
40714                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
40715                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
40716                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
40717                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
40718                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
40719                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
40720         }
40721         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
40722         LDKUpdateFee update_fee_arg_conv;
40723         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
40724         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
40725         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
40726         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
40727         LDKCommitmentSigned commitment_signed_arg_conv;
40728         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
40729         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
40730         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
40731         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
40732         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);
40733         int64_t ret_ref = 0;
40734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40735         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40736         return ret_ref;
40737 }
40738
40739 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
40740         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
40741         int64_t ret_ref = 0;
40742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40744         return ret_ref;
40745 }
40746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40747         LDKCommitmentUpdate arg_conv;
40748         arg_conv.inner = untag_ptr(arg);
40749         arg_conv.is_owned = ptr_is_owned(arg);
40750         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40751         arg_conv.is_owned = false;
40752         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
40753         return ret_conv;
40754 }
40755
40756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40757         LDKCommitmentUpdate orig_conv;
40758         orig_conv.inner = untag_ptr(orig);
40759         orig_conv.is_owned = ptr_is_owned(orig);
40760         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40761         orig_conv.is_owned = false;
40762         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
40763         int64_t ret_ref = 0;
40764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40765         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40766         return ret_ref;
40767 }
40768
40769 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40770         LDKCommitmentUpdate a_conv;
40771         a_conv.inner = untag_ptr(a);
40772         a_conv.is_owned = ptr_is_owned(a);
40773         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40774         a_conv.is_owned = false;
40775         LDKCommitmentUpdate b_conv;
40776         b_conv.inner = untag_ptr(b);
40777         b_conv.is_owned = ptr_is_owned(b);
40778         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40779         b_conv.is_owned = false;
40780         jboolean ret_conv = CommitmentUpdate_eq(&a_conv, &b_conv);
40781         return ret_conv;
40782 }
40783
40784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40785         if (!ptr_is_owned(this_ptr)) return;
40786         void* this_ptr_ptr = untag_ptr(this_ptr);
40787         CHECK_ACCESS(this_ptr_ptr);
40788         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
40789         FREE(untag_ptr(this_ptr));
40790         ChannelMessageHandler_free(this_ptr_conv);
40791 }
40792
40793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40794         if (!ptr_is_owned(this_ptr)) return;
40795         void* this_ptr_ptr = untag_ptr(this_ptr);
40796         CHECK_ACCESS(this_ptr_ptr);
40797         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
40798         FREE(untag_ptr(this_ptr));
40799         RoutingMessageHandler_free(this_ptr_conv);
40800 }
40801
40802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40803         if (!ptr_is_owned(this_ptr)) return;
40804         void* this_ptr_ptr = untag_ptr(this_ptr);
40805         CHECK_ACCESS(this_ptr_ptr);
40806         LDKOnionMessageHandler this_ptr_conv = *(LDKOnionMessageHandler*)(this_ptr_ptr);
40807         FREE(untag_ptr(this_ptr));
40808         OnionMessageHandler_free(this_ptr_conv);
40809 }
40810
40811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
40812         LDKAcceptChannel obj_conv;
40813         obj_conv.inner = untag_ptr(obj);
40814         obj_conv.is_owned = ptr_is_owned(obj);
40815         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40816         obj_conv.is_owned = false;
40817         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
40818         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40819         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40820         CVec_u8Z_free(ret_var);
40821         return ret_arr;
40822 }
40823
40824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40825         LDKu8slice ser_ref;
40826         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40827         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40828         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
40829         *ret_conv = AcceptChannel_read(ser_ref);
40830         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40831         return tag_ptr(ret_conv, true);
40832 }
40833
40834 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40835         LDKAnnouncementSignatures obj_conv;
40836         obj_conv.inner = untag_ptr(obj);
40837         obj_conv.is_owned = ptr_is_owned(obj);
40838         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40839         obj_conv.is_owned = false;
40840         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
40841         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40842         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40843         CVec_u8Z_free(ret_var);
40844         return ret_arr;
40845 }
40846
40847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40848         LDKu8slice ser_ref;
40849         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40850         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40851         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
40852         *ret_conv = AnnouncementSignatures_read(ser_ref);
40853         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40854         return tag_ptr(ret_conv, true);
40855 }
40856
40857 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
40858         LDKChannelReestablish obj_conv;
40859         obj_conv.inner = untag_ptr(obj);
40860         obj_conv.is_owned = ptr_is_owned(obj);
40861         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40862         obj_conv.is_owned = false;
40863         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
40864         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40865         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40866         CVec_u8Z_free(ret_var);
40867         return ret_arr;
40868 }
40869
40870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40871         LDKu8slice ser_ref;
40872         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40873         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40874         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
40875         *ret_conv = ChannelReestablish_read(ser_ref);
40876         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40877         return tag_ptr(ret_conv, true);
40878 }
40879
40880 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40881         LDKClosingSigned obj_conv;
40882         obj_conv.inner = untag_ptr(obj);
40883         obj_conv.is_owned = ptr_is_owned(obj);
40884         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40885         obj_conv.is_owned = false;
40886         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
40887         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40888         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40889         CVec_u8Z_free(ret_var);
40890         return ret_arr;
40891 }
40892
40893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40894         LDKu8slice ser_ref;
40895         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40896         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40897         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
40898         *ret_conv = ClosingSigned_read(ser_ref);
40899         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40900         return tag_ptr(ret_conv, true);
40901 }
40902
40903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
40904         LDKClosingSignedFeeRange obj_conv;
40905         obj_conv.inner = untag_ptr(obj);
40906         obj_conv.is_owned = ptr_is_owned(obj);
40907         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40908         obj_conv.is_owned = false;
40909         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
40910         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40911         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40912         CVec_u8Z_free(ret_var);
40913         return ret_arr;
40914 }
40915
40916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40917         LDKu8slice ser_ref;
40918         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40919         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40920         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
40921         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
40922         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40923         return tag_ptr(ret_conv, true);
40924 }
40925
40926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40927         LDKCommitmentSigned obj_conv;
40928         obj_conv.inner = untag_ptr(obj);
40929         obj_conv.is_owned = ptr_is_owned(obj);
40930         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40931         obj_conv.is_owned = false;
40932         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
40933         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40934         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40935         CVec_u8Z_free(ret_var);
40936         return ret_arr;
40937 }
40938
40939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40940         LDKu8slice ser_ref;
40941         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40942         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40943         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
40944         *ret_conv = CommitmentSigned_read(ser_ref);
40945         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40946         return tag_ptr(ret_conv, true);
40947 }
40948
40949 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
40950         LDKFundingCreated obj_conv;
40951         obj_conv.inner = untag_ptr(obj);
40952         obj_conv.is_owned = ptr_is_owned(obj);
40953         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40954         obj_conv.is_owned = false;
40955         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
40956         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40957         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40958         CVec_u8Z_free(ret_var);
40959         return ret_arr;
40960 }
40961
40962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40963         LDKu8slice ser_ref;
40964         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40965         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40966         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
40967         *ret_conv = FundingCreated_read(ser_ref);
40968         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40969         return tag_ptr(ret_conv, true);
40970 }
40971
40972 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40973         LDKFundingSigned obj_conv;
40974         obj_conv.inner = untag_ptr(obj);
40975         obj_conv.is_owned = ptr_is_owned(obj);
40976         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40977         obj_conv.is_owned = false;
40978         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
40979         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40980         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40981         CVec_u8Z_free(ret_var);
40982         return ret_arr;
40983 }
40984
40985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40986         LDKu8slice ser_ref;
40987         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40988         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40989         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
40990         *ret_conv = FundingSigned_read(ser_ref);
40991         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40992         return tag_ptr(ret_conv, true);
40993 }
40994
40995 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
40996         LDKChannelReady obj_conv;
40997         obj_conv.inner = untag_ptr(obj);
40998         obj_conv.is_owned = ptr_is_owned(obj);
40999         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41000         obj_conv.is_owned = false;
41001         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
41002         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41003         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41004         CVec_u8Z_free(ret_var);
41005         return ret_arr;
41006 }
41007
41008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41009         LDKu8slice ser_ref;
41010         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41011         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41012         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
41013         *ret_conv = ChannelReady_read(ser_ref);
41014         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41015         return tag_ptr(ret_conv, true);
41016 }
41017
41018 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
41019         LDKInit obj_conv;
41020         obj_conv.inner = untag_ptr(obj);
41021         obj_conv.is_owned = ptr_is_owned(obj);
41022         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41023         obj_conv.is_owned = false;
41024         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
41025         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41026         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41027         CVec_u8Z_free(ret_var);
41028         return ret_arr;
41029 }
41030
41031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41032         LDKu8slice ser_ref;
41033         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41034         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41035         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
41036         *ret_conv = Init_read(ser_ref);
41037         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41038         return tag_ptr(ret_conv, true);
41039 }
41040
41041 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
41042         LDKOpenChannel obj_conv;
41043         obj_conv.inner = untag_ptr(obj);
41044         obj_conv.is_owned = ptr_is_owned(obj);
41045         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41046         obj_conv.is_owned = false;
41047         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
41048         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41049         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41050         CVec_u8Z_free(ret_var);
41051         return ret_arr;
41052 }
41053
41054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41055         LDKu8slice ser_ref;
41056         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41057         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41058         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
41059         *ret_conv = OpenChannel_read(ser_ref);
41060         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41061         return tag_ptr(ret_conv, true);
41062 }
41063
41064 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
41065         LDKRevokeAndACK obj_conv;
41066         obj_conv.inner = untag_ptr(obj);
41067         obj_conv.is_owned = ptr_is_owned(obj);
41068         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41069         obj_conv.is_owned = false;
41070         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
41071         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41072         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41073         CVec_u8Z_free(ret_var);
41074         return ret_arr;
41075 }
41076
41077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41078         LDKu8slice ser_ref;
41079         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41080         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41081         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
41082         *ret_conv = RevokeAndACK_read(ser_ref);
41083         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41084         return tag_ptr(ret_conv, true);
41085 }
41086
41087 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
41088         LDKShutdown obj_conv;
41089         obj_conv.inner = untag_ptr(obj);
41090         obj_conv.is_owned = ptr_is_owned(obj);
41091         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41092         obj_conv.is_owned = false;
41093         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
41094         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41095         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41096         CVec_u8Z_free(ret_var);
41097         return ret_arr;
41098 }
41099
41100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41101         LDKu8slice ser_ref;
41102         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41103         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41104         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
41105         *ret_conv = Shutdown_read(ser_ref);
41106         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41107         return tag_ptr(ret_conv, true);
41108 }
41109
41110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41111         LDKUpdateFailHTLC obj_conv;
41112         obj_conv.inner = untag_ptr(obj);
41113         obj_conv.is_owned = ptr_is_owned(obj);
41114         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41115         obj_conv.is_owned = false;
41116         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
41117         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41118         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41119         CVec_u8Z_free(ret_var);
41120         return ret_arr;
41121 }
41122
41123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41124         LDKu8slice ser_ref;
41125         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41126         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41127         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
41128         *ret_conv = UpdateFailHTLC_read(ser_ref);
41129         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41130         return tag_ptr(ret_conv, true);
41131 }
41132
41133 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41134         LDKUpdateFailMalformedHTLC obj_conv;
41135         obj_conv.inner = untag_ptr(obj);
41136         obj_conv.is_owned = ptr_is_owned(obj);
41137         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41138         obj_conv.is_owned = false;
41139         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
41140         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41141         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41142         CVec_u8Z_free(ret_var);
41143         return ret_arr;
41144 }
41145
41146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41147         LDKu8slice ser_ref;
41148         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41149         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41150         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
41151         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
41152         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41153         return tag_ptr(ret_conv, true);
41154 }
41155
41156 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
41157         LDKUpdateFee obj_conv;
41158         obj_conv.inner = untag_ptr(obj);
41159         obj_conv.is_owned = ptr_is_owned(obj);
41160         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41161         obj_conv.is_owned = false;
41162         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
41163         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41164         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41165         CVec_u8Z_free(ret_var);
41166         return ret_arr;
41167 }
41168
41169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41170         LDKu8slice ser_ref;
41171         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41172         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41173         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
41174         *ret_conv = UpdateFee_read(ser_ref);
41175         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41176         return tag_ptr(ret_conv, true);
41177 }
41178
41179 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41180         LDKUpdateFulfillHTLC obj_conv;
41181         obj_conv.inner = untag_ptr(obj);
41182         obj_conv.is_owned = ptr_is_owned(obj);
41183         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41184         obj_conv.is_owned = false;
41185         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
41186         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41187         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41188         CVec_u8Z_free(ret_var);
41189         return ret_arr;
41190 }
41191
41192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41193         LDKu8slice ser_ref;
41194         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41195         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41196         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
41197         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
41198         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41199         return tag_ptr(ret_conv, true);
41200 }
41201
41202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41203         LDKUpdateAddHTLC obj_conv;
41204         obj_conv.inner = untag_ptr(obj);
41205         obj_conv.is_owned = ptr_is_owned(obj);
41206         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41207         obj_conv.is_owned = false;
41208         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
41209         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41210         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41211         CVec_u8Z_free(ret_var);
41212         return ret_arr;
41213 }
41214
41215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41216         LDKu8slice ser_ref;
41217         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41218         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41219         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
41220         *ret_conv = UpdateAddHTLC_read(ser_ref);
41221         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41222         return tag_ptr(ret_conv, true);
41223 }
41224
41225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41226         LDKu8slice ser_ref;
41227         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41228         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41229         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
41230         *ret_conv = OnionMessage_read(ser_ref);
41231         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41232         return tag_ptr(ret_conv, true);
41233 }
41234
41235 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41236         LDKOnionMessage obj_conv;
41237         obj_conv.inner = untag_ptr(obj);
41238         obj_conv.is_owned = ptr_is_owned(obj);
41239         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41240         obj_conv.is_owned = false;
41241         LDKCVec_u8Z ret_var = OnionMessage_write(&obj_conv);
41242         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41243         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41244         CVec_u8Z_free(ret_var);
41245         return ret_arr;
41246 }
41247
41248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
41249         LDKPing obj_conv;
41250         obj_conv.inner = untag_ptr(obj);
41251         obj_conv.is_owned = ptr_is_owned(obj);
41252         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41253         obj_conv.is_owned = false;
41254         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
41255         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41256         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41257         CVec_u8Z_free(ret_var);
41258         return ret_arr;
41259 }
41260
41261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41262         LDKu8slice ser_ref;
41263         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41264         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41265         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
41266         *ret_conv = Ping_read(ser_ref);
41267         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41268         return tag_ptr(ret_conv, true);
41269 }
41270
41271 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
41272         LDKPong obj_conv;
41273         obj_conv.inner = untag_ptr(obj);
41274         obj_conv.is_owned = ptr_is_owned(obj);
41275         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41276         obj_conv.is_owned = false;
41277         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
41278         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41279         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41280         CVec_u8Z_free(ret_var);
41281         return ret_arr;
41282 }
41283
41284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41285         LDKu8slice ser_ref;
41286         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41287         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41288         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
41289         *ret_conv = Pong_read(ser_ref);
41290         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41291         return tag_ptr(ret_conv, true);
41292 }
41293
41294 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41295         LDKUnsignedChannelAnnouncement obj_conv;
41296         obj_conv.inner = untag_ptr(obj);
41297         obj_conv.is_owned = ptr_is_owned(obj);
41298         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41299         obj_conv.is_owned = false;
41300         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
41301         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41302         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41303         CVec_u8Z_free(ret_var);
41304         return ret_arr;
41305 }
41306
41307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41308         LDKu8slice ser_ref;
41309         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41310         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41311         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
41312         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
41313         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41314         return tag_ptr(ret_conv, true);
41315 }
41316
41317 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41318         LDKChannelAnnouncement obj_conv;
41319         obj_conv.inner = untag_ptr(obj);
41320         obj_conv.is_owned = ptr_is_owned(obj);
41321         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41322         obj_conv.is_owned = false;
41323         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
41324         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41325         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41326         CVec_u8Z_free(ret_var);
41327         return ret_arr;
41328 }
41329
41330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41331         LDKu8slice ser_ref;
41332         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41333         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41334         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
41335         *ret_conv = ChannelAnnouncement_read(ser_ref);
41336         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41337         return tag_ptr(ret_conv, true);
41338 }
41339
41340 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
41341         LDKUnsignedChannelUpdate obj_conv;
41342         obj_conv.inner = untag_ptr(obj);
41343         obj_conv.is_owned = ptr_is_owned(obj);
41344         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41345         obj_conv.is_owned = false;
41346         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
41347         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41348         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41349         CVec_u8Z_free(ret_var);
41350         return ret_arr;
41351 }
41352
41353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41354         LDKu8slice ser_ref;
41355         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41356         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41357         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
41358         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
41359         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41360         return tag_ptr(ret_conv, true);
41361 }
41362
41363 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
41364         LDKChannelUpdate obj_conv;
41365         obj_conv.inner = untag_ptr(obj);
41366         obj_conv.is_owned = ptr_is_owned(obj);
41367         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41368         obj_conv.is_owned = false;
41369         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
41370         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41371         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41372         CVec_u8Z_free(ret_var);
41373         return ret_arr;
41374 }
41375
41376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41377         LDKu8slice ser_ref;
41378         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41379         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41380         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
41381         *ret_conv = ChannelUpdate_read(ser_ref);
41382         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41383         return tag_ptr(ret_conv, true);
41384 }
41385
41386 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41387         LDKErrorMessage obj_conv;
41388         obj_conv.inner = untag_ptr(obj);
41389         obj_conv.is_owned = ptr_is_owned(obj);
41390         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41391         obj_conv.is_owned = false;
41392         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
41393         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41394         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41395         CVec_u8Z_free(ret_var);
41396         return ret_arr;
41397 }
41398
41399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41400         LDKu8slice ser_ref;
41401         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41402         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41403         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
41404         *ret_conv = ErrorMessage_read(ser_ref);
41405         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41406         return tag_ptr(ret_conv, true);
41407 }
41408
41409 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41410         LDKWarningMessage obj_conv;
41411         obj_conv.inner = untag_ptr(obj);
41412         obj_conv.is_owned = ptr_is_owned(obj);
41413         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41414         obj_conv.is_owned = false;
41415         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
41416         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41417         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41418         CVec_u8Z_free(ret_var);
41419         return ret_arr;
41420 }
41421
41422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41423         LDKu8slice ser_ref;
41424         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41425         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41426         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
41427         *ret_conv = WarningMessage_read(ser_ref);
41428         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41429         return tag_ptr(ret_conv, true);
41430 }
41431
41432 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41433         LDKUnsignedNodeAnnouncement obj_conv;
41434         obj_conv.inner = untag_ptr(obj);
41435         obj_conv.is_owned = ptr_is_owned(obj);
41436         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41437         obj_conv.is_owned = false;
41438         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
41439         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41440         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41441         CVec_u8Z_free(ret_var);
41442         return ret_arr;
41443 }
41444
41445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41446         LDKu8slice ser_ref;
41447         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41448         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41449         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
41450         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
41451         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41452         return tag_ptr(ret_conv, true);
41453 }
41454
41455 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41456         LDKNodeAnnouncement obj_conv;
41457         obj_conv.inner = untag_ptr(obj);
41458         obj_conv.is_owned = ptr_is_owned(obj);
41459         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41460         obj_conv.is_owned = false;
41461         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
41462         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41463         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41464         CVec_u8Z_free(ret_var);
41465         return ret_arr;
41466 }
41467
41468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41469         LDKu8slice ser_ref;
41470         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41471         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41472         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
41473         *ret_conv = NodeAnnouncement_read(ser_ref);
41474         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41475         return tag_ptr(ret_conv, true);
41476 }
41477
41478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41479         LDKu8slice ser_ref;
41480         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41481         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41482         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
41483         *ret_conv = QueryShortChannelIds_read(ser_ref);
41484         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41485         return tag_ptr(ret_conv, true);
41486 }
41487
41488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
41489         LDKQueryShortChannelIds obj_conv;
41490         obj_conv.inner = untag_ptr(obj);
41491         obj_conv.is_owned = ptr_is_owned(obj);
41492         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41493         obj_conv.is_owned = false;
41494         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
41495         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41496         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41497         CVec_u8Z_free(ret_var);
41498         return ret_arr;
41499 }
41500
41501 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
41502         LDKReplyShortChannelIdsEnd obj_conv;
41503         obj_conv.inner = untag_ptr(obj);
41504         obj_conv.is_owned = ptr_is_owned(obj);
41505         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41506         obj_conv.is_owned = false;
41507         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
41508         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41509         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41510         CVec_u8Z_free(ret_var);
41511         return ret_arr;
41512 }
41513
41514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41515         LDKu8slice ser_ref;
41516         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41517         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41518         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
41519         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
41520         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41521         return tag_ptr(ret_conv, true);
41522 }
41523
41524 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
41525         LDKQueryChannelRange this_arg_conv;
41526         this_arg_conv.inner = untag_ptr(this_arg);
41527         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41529         this_arg_conv.is_owned = false;
41530         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
41531         return ret_conv;
41532 }
41533
41534 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
41535         LDKQueryChannelRange obj_conv;
41536         obj_conv.inner = untag_ptr(obj);
41537         obj_conv.is_owned = ptr_is_owned(obj);
41538         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41539         obj_conv.is_owned = false;
41540         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
41541         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41542         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41543         CVec_u8Z_free(ret_var);
41544         return ret_arr;
41545 }
41546
41547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41548         LDKu8slice ser_ref;
41549         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41550         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41551         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
41552         *ret_conv = QueryChannelRange_read(ser_ref);
41553         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41554         return tag_ptr(ret_conv, true);
41555 }
41556
41557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41558         LDKu8slice ser_ref;
41559         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41560         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41561         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
41562         *ret_conv = ReplyChannelRange_read(ser_ref);
41563         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41564         return tag_ptr(ret_conv, true);
41565 }
41566
41567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
41568         LDKReplyChannelRange obj_conv;
41569         obj_conv.inner = untag_ptr(obj);
41570         obj_conv.is_owned = ptr_is_owned(obj);
41571         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41572         obj_conv.is_owned = false;
41573         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
41574         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41575         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41576         CVec_u8Z_free(ret_var);
41577         return ret_arr;
41578 }
41579
41580 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
41581         LDKGossipTimestampFilter obj_conv;
41582         obj_conv.inner = untag_ptr(obj);
41583         obj_conv.is_owned = ptr_is_owned(obj);
41584         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41585         obj_conv.is_owned = false;
41586         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
41587         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41588         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41589         CVec_u8Z_free(ret_var);
41590         return ret_arr;
41591 }
41592
41593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41594         LDKu8slice ser_ref;
41595         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41596         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41597         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
41598         *ret_conv = GossipTimestampFilter_read(ser_ref);
41599         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41600         return tag_ptr(ret_conv, true);
41601 }
41602
41603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41604         if (!ptr_is_owned(this_ptr)) return;
41605         void* this_ptr_ptr = untag_ptr(this_ptr);
41606         CHECK_ACCESS(this_ptr_ptr);
41607         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
41608         FREE(untag_ptr(this_ptr));
41609         CustomMessageHandler_free(this_ptr_conv);
41610 }
41611
41612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41613         LDKIgnoringMessageHandler this_obj_conv;
41614         this_obj_conv.inner = untag_ptr(this_obj);
41615         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41617         IgnoringMessageHandler_free(this_obj_conv);
41618 }
41619
41620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
41621         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
41622         int64_t ret_ref = 0;
41623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41624         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41625         return ret_ref;
41626 }
41627
41628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41629         LDKIgnoringMessageHandler this_arg_conv;
41630         this_arg_conv.inner = untag_ptr(this_arg);
41631         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41633         this_arg_conv.is_owned = false;
41634         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
41635         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
41636         return tag_ptr(ret_ret, true);
41637 }
41638
41639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41640         LDKIgnoringMessageHandler this_arg_conv;
41641         this_arg_conv.inner = untag_ptr(this_arg);
41642         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41644         this_arg_conv.is_owned = false;
41645         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
41646         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
41647         return tag_ptr(ret_ret, true);
41648 }
41649
41650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41651         LDKIgnoringMessageHandler this_arg_conv;
41652         this_arg_conv.inner = untag_ptr(this_arg);
41653         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41655         this_arg_conv.is_owned = false;
41656         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
41657         *ret_ret = IgnoringMessageHandler_as_OnionMessageProvider(&this_arg_conv);
41658         return tag_ptr(ret_ret, true);
41659 }
41660
41661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41662         LDKIgnoringMessageHandler this_arg_conv;
41663         this_arg_conv.inner = untag_ptr(this_arg);
41664         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41666         this_arg_conv.is_owned = false;
41667         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
41668         *ret_ret = IgnoringMessageHandler_as_OnionMessageHandler(&this_arg_conv);
41669         return tag_ptr(ret_ret, true);
41670 }
41671
41672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomOnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41673         LDKIgnoringMessageHandler this_arg_conv;
41674         this_arg_conv.inner = untag_ptr(this_arg);
41675         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41677         this_arg_conv.is_owned = false;
41678         LDKCustomOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
41679         *ret_ret = IgnoringMessageHandler_as_CustomOnionMessageHandler(&this_arg_conv);
41680         return tag_ptr(ret_ret, true);
41681 }
41682
41683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
41684         LDKIgnoringMessageHandler this_arg_conv;
41685         this_arg_conv.inner = untag_ptr(this_arg);
41686         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41688         this_arg_conv.is_owned = false;
41689         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
41690         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
41691         return tag_ptr(ret_ret, true);
41692 }
41693
41694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41695         LDKIgnoringMessageHandler this_arg_conv;
41696         this_arg_conv.inner = untag_ptr(this_arg);
41697         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41699         this_arg_conv.is_owned = false;
41700         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
41701         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
41702         return tag_ptr(ret_ret, true);
41703 }
41704
41705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41706         LDKErroringMessageHandler this_obj_conv;
41707         this_obj_conv.inner = untag_ptr(this_obj);
41708         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41710         ErroringMessageHandler_free(this_obj_conv);
41711 }
41712
41713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
41714         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
41715         int64_t ret_ref = 0;
41716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41717         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41718         return ret_ref;
41719 }
41720
41721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41722         LDKErroringMessageHandler this_arg_conv;
41723         this_arg_conv.inner = untag_ptr(this_arg);
41724         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41726         this_arg_conv.is_owned = false;
41727         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
41728         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
41729         return tag_ptr(ret_ret, true);
41730 }
41731
41732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41733         LDKErroringMessageHandler this_arg_conv;
41734         this_arg_conv.inner = untag_ptr(this_arg);
41735         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41737         this_arg_conv.is_owned = false;
41738         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
41739         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
41740         return tag_ptr(ret_ret, true);
41741 }
41742
41743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41744         LDKMessageHandler this_obj_conv;
41745         this_obj_conv.inner = untag_ptr(this_obj);
41746         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41748         MessageHandler_free(this_obj_conv);
41749 }
41750
41751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41752         LDKMessageHandler this_ptr_conv;
41753         this_ptr_conv.inner = untag_ptr(this_ptr);
41754         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41756         this_ptr_conv.is_owned = false;
41757         // WARNING: This object doesn't live past this scope, needs clone!
41758         int64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
41759         return ret_ret;
41760 }
41761
41762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41763         LDKMessageHandler this_ptr_conv;
41764         this_ptr_conv.inner = untag_ptr(this_ptr);
41765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41767         this_ptr_conv.is_owned = false;
41768         void* val_ptr = untag_ptr(val);
41769         CHECK_ACCESS(val_ptr);
41770         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
41771         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
41772                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41773                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
41774         }
41775         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
41776 }
41777
41778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41779         LDKMessageHandler this_ptr_conv;
41780         this_ptr_conv.inner = untag_ptr(this_ptr);
41781         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41783         this_ptr_conv.is_owned = false;
41784         // WARNING: This object doesn't live past this scope, needs clone!
41785         int64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
41786         return ret_ret;
41787 }
41788
41789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41790         LDKMessageHandler this_ptr_conv;
41791         this_ptr_conv.inner = untag_ptr(this_ptr);
41792         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41794         this_ptr_conv.is_owned = false;
41795         void* val_ptr = untag_ptr(val);
41796         CHECK_ACCESS(val_ptr);
41797         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
41798         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
41799                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41800                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
41801         }
41802         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
41803 }
41804
41805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41806         LDKMessageHandler this_ptr_conv;
41807         this_ptr_conv.inner = untag_ptr(this_ptr);
41808         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41810         this_ptr_conv.is_owned = false;
41811         // WARNING: This object doesn't live past this scope, needs clone!
41812         int64_t ret_ret = tag_ptr(MessageHandler_get_onion_message_handler(&this_ptr_conv), false);
41813         return ret_ret;
41814 }
41815
41816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41817         LDKMessageHandler this_ptr_conv;
41818         this_ptr_conv.inner = untag_ptr(this_ptr);
41819         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41821         this_ptr_conv.is_owned = false;
41822         void* val_ptr = untag_ptr(val);
41823         CHECK_ACCESS(val_ptr);
41824         LDKOnionMessageHandler val_conv = *(LDKOnionMessageHandler*)(val_ptr);
41825         if (val_conv.free == LDKOnionMessageHandler_JCalls_free) {
41826                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41827                 LDKOnionMessageHandler_JCalls_cloned(&val_conv);
41828         }
41829         MessageHandler_set_onion_message_handler(&this_ptr_conv, val_conv);
41830 }
41831
41832 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) {
41833         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
41834         CHECK_ACCESS(chan_handler_arg_ptr);
41835         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
41836         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
41837                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41838                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
41839         }
41840         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
41841         CHECK_ACCESS(route_handler_arg_ptr);
41842         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
41843         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
41844                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41845                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
41846         }
41847         void* onion_message_handler_arg_ptr = untag_ptr(onion_message_handler_arg);
41848         CHECK_ACCESS(onion_message_handler_arg_ptr);
41849         LDKOnionMessageHandler onion_message_handler_arg_conv = *(LDKOnionMessageHandler*)(onion_message_handler_arg_ptr);
41850         if (onion_message_handler_arg_conv.free == LDKOnionMessageHandler_JCalls_free) {
41851                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41852                 LDKOnionMessageHandler_JCalls_cloned(&onion_message_handler_arg_conv);
41853         }
41854         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv, onion_message_handler_arg_conv);
41855         int64_t ret_ref = 0;
41856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41857         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41858         return ret_ref;
41859 }
41860
41861 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
41862         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41863         *ret_ret = SocketDescriptor_clone(arg);
41864         return tag_ptr(ret_ret, true);
41865 }
41866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41867         void* arg_ptr = untag_ptr(arg);
41868         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
41869         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
41870         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
41871         return ret_conv;
41872 }
41873
41874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41875         void* orig_ptr = untag_ptr(orig);
41876         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
41877         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
41878         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41879         *ret_ret = SocketDescriptor_clone(orig_conv);
41880         return tag_ptr(ret_ret, true);
41881 }
41882
41883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41884         if (!ptr_is_owned(this_ptr)) return;
41885         void* this_ptr_ptr = untag_ptr(this_ptr);
41886         CHECK_ACCESS(this_ptr_ptr);
41887         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
41888         FREE(untag_ptr(this_ptr));
41889         SocketDescriptor_free(this_ptr_conv);
41890 }
41891
41892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41893         LDKPeerHandleError this_obj_conv;
41894         this_obj_conv.inner = untag_ptr(this_obj);
41895         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41897         PeerHandleError_free(this_obj_conv);
41898 }
41899
41900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz) {
41901         LDKPeerHandleError ret_var = PeerHandleError_new();
41902         int64_t ret_ref = 0;
41903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41905         return ret_ref;
41906 }
41907
41908 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
41909         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
41910         int64_t ret_ref = 0;
41911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41912         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41913         return ret_ref;
41914 }
41915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41916         LDKPeerHandleError arg_conv;
41917         arg_conv.inner = untag_ptr(arg);
41918         arg_conv.is_owned = ptr_is_owned(arg);
41919         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41920         arg_conv.is_owned = false;
41921         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
41922         return ret_conv;
41923 }
41924
41925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41926         LDKPeerHandleError orig_conv;
41927         orig_conv.inner = untag_ptr(orig);
41928         orig_conv.is_owned = ptr_is_owned(orig);
41929         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41930         orig_conv.is_owned = false;
41931         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
41932         int64_t ret_ref = 0;
41933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41934         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41935         return ret_ref;
41936 }
41937
41938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41939         LDKPeerManager this_obj_conv;
41940         this_obj_conv.inner = untag_ptr(this_obj);
41941         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41943         PeerManager_free(this_obj_conv);
41944 }
41945
41946 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) {
41947         LDKMessageHandler message_handler_conv;
41948         message_handler_conv.inner = untag_ptr(message_handler);
41949         message_handler_conv.is_owned = ptr_is_owned(message_handler);
41950         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
41951         // WARNING: we need a move here but no clone is available for LDKMessageHandler
41952         
41953         uint8_t ephemeral_random_data_arr[32];
41954         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
41955         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
41956         uint8_t (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
41957         void* logger_ptr = untag_ptr(logger);
41958         CHECK_ACCESS(logger_ptr);
41959         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41960         if (logger_conv.free == LDKLogger_JCalls_free) {
41961                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41962                 LDKLogger_JCalls_cloned(&logger_conv);
41963         }
41964         void* custom_message_handler_ptr = untag_ptr(custom_message_handler);
41965         CHECK_ACCESS(custom_message_handler_ptr);
41966         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
41967         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
41968                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41969                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
41970         }
41971         void* node_signer_ptr = untag_ptr(node_signer);
41972         CHECK_ACCESS(node_signer_ptr);
41973         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
41974         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
41975                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41976                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
41977         }
41978         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, current_time, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv, node_signer_conv);
41979         int64_t ret_ref = 0;
41980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41981         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41982         return ret_ref;
41983 }
41984
41985 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
41986         LDKPeerManager this_arg_conv;
41987         this_arg_conv.inner = untag_ptr(this_arg);
41988         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41990         this_arg_conv.is_owned = false;
41991         LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
41992         int64_tArray ret_arr = NULL;
41993         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
41994         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
41995         for (size_t o = 0; o < ret_var.datalen; o++) {
41996                 LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
41997                 *ret_conv_40_conv = ret_var.data[o];
41998                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
41999         }
42000         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
42001         FREE(ret_var.data);
42002         return ret_arr;
42003 }
42004
42005 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) {
42006         LDKPeerManager this_arg_conv;
42007         this_arg_conv.inner = untag_ptr(this_arg);
42008         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42010         this_arg_conv.is_owned = false;
42011         LDKPublicKey their_node_id_ref;
42012         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
42013         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
42014         void* descriptor_ptr = untag_ptr(descriptor);
42015         CHECK_ACCESS(descriptor_ptr);
42016         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
42017         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
42018                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42019                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
42020         }
42021         void* remote_network_address_ptr = untag_ptr(remote_network_address);
42022         CHECK_ACCESS(remote_network_address_ptr);
42023         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
42024         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
42025         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
42026         return tag_ptr(ret_conv, true);
42027 }
42028
42029 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) {
42030         LDKPeerManager this_arg_conv;
42031         this_arg_conv.inner = untag_ptr(this_arg);
42032         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42034         this_arg_conv.is_owned = false;
42035         void* descriptor_ptr = untag_ptr(descriptor);
42036         CHECK_ACCESS(descriptor_ptr);
42037         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
42038         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
42039                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42040                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
42041         }
42042         void* remote_network_address_ptr = untag_ptr(remote_network_address);
42043         CHECK_ACCESS(remote_network_address_ptr);
42044         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
42045         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
42046         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
42047         return tag_ptr(ret_conv, true);
42048 }
42049
42050 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) {
42051         LDKPeerManager this_arg_conv;
42052         this_arg_conv.inner = untag_ptr(this_arg);
42053         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42055         this_arg_conv.is_owned = false;
42056         void* descriptor_ptr = untag_ptr(descriptor);
42057         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
42058         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
42059         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
42060         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
42061         return tag_ptr(ret_conv, true);
42062 }
42063
42064 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) {
42065         LDKPeerManager this_arg_conv;
42066         this_arg_conv.inner = untag_ptr(this_arg);
42067         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42069         this_arg_conv.is_owned = false;
42070         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
42071         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
42072         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
42073         LDKu8slice data_ref;
42074         data_ref.datalen = (*env)->GetArrayLength(env, data);
42075         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
42076         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
42077         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
42078         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
42079         return tag_ptr(ret_conv, true);
42080 }
42081
42082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
42083         LDKPeerManager this_arg_conv;
42084         this_arg_conv.inner = untag_ptr(this_arg);
42085         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42087         this_arg_conv.is_owned = false;
42088         PeerManager_process_events(&this_arg_conv);
42089 }
42090
42091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
42092         LDKPeerManager this_arg_conv;
42093         this_arg_conv.inner = untag_ptr(this_arg);
42094         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42096         this_arg_conv.is_owned = false;
42097         void* descriptor_ptr = untag_ptr(descriptor);
42098         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
42099         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
42100         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
42101 }
42102
42103 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) {
42104         LDKPeerManager this_arg_conv;
42105         this_arg_conv.inner = untag_ptr(this_arg);
42106         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42108         this_arg_conv.is_owned = false;
42109         LDKPublicKey node_id_ref;
42110         CHECK((*env)->GetArrayLength(env, node_id) == 33);
42111         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
42112         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref);
42113 }
42114
42115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
42116         LDKPeerManager this_arg_conv;
42117         this_arg_conv.inner = untag_ptr(this_arg);
42118         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42120         this_arg_conv.is_owned = false;
42121         PeerManager_disconnect_all_peers(&this_arg_conv);
42122 }
42123
42124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
42125         LDKPeerManager this_arg_conv;
42126         this_arg_conv.inner = untag_ptr(this_arg);
42127         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42129         this_arg_conv.is_owned = false;
42130         PeerManager_timer_tick_occurred(&this_arg_conv);
42131 }
42132
42133 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) {
42134         LDKPeerManager this_arg_conv;
42135         this_arg_conv.inner = untag_ptr(this_arg);
42136         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42138         this_arg_conv.is_owned = false;
42139         LDKThreeBytes rgb_ref;
42140         CHECK((*env)->GetArrayLength(env, rgb) == 3);
42141         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
42142         LDKThirtyTwoBytes alias_ref;
42143         CHECK((*env)->GetArrayLength(env, alias) == 32);
42144         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
42145         LDKCVec_NetAddressZ addresses_constr;
42146         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
42147         if (addresses_constr.datalen > 0)
42148                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
42149         else
42150                 addresses_constr.data = NULL;
42151         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
42152         for (size_t m = 0; m < addresses_constr.datalen; m++) {
42153                 int64_t addresses_conv_12 = addresses_vals[m];
42154                 void* addresses_conv_12_ptr = untag_ptr(addresses_conv_12);
42155                 CHECK_ACCESS(addresses_conv_12_ptr);
42156                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
42157                 addresses_constr.data[m] = addresses_conv_12_conv;
42158         }
42159         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
42160         PeerManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
42161 }
42162
42163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
42164         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
42165         return ret_conv;
42166 }
42167
42168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
42169         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
42170         return ret_conv;
42171 }
42172
42173 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42174         LDKHTLCClaim* orig_conv = (LDKHTLCClaim*)untag_ptr(orig);
42175         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_clone(orig_conv));
42176         return ret_conv;
42177 }
42178
42179 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1timeout(JNIEnv *env, jclass clz) {
42180         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_timeout());
42181         return ret_conv;
42182 }
42183
42184 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1preimage(JNIEnv *env, jclass clz) {
42185         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_preimage());
42186         return ret_conv;
42187 }
42188
42189 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1timeout(JNIEnv *env, jclass clz) {
42190         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_timeout());
42191         return ret_conv;
42192 }
42193
42194 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1preimage(JNIEnv *env, jclass clz) {
42195         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_preimage());
42196         return ret_conv;
42197 }
42198
42199 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1revocation(JNIEnv *env, jclass clz) {
42200         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_revocation());
42201         return ret_conv;
42202 }
42203
42204 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42205         LDKHTLCClaim* a_conv = (LDKHTLCClaim*)untag_ptr(a);
42206         LDKHTLCClaim* b_conv = (LDKHTLCClaim*)untag_ptr(b);
42207         jboolean ret_conv = HTLCClaim_eq(a_conv, b_conv);
42208         return ret_conv;
42209 }
42210
42211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1from_1witness(JNIEnv *env, jclass clz, int8_tArray witness) {
42212         LDKWitness witness_ref;
42213         witness_ref.datalen = (*env)->GetArrayLength(env, witness);
42214         witness_ref.data = MALLOC(witness_ref.datalen, "LDKWitness Bytes");
42215         (*env)->GetByteArrayRegion(env, witness, 0, witness_ref.datalen, witness_ref.data);
42216         witness_ref.data_is_owned = true;
42217         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
42218         *ret_copy = HTLCClaim_from_witness(witness_ref);
42219         int64_t ret_ref = tag_ptr(ret_copy, true);
42220         return ret_ref;
42221 }
42222
42223 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
42224         uint8_t commitment_seed_arr[32];
42225         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
42226         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
42227         uint8_t (*commitment_seed_ref)[32] = &commitment_seed_arr;
42228         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42229         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
42230         return ret_arr;
42231 }
42232
42233 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) {
42234         LDKCVec_u8Z to_holder_script_ref;
42235         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
42236         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
42237         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
42238         LDKCVec_u8Z to_counterparty_script_ref;
42239         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
42240         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
42241         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
42242         LDKOutPoint funding_outpoint_conv;
42243         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
42244         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
42245         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
42246         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
42247         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);
42248         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42249         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42250         Transaction_free(ret_var);
42251         return ret_arr;
42252 }
42253
42254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42255         LDKCounterpartyCommitmentSecrets this_obj_conv;
42256         this_obj_conv.inner = untag_ptr(this_obj);
42257         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42259         CounterpartyCommitmentSecrets_free(this_obj_conv);
42260 }
42261
42262 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
42263         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
42264         int64_t ret_ref = 0;
42265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42266         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42267         return ret_ref;
42268 }
42269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42270         LDKCounterpartyCommitmentSecrets arg_conv;
42271         arg_conv.inner = untag_ptr(arg);
42272         arg_conv.is_owned = ptr_is_owned(arg);
42273         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42274         arg_conv.is_owned = false;
42275         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
42276         return ret_conv;
42277 }
42278
42279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42280         LDKCounterpartyCommitmentSecrets orig_conv;
42281         orig_conv.inner = untag_ptr(orig);
42282         orig_conv.is_owned = ptr_is_owned(orig);
42283         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42284         orig_conv.is_owned = false;
42285         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
42286         int64_t ret_ref = 0;
42287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42288         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42289         return ret_ref;
42290 }
42291
42292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
42293         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
42294         int64_t ret_ref = 0;
42295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42296         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42297         return ret_ref;
42298 }
42299
42300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42301         LDKCounterpartyCommitmentSecrets this_arg_conv;
42302         this_arg_conv.inner = untag_ptr(this_arg);
42303         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42305         this_arg_conv.is_owned = false;
42306         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
42307         return ret_conv;
42308 }
42309
42310 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) {
42311         LDKCounterpartyCommitmentSecrets this_arg_conv;
42312         this_arg_conv.inner = untag_ptr(this_arg);
42313         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42315         this_arg_conv.is_owned = false;
42316         LDKThirtyTwoBytes secret_ref;
42317         CHECK((*env)->GetArrayLength(env, secret) == 32);
42318         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
42319         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
42320         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
42321         return tag_ptr(ret_conv, true);
42322 }
42323
42324 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
42325         LDKCounterpartyCommitmentSecrets this_arg_conv;
42326         this_arg_conv.inner = untag_ptr(this_arg);
42327         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42329         this_arg_conv.is_owned = false;
42330         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42331         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
42332         return ret_arr;
42333 }
42334
42335 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
42336         LDKCounterpartyCommitmentSecrets obj_conv;
42337         obj_conv.inner = untag_ptr(obj);
42338         obj_conv.is_owned = ptr_is_owned(obj);
42339         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42340         obj_conv.is_owned = false;
42341         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
42342         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42343         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42344         CVec_u8Z_free(ret_var);
42345         return ret_arr;
42346 }
42347
42348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42349         LDKu8slice ser_ref;
42350         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42351         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42352         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
42353         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
42354         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42355         return tag_ptr(ret_conv, true);
42356 }
42357
42358 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) {
42359         LDKPublicKey per_commitment_point_ref;
42360         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42361         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42362         uint8_t base_secret_arr[32];
42363         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
42364         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
42365         uint8_t (*base_secret_ref)[32] = &base_secret_arr;
42366         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42367         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_key(per_commitment_point_ref, base_secret_ref).bytes);
42368         return ret_arr;
42369 }
42370
42371 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) {
42372         LDKPublicKey per_commitment_point_ref;
42373         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42374         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42375         LDKPublicKey base_point_ref;
42376         CHECK((*env)->GetArrayLength(env, base_point) == 33);
42377         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
42378         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42379         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_key(per_commitment_point_ref, base_point_ref).compressed_form);
42380         return ret_arr;
42381 }
42382
42383 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) {
42384         uint8_t per_commitment_secret_arr[32];
42385         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
42386         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
42387         uint8_t (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
42388         uint8_t countersignatory_revocation_base_secret_arr[32];
42389         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
42390         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
42391         uint8_t (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
42392         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42393         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref).bytes);
42394         return ret_arr;
42395 }
42396
42397 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) {
42398         LDKPublicKey per_commitment_point_ref;
42399         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42400         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42401         LDKPublicKey countersignatory_revocation_base_point_ref;
42402         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
42403         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
42404         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42405         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref).compressed_form);
42406         return ret_arr;
42407 }
42408
42409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42410         LDKTxCreationKeys this_obj_conv;
42411         this_obj_conv.inner = untag_ptr(this_obj);
42412         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42414         TxCreationKeys_free(this_obj_conv);
42415 }
42416
42417 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
42418         LDKTxCreationKeys this_ptr_conv;
42419         this_ptr_conv.inner = untag_ptr(this_ptr);
42420         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42422         this_ptr_conv.is_owned = false;
42423         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42424         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
42425         return ret_arr;
42426 }
42427
42428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
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         LDKPublicKey val_ref;
42435         CHECK((*env)->GetArrayLength(env, val) == 33);
42436         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42437         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
42438 }
42439
42440 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42441         LDKTxCreationKeys this_ptr_conv;
42442         this_ptr_conv.inner = untag_ptr(this_ptr);
42443         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42445         this_ptr_conv.is_owned = false;
42446         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42447         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
42448         return ret_arr;
42449 }
42450
42451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42452         LDKTxCreationKeys this_ptr_conv;
42453         this_ptr_conv.inner = untag_ptr(this_ptr);
42454         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42456         this_ptr_conv.is_owned = false;
42457         LDKPublicKey val_ref;
42458         CHECK((*env)->GetArrayLength(env, val) == 33);
42459         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42460         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
42461 }
42462
42463 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42464         LDKTxCreationKeys this_ptr_conv;
42465         this_ptr_conv.inner = untag_ptr(this_ptr);
42466         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42468         this_ptr_conv.is_owned = false;
42469         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42470         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
42471         return ret_arr;
42472 }
42473
42474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42475         LDKTxCreationKeys this_ptr_conv;
42476         this_ptr_conv.inner = untag_ptr(this_ptr);
42477         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42479         this_ptr_conv.is_owned = false;
42480         LDKPublicKey val_ref;
42481         CHECK((*env)->GetArrayLength(env, val) == 33);
42482         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42483         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
42484 }
42485
42486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42487         LDKTxCreationKeys this_ptr_conv;
42488         this_ptr_conv.inner = untag_ptr(this_ptr);
42489         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42491         this_ptr_conv.is_owned = false;
42492         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42493         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
42494         return ret_arr;
42495 }
42496
42497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42498         LDKTxCreationKeys this_ptr_conv;
42499         this_ptr_conv.inner = untag_ptr(this_ptr);
42500         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42502         this_ptr_conv.is_owned = false;
42503         LDKPublicKey val_ref;
42504         CHECK((*env)->GetArrayLength(env, val) == 33);
42505         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42506         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
42507 }
42508
42509 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42510         LDKTxCreationKeys this_ptr_conv;
42511         this_ptr_conv.inner = untag_ptr(this_ptr);
42512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42514         this_ptr_conv.is_owned = false;
42515         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42516         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
42517         return ret_arr;
42518 }
42519
42520 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) {
42521         LDKTxCreationKeys this_ptr_conv;
42522         this_ptr_conv.inner = untag_ptr(this_ptr);
42523         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42525         this_ptr_conv.is_owned = false;
42526         LDKPublicKey val_ref;
42527         CHECK((*env)->GetArrayLength(env, val) == 33);
42528         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42529         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
42530 }
42531
42532 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) {
42533         LDKPublicKey per_commitment_point_arg_ref;
42534         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
42535         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
42536         LDKPublicKey revocation_key_arg_ref;
42537         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
42538         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
42539         LDKPublicKey broadcaster_htlc_key_arg_ref;
42540         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
42541         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
42542         LDKPublicKey countersignatory_htlc_key_arg_ref;
42543         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
42544         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
42545         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
42546         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
42547         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
42548         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);
42549         int64_t ret_ref = 0;
42550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42552         return ret_ref;
42553 }
42554
42555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42556         LDKTxCreationKeys a_conv;
42557         a_conv.inner = untag_ptr(a);
42558         a_conv.is_owned = ptr_is_owned(a);
42559         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42560         a_conv.is_owned = false;
42561         LDKTxCreationKeys b_conv;
42562         b_conv.inner = untag_ptr(b);
42563         b_conv.is_owned = ptr_is_owned(b);
42564         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42565         b_conv.is_owned = false;
42566         jboolean ret_conv = TxCreationKeys_eq(&a_conv, &b_conv);
42567         return ret_conv;
42568 }
42569
42570 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
42571         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
42572         int64_t ret_ref = 0;
42573         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42574         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42575         return ret_ref;
42576 }
42577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42578         LDKTxCreationKeys arg_conv;
42579         arg_conv.inner = untag_ptr(arg);
42580         arg_conv.is_owned = ptr_is_owned(arg);
42581         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42582         arg_conv.is_owned = false;
42583         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
42584         return ret_conv;
42585 }
42586
42587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42588         LDKTxCreationKeys orig_conv;
42589         orig_conv.inner = untag_ptr(orig);
42590         orig_conv.is_owned = ptr_is_owned(orig);
42591         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42592         orig_conv.is_owned = false;
42593         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
42594         int64_t ret_ref = 0;
42595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42596         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42597         return ret_ref;
42598 }
42599
42600 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
42601         LDKTxCreationKeys obj_conv;
42602         obj_conv.inner = untag_ptr(obj);
42603         obj_conv.is_owned = ptr_is_owned(obj);
42604         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42605         obj_conv.is_owned = false;
42606         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
42607         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42608         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42609         CVec_u8Z_free(ret_var);
42610         return ret_arr;
42611 }
42612
42613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42614         LDKu8slice ser_ref;
42615         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42616         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42617         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
42618         *ret_conv = TxCreationKeys_read(ser_ref);
42619         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42620         return tag_ptr(ret_conv, true);
42621 }
42622
42623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42624         LDKChannelPublicKeys this_obj_conv;
42625         this_obj_conv.inner = untag_ptr(this_obj);
42626         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42628         ChannelPublicKeys_free(this_obj_conv);
42629 }
42630
42631 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
42632         LDKChannelPublicKeys this_ptr_conv;
42633         this_ptr_conv.inner = untag_ptr(this_ptr);
42634         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42636         this_ptr_conv.is_owned = false;
42637         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42638         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
42639         return ret_arr;
42640 }
42641
42642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
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         LDKPublicKey val_ref;
42649         CHECK((*env)->GetArrayLength(env, val) == 33);
42650         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42651         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
42652 }
42653
42654 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42655         LDKChannelPublicKeys this_ptr_conv;
42656         this_ptr_conv.inner = untag_ptr(this_ptr);
42657         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42659         this_ptr_conv.is_owned = false;
42660         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42661         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
42662         return ret_arr;
42663 }
42664
42665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42666         LDKChannelPublicKeys this_ptr_conv;
42667         this_ptr_conv.inner = untag_ptr(this_ptr);
42668         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42670         this_ptr_conv.is_owned = false;
42671         LDKPublicKey val_ref;
42672         CHECK((*env)->GetArrayLength(env, val) == 33);
42673         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42674         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
42675 }
42676
42677 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
42678         LDKChannelPublicKeys this_ptr_conv;
42679         this_ptr_conv.inner = untag_ptr(this_ptr);
42680         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42682         this_ptr_conv.is_owned = false;
42683         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42684         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
42685         return ret_arr;
42686 }
42687
42688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42689         LDKChannelPublicKeys this_ptr_conv;
42690         this_ptr_conv.inner = untag_ptr(this_ptr);
42691         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42693         this_ptr_conv.is_owned = false;
42694         LDKPublicKey val_ref;
42695         CHECK((*env)->GetArrayLength(env, val) == 33);
42696         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42697         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
42698 }
42699
42700 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42701         LDKChannelPublicKeys this_ptr_conv;
42702         this_ptr_conv.inner = untag_ptr(this_ptr);
42703         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42705         this_ptr_conv.is_owned = false;
42706         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42707         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
42708         return ret_arr;
42709 }
42710
42711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42712         LDKChannelPublicKeys this_ptr_conv;
42713         this_ptr_conv.inner = untag_ptr(this_ptr);
42714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42716         this_ptr_conv.is_owned = false;
42717         LDKPublicKey val_ref;
42718         CHECK((*env)->GetArrayLength(env, val) == 33);
42719         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42720         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
42721 }
42722
42723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42724         LDKChannelPublicKeys this_ptr_conv;
42725         this_ptr_conv.inner = untag_ptr(this_ptr);
42726         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42728         this_ptr_conv.is_owned = false;
42729         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42730         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
42731         return ret_arr;
42732 }
42733
42734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42735         LDKChannelPublicKeys this_ptr_conv;
42736         this_ptr_conv.inner = untag_ptr(this_ptr);
42737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42739         this_ptr_conv.is_owned = false;
42740         LDKPublicKey val_ref;
42741         CHECK((*env)->GetArrayLength(env, val) == 33);
42742         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42743         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
42744 }
42745
42746 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) {
42747         LDKPublicKey funding_pubkey_arg_ref;
42748         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
42749         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
42750         LDKPublicKey revocation_basepoint_arg_ref;
42751         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
42752         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
42753         LDKPublicKey payment_point_arg_ref;
42754         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
42755         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
42756         LDKPublicKey delayed_payment_basepoint_arg_ref;
42757         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
42758         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
42759         LDKPublicKey htlc_basepoint_arg_ref;
42760         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
42761         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
42762         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);
42763         int64_t ret_ref = 0;
42764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42765         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42766         return ret_ref;
42767 }
42768
42769 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
42770         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
42771         int64_t ret_ref = 0;
42772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42773         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42774         return ret_ref;
42775 }
42776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42777         LDKChannelPublicKeys arg_conv;
42778         arg_conv.inner = untag_ptr(arg);
42779         arg_conv.is_owned = ptr_is_owned(arg);
42780         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42781         arg_conv.is_owned = false;
42782         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
42783         return ret_conv;
42784 }
42785
42786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42787         LDKChannelPublicKeys orig_conv;
42788         orig_conv.inner = untag_ptr(orig);
42789         orig_conv.is_owned = ptr_is_owned(orig);
42790         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42791         orig_conv.is_owned = false;
42792         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
42793         int64_t ret_ref = 0;
42794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42795         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42796         return ret_ref;
42797 }
42798
42799 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42800         LDKChannelPublicKeys a_conv;
42801         a_conv.inner = untag_ptr(a);
42802         a_conv.is_owned = ptr_is_owned(a);
42803         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42804         a_conv.is_owned = false;
42805         LDKChannelPublicKeys b_conv;
42806         b_conv.inner = untag_ptr(b);
42807         b_conv.is_owned = ptr_is_owned(b);
42808         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42809         b_conv.is_owned = false;
42810         jboolean ret_conv = ChannelPublicKeys_eq(&a_conv, &b_conv);
42811         return ret_conv;
42812 }
42813
42814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
42815         LDKChannelPublicKeys obj_conv;
42816         obj_conv.inner = untag_ptr(obj);
42817         obj_conv.is_owned = ptr_is_owned(obj);
42818         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42819         obj_conv.is_owned = false;
42820         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
42821         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42822         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42823         CVec_u8Z_free(ret_var);
42824         return ret_arr;
42825 }
42826
42827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42828         LDKu8slice ser_ref;
42829         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42830         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42831         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
42832         *ret_conv = ChannelPublicKeys_read(ser_ref);
42833         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42834         return tag_ptr(ret_conv, true);
42835 }
42836
42837 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) {
42838         LDKPublicKey per_commitment_point_ref;
42839         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42840         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42841         LDKPublicKey broadcaster_delayed_payment_base_ref;
42842         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
42843         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
42844         LDKPublicKey broadcaster_htlc_base_ref;
42845         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
42846         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
42847         LDKPublicKey countersignatory_revocation_base_ref;
42848         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
42849         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
42850         LDKPublicKey countersignatory_htlc_base_ref;
42851         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
42852         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
42853         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);
42854         int64_t ret_ref = 0;
42855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42856         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42857         return ret_ref;
42858 }
42859
42860 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) {
42861         LDKPublicKey per_commitment_point_ref;
42862         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42863         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42864         LDKChannelPublicKeys broadcaster_keys_conv;
42865         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
42866         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
42867         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
42868         broadcaster_keys_conv.is_owned = false;
42869         LDKChannelPublicKeys countersignatory_keys_conv;
42870         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
42871         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
42872         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
42873         countersignatory_keys_conv.is_owned = false;
42874         LDKTxCreationKeys ret_var = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
42875         int64_t ret_ref = 0;
42876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42877         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42878         return ret_ref;
42879 }
42880
42881 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) {
42882         LDKPublicKey revocation_key_ref;
42883         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
42884         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
42885         LDKPublicKey broadcaster_delayed_payment_key_ref;
42886         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
42887         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
42888         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
42889         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42890         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42891         CVec_u8Z_free(ret_var);
42892         return ret_arr;
42893 }
42894
42895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42896         LDKHTLCOutputInCommitment this_obj_conv;
42897         this_obj_conv.inner = untag_ptr(this_obj);
42898         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42900         HTLCOutputInCommitment_free(this_obj_conv);
42901 }
42902
42903 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
42904         LDKHTLCOutputInCommitment this_ptr_conv;
42905         this_ptr_conv.inner = untag_ptr(this_ptr);
42906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42908         this_ptr_conv.is_owned = false;
42909         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
42910         return ret_conv;
42911 }
42912
42913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
42914         LDKHTLCOutputInCommitment this_ptr_conv;
42915         this_ptr_conv.inner = untag_ptr(this_ptr);
42916         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42918         this_ptr_conv.is_owned = false;
42919         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
42920 }
42921
42922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42923         LDKHTLCOutputInCommitment this_ptr_conv;
42924         this_ptr_conv.inner = untag_ptr(this_ptr);
42925         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42927         this_ptr_conv.is_owned = false;
42928         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
42929         return ret_conv;
42930 }
42931
42932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42933         LDKHTLCOutputInCommitment this_ptr_conv;
42934         this_ptr_conv.inner = untag_ptr(this_ptr);
42935         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42937         this_ptr_conv.is_owned = false;
42938         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
42939 }
42940
42941 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
42942         LDKHTLCOutputInCommitment this_ptr_conv;
42943         this_ptr_conv.inner = untag_ptr(this_ptr);
42944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42946         this_ptr_conv.is_owned = false;
42947         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
42948         return ret_conv;
42949 }
42950
42951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42952         LDKHTLCOutputInCommitment this_ptr_conv;
42953         this_ptr_conv.inner = untag_ptr(this_ptr);
42954         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42956         this_ptr_conv.is_owned = false;
42957         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
42958 }
42959
42960 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
42961         LDKHTLCOutputInCommitment this_ptr_conv;
42962         this_ptr_conv.inner = untag_ptr(this_ptr);
42963         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42965         this_ptr_conv.is_owned = false;
42966         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42967         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
42968         return ret_arr;
42969 }
42970
42971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42972         LDKHTLCOutputInCommitment this_ptr_conv;
42973         this_ptr_conv.inner = untag_ptr(this_ptr);
42974         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42976         this_ptr_conv.is_owned = false;
42977         LDKThirtyTwoBytes val_ref;
42978         CHECK((*env)->GetArrayLength(env, val) == 32);
42979         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
42980         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
42981 }
42982
42983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
42984         LDKHTLCOutputInCommitment this_ptr_conv;
42985         this_ptr_conv.inner = untag_ptr(this_ptr);
42986         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42988         this_ptr_conv.is_owned = false;
42989         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
42990         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
42991         int64_t ret_ref = tag_ptr(ret_copy, true);
42992         return ret_ref;
42993 }
42994
42995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42996         LDKHTLCOutputInCommitment this_ptr_conv;
42997         this_ptr_conv.inner = untag_ptr(this_ptr);
42998         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43000         this_ptr_conv.is_owned = false;
43001         void* val_ptr = untag_ptr(val);
43002         CHECK_ACCESS(val_ptr);
43003         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
43004         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
43005         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
43006 }
43007
43008 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) {
43009         LDKThirtyTwoBytes payment_hash_arg_ref;
43010         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
43011         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
43012         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
43013         CHECK_ACCESS(transaction_output_index_arg_ptr);
43014         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
43015         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
43016         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
43017         int64_t ret_ref = 0;
43018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43019         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43020         return ret_ref;
43021 }
43022
43023 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
43024         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
43025         int64_t ret_ref = 0;
43026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43027         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43028         return ret_ref;
43029 }
43030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43031         LDKHTLCOutputInCommitment arg_conv;
43032         arg_conv.inner = untag_ptr(arg);
43033         arg_conv.is_owned = ptr_is_owned(arg);
43034         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43035         arg_conv.is_owned = false;
43036         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
43037         return ret_conv;
43038 }
43039
43040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43041         LDKHTLCOutputInCommitment orig_conv;
43042         orig_conv.inner = untag_ptr(orig);
43043         orig_conv.is_owned = ptr_is_owned(orig);
43044         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43045         orig_conv.is_owned = false;
43046         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
43047         int64_t ret_ref = 0;
43048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43050         return ret_ref;
43051 }
43052
43053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43054         LDKHTLCOutputInCommitment a_conv;
43055         a_conv.inner = untag_ptr(a);
43056         a_conv.is_owned = ptr_is_owned(a);
43057         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43058         a_conv.is_owned = false;
43059         LDKHTLCOutputInCommitment b_conv;
43060         b_conv.inner = untag_ptr(b);
43061         b_conv.is_owned = ptr_is_owned(b);
43062         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43063         b_conv.is_owned = false;
43064         jboolean ret_conv = HTLCOutputInCommitment_eq(&a_conv, &b_conv);
43065         return ret_conv;
43066 }
43067
43068 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
43069         LDKHTLCOutputInCommitment obj_conv;
43070         obj_conv.inner = untag_ptr(obj);
43071         obj_conv.is_owned = ptr_is_owned(obj);
43072         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43073         obj_conv.is_owned = false;
43074         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
43075         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43076         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43077         CVec_u8Z_free(ret_var);
43078         return ret_arr;
43079 }
43080
43081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43082         LDKu8slice ser_ref;
43083         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43084         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43085         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
43086         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
43087         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43088         return tag_ptr(ret_conv, true);
43089 }
43090
43091 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) {
43092         LDKHTLCOutputInCommitment htlc_conv;
43093         htlc_conv.inner = untag_ptr(htlc);
43094         htlc_conv.is_owned = ptr_is_owned(htlc);
43095         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
43096         htlc_conv.is_owned = false;
43097         LDKTxCreationKeys keys_conv;
43098         keys_conv.inner = untag_ptr(keys);
43099         keys_conv.is_owned = ptr_is_owned(keys);
43100         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
43101         keys_conv.is_owned = false;
43102         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
43103         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43104         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43105         CVec_u8Z_free(ret_var);
43106         return ret_arr;
43107 }
43108
43109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
43110         LDKPublicKey broadcaster_ref;
43111         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
43112         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
43113         LDKPublicKey countersignatory_ref;
43114         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
43115         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
43116         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
43117         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43118         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43119         CVec_u8Z_free(ret_var);
43120         return ret_arr;
43121 }
43122
43123 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) {
43124         uint8_t commitment_txid_arr[32];
43125         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
43126         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
43127         uint8_t (*commitment_txid_ref)[32] = &commitment_txid_arr;
43128         LDKHTLCOutputInCommitment htlc_conv;
43129         htlc_conv.inner = untag_ptr(htlc);
43130         htlc_conv.is_owned = ptr_is_owned(htlc);
43131         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
43132         htlc_conv.is_owned = false;
43133         LDKPublicKey broadcaster_delayed_payment_key_ref;
43134         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
43135         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
43136         LDKPublicKey revocation_key_ref;
43137         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
43138         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
43139         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);
43140         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43141         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43142         Transaction_free(ret_var);
43143         return ret_arr;
43144 }
43145
43146 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) {
43147         LDKSignature local_sig_ref;
43148         CHECK((*env)->GetArrayLength(env, local_sig) == 64);
43149         (*env)->GetByteArrayRegion(env, local_sig, 0, 64, local_sig_ref.compact_form);
43150         LDKSignature remote_sig_ref;
43151         CHECK((*env)->GetArrayLength(env, remote_sig) == 64);
43152         (*env)->GetByteArrayRegion(env, remote_sig, 0, 64, remote_sig_ref.compact_form);
43153         LDKThirtyTwoBytes preimage_ref;
43154         CHECK((*env)->GetArrayLength(env, preimage) == 32);
43155         (*env)->GetByteArrayRegion(env, preimage, 0, 32, preimage_ref.data);
43156         LDKu8slice redeem_script_ref;
43157         redeem_script_ref.datalen = (*env)->GetArrayLength(env, redeem_script);
43158         redeem_script_ref.data = (*env)->GetByteArrayElements (env, redeem_script, NULL);
43159         LDKWitness ret_var = build_htlc_input_witness(local_sig_ref, remote_sig_ref, preimage_ref, redeem_script_ref, opt_anchors);
43160         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43161         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43162         Witness_free(ret_var);
43163         (*env)->ReleaseByteArrayElements(env, redeem_script, (int8_t*)redeem_script_ref.data, 0);
43164         return ret_arr;
43165 }
43166
43167 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1to_1countersignatory_1with_1anchors_1redeemscript(JNIEnv *env, jclass clz, int8_tArray payment_point) {
43168         LDKPublicKey payment_point_ref;
43169         CHECK((*env)->GetArrayLength(env, payment_point) == 33);
43170         (*env)->GetByteArrayRegion(env, payment_point, 0, 33, payment_point_ref.compressed_form);
43171         LDKCVec_u8Z ret_var = get_to_countersignatory_with_anchors_redeemscript(payment_point_ref);
43172         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43173         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43174         CVec_u8Z_free(ret_var);
43175         return ret_arr;
43176 }
43177
43178 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
43179         LDKPublicKey funding_pubkey_ref;
43180         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
43181         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
43182         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
43183         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43184         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43185         CVec_u8Z_free(ret_var);
43186         return ret_arr;
43187 }
43188
43189 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) {
43190         LDKPublicKey funding_key_ref;
43191         CHECK((*env)->GetArrayLength(env, funding_key) == 33);
43192         (*env)->GetByteArrayRegion(env, funding_key, 0, 33, funding_key_ref.compressed_form);
43193         LDKSignature funding_sig_ref;
43194         CHECK((*env)->GetArrayLength(env, funding_sig) == 64);
43195         (*env)->GetByteArrayRegion(env, funding_sig, 0, 64, funding_sig_ref.compact_form);
43196         LDKWitness ret_var = build_anchor_input_witness(funding_key_ref, funding_sig_ref);
43197         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43198         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43199         Witness_free(ret_var);
43200         return ret_arr;
43201 }
43202
43203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43204         LDKChannelTransactionParameters this_obj_conv;
43205         this_obj_conv.inner = untag_ptr(this_obj);
43206         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43208         ChannelTransactionParameters_free(this_obj_conv);
43209 }
43210
43211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
43212         LDKChannelTransactionParameters this_ptr_conv;
43213         this_ptr_conv.inner = untag_ptr(this_ptr);
43214         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43216         this_ptr_conv.is_owned = false;
43217         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
43218         int64_t ret_ref = 0;
43219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43220         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43221         return ret_ref;
43222 }
43223
43224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43225         LDKChannelTransactionParameters this_ptr_conv;
43226         this_ptr_conv.inner = untag_ptr(this_ptr);
43227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43229         this_ptr_conv.is_owned = false;
43230         LDKChannelPublicKeys val_conv;
43231         val_conv.inner = untag_ptr(val);
43232         val_conv.is_owned = ptr_is_owned(val);
43233         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43234         val_conv = ChannelPublicKeys_clone(&val_conv);
43235         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
43236 }
43237
43238 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
43239         LDKChannelTransactionParameters this_ptr_conv;
43240         this_ptr_conv.inner = untag_ptr(this_ptr);
43241         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43243         this_ptr_conv.is_owned = false;
43244         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
43245         return ret_conv;
43246 }
43247
43248 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) {
43249         LDKChannelTransactionParameters this_ptr_conv;
43250         this_ptr_conv.inner = untag_ptr(this_ptr);
43251         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43253         this_ptr_conv.is_owned = false;
43254         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
43255 }
43256
43257 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
43258         LDKChannelTransactionParameters this_ptr_conv;
43259         this_ptr_conv.inner = untag_ptr(this_ptr);
43260         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43262         this_ptr_conv.is_owned = false;
43263         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
43264         return ret_conv;
43265 }
43266
43267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
43268         LDKChannelTransactionParameters this_ptr_conv;
43269         this_ptr_conv.inner = untag_ptr(this_ptr);
43270         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43272         this_ptr_conv.is_owned = false;
43273         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
43274 }
43275
43276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
43277         LDKChannelTransactionParameters this_ptr_conv;
43278         this_ptr_conv.inner = untag_ptr(this_ptr);
43279         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43281         this_ptr_conv.is_owned = false;
43282         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
43283         int64_t ret_ref = 0;
43284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43285         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43286         return ret_ref;
43287 }
43288
43289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43290         LDKChannelTransactionParameters this_ptr_conv;
43291         this_ptr_conv.inner = untag_ptr(this_ptr);
43292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43294         this_ptr_conv.is_owned = false;
43295         LDKCounterpartyChannelTransactionParameters val_conv;
43296         val_conv.inner = untag_ptr(val);
43297         val_conv.is_owned = ptr_is_owned(val);
43298         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43299         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
43300         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
43301 }
43302
43303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
43304         LDKChannelTransactionParameters this_ptr_conv;
43305         this_ptr_conv.inner = untag_ptr(this_ptr);
43306         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43308         this_ptr_conv.is_owned = false;
43309         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
43310         int64_t ret_ref = 0;
43311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43312         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43313         return ret_ref;
43314 }
43315
43316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43317         LDKChannelTransactionParameters this_ptr_conv;
43318         this_ptr_conv.inner = untag_ptr(this_ptr);
43319         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43321         this_ptr_conv.is_owned = false;
43322         LDKOutPoint val_conv;
43323         val_conv.inner = untag_ptr(val);
43324         val_conv.is_owned = ptr_is_owned(val);
43325         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43326         val_conv = OutPoint_clone(&val_conv);
43327         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
43328 }
43329
43330 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
43331         LDKChannelTransactionParameters this_ptr_conv;
43332         this_ptr_conv.inner = untag_ptr(this_ptr);
43333         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43335         this_ptr_conv.is_owned = false;
43336         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
43337         return ret_conv;
43338 }
43339
43340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
43341         LDKChannelTransactionParameters this_ptr_conv;
43342         this_ptr_conv.inner = untag_ptr(this_ptr);
43343         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43345         this_ptr_conv.is_owned = false;
43346         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
43347         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
43348 }
43349
43350 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1non_1zero_1fee_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
43351         LDKChannelTransactionParameters this_ptr_conv;
43352         this_ptr_conv.inner = untag_ptr(this_ptr);
43353         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43355         this_ptr_conv.is_owned = false;
43356         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_non_zero_fee_anchors(&this_ptr_conv));
43357         return ret_conv;
43358 }
43359
43360 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) {
43361         LDKChannelTransactionParameters this_ptr_conv;
43362         this_ptr_conv.inner = untag_ptr(this_ptr);
43363         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43365         this_ptr_conv.is_owned = false;
43366         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
43367         ChannelTransactionParameters_set_opt_non_zero_fee_anchors(&this_ptr_conv, val_conv);
43368 }
43369
43370 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) {
43371         LDKChannelPublicKeys holder_pubkeys_arg_conv;
43372         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
43373         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
43374         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
43375         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
43376         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
43377         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
43378         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
43379         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
43380         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
43381         LDKOutPoint funding_outpoint_arg_conv;
43382         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
43383         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
43384         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
43385         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
43386         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
43387         LDKCOption_NoneZ opt_non_zero_fee_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_non_zero_fee_anchors_arg);
43388         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);
43389         int64_t ret_ref = 0;
43390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43391         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43392         return ret_ref;
43393 }
43394
43395 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
43396         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
43397         int64_t ret_ref = 0;
43398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43399         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43400         return ret_ref;
43401 }
43402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43403         LDKChannelTransactionParameters arg_conv;
43404         arg_conv.inner = untag_ptr(arg);
43405         arg_conv.is_owned = ptr_is_owned(arg);
43406         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43407         arg_conv.is_owned = false;
43408         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
43409         return ret_conv;
43410 }
43411
43412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43413         LDKChannelTransactionParameters orig_conv;
43414         orig_conv.inner = untag_ptr(orig);
43415         orig_conv.is_owned = ptr_is_owned(orig);
43416         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43417         orig_conv.is_owned = false;
43418         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
43419         int64_t ret_ref = 0;
43420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43421         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43422         return ret_ref;
43423 }
43424
43425 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43426         LDKChannelTransactionParameters a_conv;
43427         a_conv.inner = untag_ptr(a);
43428         a_conv.is_owned = ptr_is_owned(a);
43429         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43430         a_conv.is_owned = false;
43431         LDKChannelTransactionParameters b_conv;
43432         b_conv.inner = untag_ptr(b);
43433         b_conv.is_owned = ptr_is_owned(b);
43434         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43435         b_conv.is_owned = false;
43436         jboolean ret_conv = ChannelTransactionParameters_eq(&a_conv, &b_conv);
43437         return ret_conv;
43438 }
43439
43440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43441         LDKCounterpartyChannelTransactionParameters this_obj_conv;
43442         this_obj_conv.inner = untag_ptr(this_obj);
43443         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43445         CounterpartyChannelTransactionParameters_free(this_obj_conv);
43446 }
43447
43448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
43449         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43450         this_ptr_conv.inner = untag_ptr(this_ptr);
43451         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43453         this_ptr_conv.is_owned = false;
43454         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
43455         int64_t ret_ref = 0;
43456         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43457         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43458         return ret_ref;
43459 }
43460
43461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43462         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43463         this_ptr_conv.inner = untag_ptr(this_ptr);
43464         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43466         this_ptr_conv.is_owned = false;
43467         LDKChannelPublicKeys val_conv;
43468         val_conv.inner = untag_ptr(val);
43469         val_conv.is_owned = ptr_is_owned(val);
43470         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43471         val_conv = ChannelPublicKeys_clone(&val_conv);
43472         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
43473 }
43474
43475 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
43476         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43477         this_ptr_conv.inner = untag_ptr(this_ptr);
43478         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43480         this_ptr_conv.is_owned = false;
43481         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
43482         return ret_conv;
43483 }
43484
43485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
43486         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43487         this_ptr_conv.inner = untag_ptr(this_ptr);
43488         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43490         this_ptr_conv.is_owned = false;
43491         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
43492 }
43493
43494 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) {
43495         LDKChannelPublicKeys pubkeys_arg_conv;
43496         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
43497         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
43498         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
43499         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
43500         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
43501         int64_t ret_ref = 0;
43502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43503         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43504         return ret_ref;
43505 }
43506
43507 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
43508         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
43509         int64_t ret_ref = 0;
43510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43511         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43512         return ret_ref;
43513 }
43514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43515         LDKCounterpartyChannelTransactionParameters arg_conv;
43516         arg_conv.inner = untag_ptr(arg);
43517         arg_conv.is_owned = ptr_is_owned(arg);
43518         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43519         arg_conv.is_owned = false;
43520         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
43521         return ret_conv;
43522 }
43523
43524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43525         LDKCounterpartyChannelTransactionParameters orig_conv;
43526         orig_conv.inner = untag_ptr(orig);
43527         orig_conv.is_owned = ptr_is_owned(orig);
43528         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43529         orig_conv.is_owned = false;
43530         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
43531         int64_t ret_ref = 0;
43532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43533         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43534         return ret_ref;
43535 }
43536
43537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43538         LDKCounterpartyChannelTransactionParameters a_conv;
43539         a_conv.inner = untag_ptr(a);
43540         a_conv.is_owned = ptr_is_owned(a);
43541         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43542         a_conv.is_owned = false;
43543         LDKCounterpartyChannelTransactionParameters b_conv;
43544         b_conv.inner = untag_ptr(b);
43545         b_conv.is_owned = ptr_is_owned(b);
43546         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43547         b_conv.is_owned = false;
43548         jboolean ret_conv = CounterpartyChannelTransactionParameters_eq(&a_conv, &b_conv);
43549         return ret_conv;
43550 }
43551
43552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
43553         LDKChannelTransactionParameters this_arg_conv;
43554         this_arg_conv.inner = untag_ptr(this_arg);
43555         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43557         this_arg_conv.is_owned = false;
43558         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
43559         return ret_conv;
43560 }
43561
43562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
43563         LDKChannelTransactionParameters this_arg_conv;
43564         this_arg_conv.inner = untag_ptr(this_arg);
43565         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43567         this_arg_conv.is_owned = false;
43568         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
43569         int64_t ret_ref = 0;
43570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43571         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43572         return ret_ref;
43573 }
43574
43575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
43576         LDKChannelTransactionParameters this_arg_conv;
43577         this_arg_conv.inner = untag_ptr(this_arg);
43578         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43580         this_arg_conv.is_owned = false;
43581         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
43582         int64_t ret_ref = 0;
43583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43584         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43585         return ret_ref;
43586 }
43587
43588 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43589         LDKCounterpartyChannelTransactionParameters obj_conv;
43590         obj_conv.inner = untag_ptr(obj);
43591         obj_conv.is_owned = ptr_is_owned(obj);
43592         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43593         obj_conv.is_owned = false;
43594         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
43595         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43596         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43597         CVec_u8Z_free(ret_var);
43598         return ret_arr;
43599 }
43600
43601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43602         LDKu8slice ser_ref;
43603         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43604         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43605         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
43606         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
43607         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43608         return tag_ptr(ret_conv, true);
43609 }
43610
43611 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43612         LDKChannelTransactionParameters obj_conv;
43613         obj_conv.inner = untag_ptr(obj);
43614         obj_conv.is_owned = ptr_is_owned(obj);
43615         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43616         obj_conv.is_owned = false;
43617         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
43618         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43619         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43620         CVec_u8Z_free(ret_var);
43621         return ret_arr;
43622 }
43623
43624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43625         LDKu8slice ser_ref;
43626         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43627         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43628         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
43629         *ret_conv = ChannelTransactionParameters_read(ser_ref);
43630         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43631         return tag_ptr(ret_conv, true);
43632 }
43633
43634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43635         LDKDirectedChannelTransactionParameters this_obj_conv;
43636         this_obj_conv.inner = untag_ptr(this_obj);
43637         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43639         DirectedChannelTransactionParameters_free(this_obj_conv);
43640 }
43641
43642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
43643         LDKDirectedChannelTransactionParameters this_arg_conv;
43644         this_arg_conv.inner = untag_ptr(this_arg);
43645         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43647         this_arg_conv.is_owned = false;
43648         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
43649         int64_t ret_ref = 0;
43650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43651         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43652         return ret_ref;
43653 }
43654
43655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
43656         LDKDirectedChannelTransactionParameters this_arg_conv;
43657         this_arg_conv.inner = untag_ptr(this_arg);
43658         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43660         this_arg_conv.is_owned = false;
43661         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
43662         int64_t ret_ref = 0;
43663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43664         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43665         return ret_ref;
43666 }
43667
43668 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
43669         LDKDirectedChannelTransactionParameters this_arg_conv;
43670         this_arg_conv.inner = untag_ptr(this_arg);
43671         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43673         this_arg_conv.is_owned = false;
43674         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
43675         return ret_conv;
43676 }
43677
43678 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
43679         LDKDirectedChannelTransactionParameters this_arg_conv;
43680         this_arg_conv.inner = untag_ptr(this_arg);
43681         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43683         this_arg_conv.is_owned = false;
43684         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
43685         return ret_conv;
43686 }
43687
43688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
43689         LDKDirectedChannelTransactionParameters this_arg_conv;
43690         this_arg_conv.inner = untag_ptr(this_arg);
43691         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43693         this_arg_conv.is_owned = false;
43694         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
43695         int64_t ret_ref = 0;
43696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43697         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43698         return ret_ref;
43699 }
43700
43701 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
43702         LDKDirectedChannelTransactionParameters this_arg_conv;
43703         this_arg_conv.inner = untag_ptr(this_arg);
43704         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43706         this_arg_conv.is_owned = false;
43707         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
43708         return ret_conv;
43709 }
43710
43711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43712         LDKHolderCommitmentTransaction this_obj_conv;
43713         this_obj_conv.inner = untag_ptr(this_obj);
43714         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43716         HolderCommitmentTransaction_free(this_obj_conv);
43717 }
43718
43719 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
43720         LDKHolderCommitmentTransaction this_ptr_conv;
43721         this_ptr_conv.inner = untag_ptr(this_ptr);
43722         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43724         this_ptr_conv.is_owned = false;
43725         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
43726         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
43727         return ret_arr;
43728 }
43729
43730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43731         LDKHolderCommitmentTransaction this_ptr_conv;
43732         this_ptr_conv.inner = untag_ptr(this_ptr);
43733         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43735         this_ptr_conv.is_owned = false;
43736         LDKSignature val_ref;
43737         CHECK((*env)->GetArrayLength(env, val) == 64);
43738         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
43739         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
43740 }
43741
43742 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr) {
43743         LDKHolderCommitmentTransaction this_ptr_conv;
43744         this_ptr_conv.inner = untag_ptr(this_ptr);
43745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43747         this_ptr_conv.is_owned = false;
43748         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
43749         jobjectArray ret_arr = NULL;
43750         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
43751         ;
43752         for (size_t i = 0; i < ret_var.datalen; i++) {
43753                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
43754                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
43755                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
43756         }
43757         
43758         FREE(ret_var.data);
43759         return ret_arr;
43760 }
43761
43762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
43763         LDKHolderCommitmentTransaction this_ptr_conv;
43764         this_ptr_conv.inner = untag_ptr(this_ptr);
43765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43767         this_ptr_conv.is_owned = false;
43768         LDKCVec_SignatureZ val_constr;
43769         val_constr.datalen = (*env)->GetArrayLength(env, val);
43770         if (val_constr.datalen > 0)
43771                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
43772         else
43773                 val_constr.data = NULL;
43774         for (size_t i = 0; i < val_constr.datalen; i++) {
43775                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
43776                 LDKSignature val_conv_8_ref;
43777                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
43778                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
43779                 val_constr.data[i] = val_conv_8_ref;
43780         }
43781         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
43782 }
43783
43784 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
43785         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
43786         int64_t ret_ref = 0;
43787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43788         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43789         return ret_ref;
43790 }
43791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43792         LDKHolderCommitmentTransaction arg_conv;
43793         arg_conv.inner = untag_ptr(arg);
43794         arg_conv.is_owned = ptr_is_owned(arg);
43795         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43796         arg_conv.is_owned = false;
43797         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
43798         return ret_conv;
43799 }
43800
43801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43802         LDKHolderCommitmentTransaction orig_conv;
43803         orig_conv.inner = untag_ptr(orig);
43804         orig_conv.is_owned = ptr_is_owned(orig);
43805         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43806         orig_conv.is_owned = false;
43807         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
43808         int64_t ret_ref = 0;
43809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43810         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43811         return ret_ref;
43812 }
43813
43814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43815         LDKHolderCommitmentTransaction obj_conv;
43816         obj_conv.inner = untag_ptr(obj);
43817         obj_conv.is_owned = ptr_is_owned(obj);
43818         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43819         obj_conv.is_owned = false;
43820         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
43821         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43822         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43823         CVec_u8Z_free(ret_var);
43824         return ret_arr;
43825 }
43826
43827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43828         LDKu8slice ser_ref;
43829         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43830         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43831         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
43832         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
43833         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43834         return tag_ptr(ret_conv, true);
43835 }
43836
43837 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) {
43838         LDKCommitmentTransaction commitment_tx_conv;
43839         commitment_tx_conv.inner = untag_ptr(commitment_tx);
43840         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
43841         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
43842         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
43843         LDKSignature counterparty_sig_ref;
43844         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
43845         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
43846         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
43847         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
43848         if (counterparty_htlc_sigs_constr.datalen > 0)
43849                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
43850         else
43851                 counterparty_htlc_sigs_constr.data = NULL;
43852         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
43853                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
43854                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
43855                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
43856                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
43857                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
43858         }
43859         LDKPublicKey holder_funding_key_ref;
43860         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
43861         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
43862         LDKPublicKey counterparty_funding_key_ref;
43863         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
43864         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
43865         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
43866         int64_t ret_ref = 0;
43867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43868         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43869         return ret_ref;
43870 }
43871
43872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43873         LDKBuiltCommitmentTransaction this_obj_conv;
43874         this_obj_conv.inner = untag_ptr(this_obj);
43875         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43877         BuiltCommitmentTransaction_free(this_obj_conv);
43878 }
43879
43880 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
43881         LDKBuiltCommitmentTransaction this_ptr_conv;
43882         this_ptr_conv.inner = untag_ptr(this_ptr);
43883         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43885         this_ptr_conv.is_owned = false;
43886         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
43887         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43888         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43889         Transaction_free(ret_var);
43890         return ret_arr;
43891 }
43892
43893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43894         LDKBuiltCommitmentTransaction this_ptr_conv;
43895         this_ptr_conv.inner = untag_ptr(this_ptr);
43896         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43898         this_ptr_conv.is_owned = false;
43899         LDKTransaction val_ref;
43900         val_ref.datalen = (*env)->GetArrayLength(env, val);
43901         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
43902         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
43903         val_ref.data_is_owned = true;
43904         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
43905 }
43906
43907 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
43908         LDKBuiltCommitmentTransaction this_ptr_conv;
43909         this_ptr_conv.inner = untag_ptr(this_ptr);
43910         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43912         this_ptr_conv.is_owned = false;
43913         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43914         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
43915         return ret_arr;
43916 }
43917
43918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43919         LDKBuiltCommitmentTransaction this_ptr_conv;
43920         this_ptr_conv.inner = untag_ptr(this_ptr);
43921         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43923         this_ptr_conv.is_owned = false;
43924         LDKThirtyTwoBytes val_ref;
43925         CHECK((*env)->GetArrayLength(env, val) == 32);
43926         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
43927         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
43928 }
43929
43930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
43931         LDKTransaction transaction_arg_ref;
43932         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
43933         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
43934         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
43935         transaction_arg_ref.data_is_owned = true;
43936         LDKThirtyTwoBytes txid_arg_ref;
43937         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
43938         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
43939         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
43940         int64_t ret_ref = 0;
43941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43942         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43943         return ret_ref;
43944 }
43945
43946 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
43947         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
43948         int64_t ret_ref = 0;
43949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43950         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43951         return ret_ref;
43952 }
43953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43954         LDKBuiltCommitmentTransaction arg_conv;
43955         arg_conv.inner = untag_ptr(arg);
43956         arg_conv.is_owned = ptr_is_owned(arg);
43957         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43958         arg_conv.is_owned = false;
43959         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
43960         return ret_conv;
43961 }
43962
43963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43964         LDKBuiltCommitmentTransaction orig_conv;
43965         orig_conv.inner = untag_ptr(orig);
43966         orig_conv.is_owned = ptr_is_owned(orig);
43967         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43968         orig_conv.is_owned = false;
43969         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
43970         int64_t ret_ref = 0;
43971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43972         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43973         return ret_ref;
43974 }
43975
43976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43977         LDKBuiltCommitmentTransaction obj_conv;
43978         obj_conv.inner = untag_ptr(obj);
43979         obj_conv.is_owned = ptr_is_owned(obj);
43980         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43981         obj_conv.is_owned = false;
43982         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
43983         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43984         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43985         CVec_u8Z_free(ret_var);
43986         return ret_arr;
43987 }
43988
43989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43990         LDKu8slice ser_ref;
43991         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43992         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43993         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
43994         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
43995         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43996         return tag_ptr(ret_conv, true);
43997 }
43998
43999 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) {
44000         LDKBuiltCommitmentTransaction this_arg_conv;
44001         this_arg_conv.inner = untag_ptr(this_arg);
44002         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44004         this_arg_conv.is_owned = false;
44005         LDKu8slice funding_redeemscript_ref;
44006         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44007         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44008         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44009         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
44010         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44011         return ret_arr;
44012 }
44013
44014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
44015         LDKBuiltCommitmentTransaction this_arg_conv;
44016         this_arg_conv.inner = untag_ptr(this_arg);
44017         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44019         this_arg_conv.is_owned = false;
44020         uint8_t funding_key_arr[32];
44021         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
44022         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
44023         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
44024         LDKu8slice funding_redeemscript_ref;
44025         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44026         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44027         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
44028         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign_counterparty_commitment(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
44029         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44030         return ret_arr;
44031 }
44032
44033 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1sign_1holder_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis, int64_t entropy_source) {
44034         LDKBuiltCommitmentTransaction this_arg_conv;
44035         this_arg_conv.inner = untag_ptr(this_arg);
44036         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44038         this_arg_conv.is_owned = false;
44039         uint8_t funding_key_arr[32];
44040         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
44041         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
44042         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
44043         LDKu8slice funding_redeemscript_ref;
44044         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44045         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44046         void* entropy_source_ptr = untag_ptr(entropy_source);
44047         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
44048         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
44049         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
44050         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign_holder_commitment(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis, entropy_source_conv).compact_form);
44051         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44052         return ret_arr;
44053 }
44054
44055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44056         LDKClosingTransaction this_obj_conv;
44057         this_obj_conv.inner = untag_ptr(this_obj);
44058         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44060         ClosingTransaction_free(this_obj_conv);
44061 }
44062
44063 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
44064         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
44065         int64_t ret_ref = 0;
44066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44067         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44068         return ret_ref;
44069 }
44070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44071         LDKClosingTransaction arg_conv;
44072         arg_conv.inner = untag_ptr(arg);
44073         arg_conv.is_owned = ptr_is_owned(arg);
44074         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44075         arg_conv.is_owned = false;
44076         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
44077         return ret_conv;
44078 }
44079
44080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44081         LDKClosingTransaction orig_conv;
44082         orig_conv.inner = untag_ptr(orig);
44083         orig_conv.is_owned = ptr_is_owned(orig);
44084         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44085         orig_conv.is_owned = false;
44086         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
44087         int64_t ret_ref = 0;
44088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44089         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44090         return ret_ref;
44091 }
44092
44093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
44094         LDKClosingTransaction o_conv;
44095         o_conv.inner = untag_ptr(o);
44096         o_conv.is_owned = ptr_is_owned(o);
44097         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44098         o_conv.is_owned = false;
44099         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
44100         return ret_conv;
44101 }
44102
44103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44104         LDKClosingTransaction a_conv;
44105         a_conv.inner = untag_ptr(a);
44106         a_conv.is_owned = ptr_is_owned(a);
44107         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44108         a_conv.is_owned = false;
44109         LDKClosingTransaction b_conv;
44110         b_conv.inner = untag_ptr(b);
44111         b_conv.is_owned = ptr_is_owned(b);
44112         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44113         b_conv.is_owned = false;
44114         jboolean ret_conv = ClosingTransaction_eq(&a_conv, &b_conv);
44115         return ret_conv;
44116 }
44117
44118 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) {
44119         LDKCVec_u8Z to_holder_script_ref;
44120         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
44121         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
44122         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
44123         LDKCVec_u8Z to_counterparty_script_ref;
44124         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
44125         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
44126         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
44127         LDKOutPoint funding_outpoint_conv;
44128         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
44129         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
44130         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
44131         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
44132         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
44133         int64_t ret_ref = 0;
44134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44135         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44136         return ret_ref;
44137 }
44138
44139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
44140         LDKClosingTransaction this_arg_conv;
44141         this_arg_conv.inner = untag_ptr(this_arg);
44142         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44144         this_arg_conv.is_owned = false;
44145         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
44146         int64_t ret_ref = 0;
44147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44148         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44149         return ret_ref;
44150 }
44151
44152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
44153         LDKClosingTransaction this_arg_conv;
44154         this_arg_conv.inner = untag_ptr(this_arg);
44155         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44157         this_arg_conv.is_owned = false;
44158         LDKOutPoint funding_outpoint_conv;
44159         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
44160         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
44161         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
44162         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
44163         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
44164         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
44165         return tag_ptr(ret_conv, true);
44166 }
44167
44168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44169         LDKClosingTransaction this_arg_conv;
44170         this_arg_conv.inner = untag_ptr(this_arg);
44171         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44173         this_arg_conv.is_owned = false;
44174         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
44175         return ret_conv;
44176 }
44177
44178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44179         LDKClosingTransaction this_arg_conv;
44180         this_arg_conv.inner = untag_ptr(this_arg);
44181         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44183         this_arg_conv.is_owned = false;
44184         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
44185         return ret_conv;
44186 }
44187
44188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44189         LDKClosingTransaction this_arg_conv;
44190         this_arg_conv.inner = untag_ptr(this_arg);
44191         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44193         this_arg_conv.is_owned = false;
44194         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
44195         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44196         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44197         return ret_arr;
44198 }
44199
44200 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44201         LDKClosingTransaction this_arg_conv;
44202         this_arg_conv.inner = untag_ptr(this_arg);
44203         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44205         this_arg_conv.is_owned = false;
44206         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
44207         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44208         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44209         return ret_arr;
44210 }
44211
44212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44213         LDKTrustedClosingTransaction this_obj_conv;
44214         this_obj_conv.inner = untag_ptr(this_obj);
44215         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44217         TrustedClosingTransaction_free(this_obj_conv);
44218 }
44219
44220 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
44221         LDKTrustedClosingTransaction this_arg_conv;
44222         this_arg_conv.inner = untag_ptr(this_arg);
44223         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44225         this_arg_conv.is_owned = false;
44226         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
44227         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44228         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44229         Transaction_free(ret_var);
44230         return ret_arr;
44231 }
44232
44233 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) {
44234         LDKTrustedClosingTransaction this_arg_conv;
44235         this_arg_conv.inner = untag_ptr(this_arg);
44236         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44238         this_arg_conv.is_owned = false;
44239         LDKu8slice funding_redeemscript_ref;
44240         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44241         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44242         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44243         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
44244         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44245         return ret_arr;
44246 }
44247
44248 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) {
44249         LDKTrustedClosingTransaction 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         uint8_t funding_key_arr[32];
44255         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
44256         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
44257         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
44258         LDKu8slice funding_redeemscript_ref;
44259         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44260         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44261         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
44262         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
44263         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44264         return ret_arr;
44265 }
44266
44267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44268         LDKCommitmentTransaction this_obj_conv;
44269         this_obj_conv.inner = untag_ptr(this_obj);
44270         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44272         CommitmentTransaction_free(this_obj_conv);
44273 }
44274
44275 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
44276         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
44277         int64_t ret_ref = 0;
44278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44279         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44280         return ret_ref;
44281 }
44282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44283         LDKCommitmentTransaction arg_conv;
44284         arg_conv.inner = untag_ptr(arg);
44285         arg_conv.is_owned = ptr_is_owned(arg);
44286         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44287         arg_conv.is_owned = false;
44288         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
44289         return ret_conv;
44290 }
44291
44292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44293         LDKCommitmentTransaction orig_conv;
44294         orig_conv.inner = untag_ptr(orig);
44295         orig_conv.is_owned = ptr_is_owned(orig);
44296         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44297         orig_conv.is_owned = false;
44298         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
44299         int64_t ret_ref = 0;
44300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44301         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44302         return ret_ref;
44303 }
44304
44305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
44306         LDKCommitmentTransaction obj_conv;
44307         obj_conv.inner = untag_ptr(obj);
44308         obj_conv.is_owned = ptr_is_owned(obj);
44309         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44310         obj_conv.is_owned = false;
44311         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
44312         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44313         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44314         CVec_u8Z_free(ret_var);
44315         return ret_arr;
44316 }
44317
44318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44319         LDKu8slice ser_ref;
44320         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44321         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44322         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
44323         *ret_conv = CommitmentTransaction_read(ser_ref);
44324         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44325         return tag_ptr(ret_conv, true);
44326 }
44327
44328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
44329         LDKCommitmentTransaction this_arg_conv;
44330         this_arg_conv.inner = untag_ptr(this_arg);
44331         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44333         this_arg_conv.is_owned = false;
44334         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
44335         return ret_conv;
44336 }
44337
44338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44339         LDKCommitmentTransaction this_arg_conv;
44340         this_arg_conv.inner = untag_ptr(this_arg);
44341         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44343         this_arg_conv.is_owned = false;
44344         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
44345         return ret_conv;
44346 }
44347
44348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44349         LDKCommitmentTransaction this_arg_conv;
44350         this_arg_conv.inner = untag_ptr(this_arg);
44351         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44353         this_arg_conv.is_owned = false;
44354         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
44355         return ret_conv;
44356 }
44357
44358 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
44359         LDKCommitmentTransaction this_arg_conv;
44360         this_arg_conv.inner = untag_ptr(this_arg);
44361         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44363         this_arg_conv.is_owned = false;
44364         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
44365         return ret_conv;
44366 }
44367
44368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
44369         LDKCommitmentTransaction this_arg_conv;
44370         this_arg_conv.inner = untag_ptr(this_arg);
44371         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44373         this_arg_conv.is_owned = false;
44374         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
44375         int64_t ret_ref = 0;
44376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44377         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44378         return ret_ref;
44379 }
44380
44381 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) {
44382         LDKCommitmentTransaction this_arg_conv;
44383         this_arg_conv.inner = untag_ptr(this_arg);
44384         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44386         this_arg_conv.is_owned = false;
44387         LDKDirectedChannelTransactionParameters channel_parameters_conv;
44388         channel_parameters_conv.inner = untag_ptr(channel_parameters);
44389         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
44390         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
44391         channel_parameters_conv.is_owned = false;
44392         LDKChannelPublicKeys broadcaster_keys_conv;
44393         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
44394         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
44395         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
44396         broadcaster_keys_conv.is_owned = false;
44397         LDKChannelPublicKeys countersignatory_keys_conv;
44398         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
44399         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
44400         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
44401         countersignatory_keys_conv.is_owned = false;
44402         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
44403         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
44404         return tag_ptr(ret_conv, true);
44405 }
44406
44407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44408         LDKTrustedCommitmentTransaction this_obj_conv;
44409         this_obj_conv.inner = untag_ptr(this_obj);
44410         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44412         TrustedCommitmentTransaction_free(this_obj_conv);
44413 }
44414
44415 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
44416         LDKTrustedCommitmentTransaction this_arg_conv;
44417         this_arg_conv.inner = untag_ptr(this_arg);
44418         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44420         this_arg_conv.is_owned = false;
44421         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44422         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
44423         return ret_arr;
44424 }
44425
44426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
44427         LDKTrustedCommitmentTransaction this_arg_conv;
44428         this_arg_conv.inner = untag_ptr(this_arg);
44429         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44431         this_arg_conv.is_owned = false;
44432         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
44433         int64_t ret_ref = 0;
44434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44435         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44436         return ret_ref;
44437 }
44438
44439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
44440         LDKTrustedCommitmentTransaction this_arg_conv;
44441         this_arg_conv.inner = untag_ptr(this_arg);
44442         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44444         this_arg_conv.is_owned = false;
44445         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
44446         int64_t ret_ref = 0;
44447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44448         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44449         return ret_ref;
44450 }
44451
44452 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
44453         LDKTrustedCommitmentTransaction this_arg_conv;
44454         this_arg_conv.inner = untag_ptr(this_arg);
44455         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44457         this_arg_conv.is_owned = false;
44458         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
44459         return ret_conv;
44460 }
44461
44462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1get_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray htlc_base_key, int64_t channel_parameters, int64_t entropy_source) {
44463         LDKTrustedCommitmentTransaction this_arg_conv;
44464         this_arg_conv.inner = untag_ptr(this_arg);
44465         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44467         this_arg_conv.is_owned = false;
44468         uint8_t htlc_base_key_arr[32];
44469         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
44470         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
44471         uint8_t (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
44472         LDKDirectedChannelTransactionParameters channel_parameters_conv;
44473         channel_parameters_conv.inner = untag_ptr(channel_parameters);
44474         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
44475         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
44476         channel_parameters_conv.is_owned = false;
44477         void* entropy_source_ptr = untag_ptr(entropy_source);
44478         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
44479         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
44480         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
44481         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv, entropy_source_conv);
44482         return tag_ptr(ret_conv, true);
44483 }
44484
44485 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) {
44486         LDKPublicKey broadcaster_payment_basepoint_ref;
44487         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
44488         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
44489         LDKPublicKey countersignatory_payment_basepoint_ref;
44490         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
44491         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
44492         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
44493         return ret_conv;
44494 }
44495
44496 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44497         LDKInitFeatures a_conv;
44498         a_conv.inner = untag_ptr(a);
44499         a_conv.is_owned = ptr_is_owned(a);
44500         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44501         a_conv.is_owned = false;
44502         LDKInitFeatures b_conv;
44503         b_conv.inner = untag_ptr(b);
44504         b_conv.is_owned = ptr_is_owned(b);
44505         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44506         b_conv.is_owned = false;
44507         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
44508         return ret_conv;
44509 }
44510
44511 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44512         LDKNodeFeatures a_conv;
44513         a_conv.inner = untag_ptr(a);
44514         a_conv.is_owned = ptr_is_owned(a);
44515         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44516         a_conv.is_owned = false;
44517         LDKNodeFeatures b_conv;
44518         b_conv.inner = untag_ptr(b);
44519         b_conv.is_owned = ptr_is_owned(b);
44520         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44521         b_conv.is_owned = false;
44522         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
44523         return ret_conv;
44524 }
44525
44526 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44527         LDKChannelFeatures a_conv;
44528         a_conv.inner = untag_ptr(a);
44529         a_conv.is_owned = ptr_is_owned(a);
44530         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44531         a_conv.is_owned = false;
44532         LDKChannelFeatures b_conv;
44533         b_conv.inner = untag_ptr(b);
44534         b_conv.is_owned = ptr_is_owned(b);
44535         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44536         b_conv.is_owned = false;
44537         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
44538         return ret_conv;
44539 }
44540
44541 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44542         LDKInvoiceFeatures a_conv;
44543         a_conv.inner = untag_ptr(a);
44544         a_conv.is_owned = ptr_is_owned(a);
44545         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44546         a_conv.is_owned = false;
44547         LDKInvoiceFeatures b_conv;
44548         b_conv.inner = untag_ptr(b);
44549         b_conv.is_owned = ptr_is_owned(b);
44550         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44551         b_conv.is_owned = false;
44552         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
44553         return ret_conv;
44554 }
44555
44556 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44557         LDKOfferFeatures a_conv;
44558         a_conv.inner = untag_ptr(a);
44559         a_conv.is_owned = ptr_is_owned(a);
44560         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44561         a_conv.is_owned = false;
44562         LDKOfferFeatures b_conv;
44563         b_conv.inner = untag_ptr(b);
44564         b_conv.is_owned = ptr_is_owned(b);
44565         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44566         b_conv.is_owned = false;
44567         jboolean ret_conv = OfferFeatures_eq(&a_conv, &b_conv);
44568         return ret_conv;
44569 }
44570
44571 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44572         LDKInvoiceRequestFeatures a_conv;
44573         a_conv.inner = untag_ptr(a);
44574         a_conv.is_owned = ptr_is_owned(a);
44575         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44576         a_conv.is_owned = false;
44577         LDKInvoiceRequestFeatures b_conv;
44578         b_conv.inner = untag_ptr(b);
44579         b_conv.is_owned = ptr_is_owned(b);
44580         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44581         b_conv.is_owned = false;
44582         jboolean ret_conv = InvoiceRequestFeatures_eq(&a_conv, &b_conv);
44583         return ret_conv;
44584 }
44585
44586 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44587         LDKBolt12InvoiceFeatures a_conv;
44588         a_conv.inner = untag_ptr(a);
44589         a_conv.is_owned = ptr_is_owned(a);
44590         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44591         a_conv.is_owned = false;
44592         LDKBolt12InvoiceFeatures b_conv;
44593         b_conv.inner = untag_ptr(b);
44594         b_conv.is_owned = ptr_is_owned(b);
44595         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44596         b_conv.is_owned = false;
44597         jboolean ret_conv = Bolt12InvoiceFeatures_eq(&a_conv, &b_conv);
44598         return ret_conv;
44599 }
44600
44601 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44602         LDKBlindedHopFeatures a_conv;
44603         a_conv.inner = untag_ptr(a);
44604         a_conv.is_owned = ptr_is_owned(a);
44605         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44606         a_conv.is_owned = false;
44607         LDKBlindedHopFeatures b_conv;
44608         b_conv.inner = untag_ptr(b);
44609         b_conv.is_owned = ptr_is_owned(b);
44610         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44611         b_conv.is_owned = false;
44612         jboolean ret_conv = BlindedHopFeatures_eq(&a_conv, &b_conv);
44613         return ret_conv;
44614 }
44615
44616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44617         LDKChannelTypeFeatures a_conv;
44618         a_conv.inner = untag_ptr(a);
44619         a_conv.is_owned = ptr_is_owned(a);
44620         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44621         a_conv.is_owned = false;
44622         LDKChannelTypeFeatures b_conv;
44623         b_conv.inner = untag_ptr(b);
44624         b_conv.is_owned = ptr_is_owned(b);
44625         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44626         b_conv.is_owned = false;
44627         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
44628         return ret_conv;
44629 }
44630
44631 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
44632         LDKInitFeatures ret_var = InitFeatures_clone(arg);
44633         int64_t ret_ref = 0;
44634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44635         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44636         return ret_ref;
44637 }
44638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44639         LDKInitFeatures arg_conv;
44640         arg_conv.inner = untag_ptr(arg);
44641         arg_conv.is_owned = ptr_is_owned(arg);
44642         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44643         arg_conv.is_owned = false;
44644         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
44645         return ret_conv;
44646 }
44647
44648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44649         LDKInitFeatures orig_conv;
44650         orig_conv.inner = untag_ptr(orig);
44651         orig_conv.is_owned = ptr_is_owned(orig);
44652         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44653         orig_conv.is_owned = false;
44654         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
44655         int64_t ret_ref = 0;
44656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44657         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44658         return ret_ref;
44659 }
44660
44661 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
44662         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
44663         int64_t ret_ref = 0;
44664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44665         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44666         return ret_ref;
44667 }
44668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44669         LDKNodeFeatures arg_conv;
44670         arg_conv.inner = untag_ptr(arg);
44671         arg_conv.is_owned = ptr_is_owned(arg);
44672         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44673         arg_conv.is_owned = false;
44674         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
44675         return ret_conv;
44676 }
44677
44678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44679         LDKNodeFeatures orig_conv;
44680         orig_conv.inner = untag_ptr(orig);
44681         orig_conv.is_owned = ptr_is_owned(orig);
44682         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44683         orig_conv.is_owned = false;
44684         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
44685         int64_t ret_ref = 0;
44686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44687         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44688         return ret_ref;
44689 }
44690
44691 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
44692         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
44693         int64_t ret_ref = 0;
44694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44696         return ret_ref;
44697 }
44698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44699         LDKChannelFeatures arg_conv;
44700         arg_conv.inner = untag_ptr(arg);
44701         arg_conv.is_owned = ptr_is_owned(arg);
44702         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44703         arg_conv.is_owned = false;
44704         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
44705         return ret_conv;
44706 }
44707
44708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44709         LDKChannelFeatures orig_conv;
44710         orig_conv.inner = untag_ptr(orig);
44711         orig_conv.is_owned = ptr_is_owned(orig);
44712         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44713         orig_conv.is_owned = false;
44714         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
44715         int64_t ret_ref = 0;
44716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44717         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44718         return ret_ref;
44719 }
44720
44721 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
44722         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
44723         int64_t ret_ref = 0;
44724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44725         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44726         return ret_ref;
44727 }
44728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44729         LDKInvoiceFeatures arg_conv;
44730         arg_conv.inner = untag_ptr(arg);
44731         arg_conv.is_owned = ptr_is_owned(arg);
44732         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44733         arg_conv.is_owned = false;
44734         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
44735         return ret_conv;
44736 }
44737
44738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44739         LDKInvoiceFeatures orig_conv;
44740         orig_conv.inner = untag_ptr(orig);
44741         orig_conv.is_owned = ptr_is_owned(orig);
44742         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44743         orig_conv.is_owned = false;
44744         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
44745         int64_t ret_ref = 0;
44746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44747         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44748         return ret_ref;
44749 }
44750
44751 static inline uint64_t OfferFeatures_clone_ptr(LDKOfferFeatures *NONNULL_PTR arg) {
44752         LDKOfferFeatures ret_var = OfferFeatures_clone(arg);
44753         int64_t ret_ref = 0;
44754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44755         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44756         return ret_ref;
44757 }
44758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44759         LDKOfferFeatures arg_conv;
44760         arg_conv.inner = untag_ptr(arg);
44761         arg_conv.is_owned = ptr_is_owned(arg);
44762         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44763         arg_conv.is_owned = false;
44764         int64_t ret_conv = OfferFeatures_clone_ptr(&arg_conv);
44765         return ret_conv;
44766 }
44767
44768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44769         LDKOfferFeatures orig_conv;
44770         orig_conv.inner = untag_ptr(orig);
44771         orig_conv.is_owned = ptr_is_owned(orig);
44772         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44773         orig_conv.is_owned = false;
44774         LDKOfferFeatures ret_var = OfferFeatures_clone(&orig_conv);
44775         int64_t ret_ref = 0;
44776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44777         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44778         return ret_ref;
44779 }
44780
44781 static inline uint64_t InvoiceRequestFeatures_clone_ptr(LDKInvoiceRequestFeatures *NONNULL_PTR arg) {
44782         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(arg);
44783         int64_t ret_ref = 0;
44784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44785         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44786         return ret_ref;
44787 }
44788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44789         LDKInvoiceRequestFeatures arg_conv;
44790         arg_conv.inner = untag_ptr(arg);
44791         arg_conv.is_owned = ptr_is_owned(arg);
44792         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44793         arg_conv.is_owned = false;
44794         int64_t ret_conv = InvoiceRequestFeatures_clone_ptr(&arg_conv);
44795         return ret_conv;
44796 }
44797
44798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44799         LDKInvoiceRequestFeatures orig_conv;
44800         orig_conv.inner = untag_ptr(orig);
44801         orig_conv.is_owned = ptr_is_owned(orig);
44802         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44803         orig_conv.is_owned = false;
44804         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(&orig_conv);
44805         int64_t ret_ref = 0;
44806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44807         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44808         return ret_ref;
44809 }
44810
44811 static inline uint64_t Bolt12InvoiceFeatures_clone_ptr(LDKBolt12InvoiceFeatures *NONNULL_PTR arg) {
44812         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(arg);
44813         int64_t ret_ref = 0;
44814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44815         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44816         return ret_ref;
44817 }
44818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44819         LDKBolt12InvoiceFeatures arg_conv;
44820         arg_conv.inner = untag_ptr(arg);
44821         arg_conv.is_owned = ptr_is_owned(arg);
44822         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44823         arg_conv.is_owned = false;
44824         int64_t ret_conv = Bolt12InvoiceFeatures_clone_ptr(&arg_conv);
44825         return ret_conv;
44826 }
44827
44828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44829         LDKBolt12InvoiceFeatures orig_conv;
44830         orig_conv.inner = untag_ptr(orig);
44831         orig_conv.is_owned = ptr_is_owned(orig);
44832         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44833         orig_conv.is_owned = false;
44834         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(&orig_conv);
44835         int64_t ret_ref = 0;
44836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44837         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44838         return ret_ref;
44839 }
44840
44841 static inline uint64_t BlindedHopFeatures_clone_ptr(LDKBlindedHopFeatures *NONNULL_PTR arg) {
44842         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(arg);
44843         int64_t ret_ref = 0;
44844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44845         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44846         return ret_ref;
44847 }
44848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44849         LDKBlindedHopFeatures arg_conv;
44850         arg_conv.inner = untag_ptr(arg);
44851         arg_conv.is_owned = ptr_is_owned(arg);
44852         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44853         arg_conv.is_owned = false;
44854         int64_t ret_conv = BlindedHopFeatures_clone_ptr(&arg_conv);
44855         return ret_conv;
44856 }
44857
44858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44859         LDKBlindedHopFeatures orig_conv;
44860         orig_conv.inner = untag_ptr(orig);
44861         orig_conv.is_owned = ptr_is_owned(orig);
44862         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44863         orig_conv.is_owned = false;
44864         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(&orig_conv);
44865         int64_t ret_ref = 0;
44866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44867         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44868         return ret_ref;
44869 }
44870
44871 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
44872         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
44873         int64_t ret_ref = 0;
44874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44875         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44876         return ret_ref;
44877 }
44878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44879         LDKChannelTypeFeatures arg_conv;
44880         arg_conv.inner = untag_ptr(arg);
44881         arg_conv.is_owned = ptr_is_owned(arg);
44882         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44883         arg_conv.is_owned = false;
44884         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
44885         return ret_conv;
44886 }
44887
44888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44889         LDKChannelTypeFeatures orig_conv;
44890         orig_conv.inner = untag_ptr(orig);
44891         orig_conv.is_owned = ptr_is_owned(orig);
44892         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44893         orig_conv.is_owned = false;
44894         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
44895         int64_t ret_ref = 0;
44896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44897         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44898         return ret_ref;
44899 }
44900
44901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44902         LDKInitFeatures this_obj_conv;
44903         this_obj_conv.inner = untag_ptr(this_obj);
44904         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44906         InitFeatures_free(this_obj_conv);
44907 }
44908
44909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44910         LDKNodeFeatures this_obj_conv;
44911         this_obj_conv.inner = untag_ptr(this_obj);
44912         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44914         NodeFeatures_free(this_obj_conv);
44915 }
44916
44917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44918         LDKChannelFeatures this_obj_conv;
44919         this_obj_conv.inner = untag_ptr(this_obj);
44920         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44922         ChannelFeatures_free(this_obj_conv);
44923 }
44924
44925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44926         LDKInvoiceFeatures this_obj_conv;
44927         this_obj_conv.inner = untag_ptr(this_obj);
44928         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44930         InvoiceFeatures_free(this_obj_conv);
44931 }
44932
44933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44934         LDKOfferFeatures this_obj_conv;
44935         this_obj_conv.inner = untag_ptr(this_obj);
44936         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44938         OfferFeatures_free(this_obj_conv);
44939 }
44940
44941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44942         LDKInvoiceRequestFeatures this_obj_conv;
44943         this_obj_conv.inner = untag_ptr(this_obj);
44944         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44946         InvoiceRequestFeatures_free(this_obj_conv);
44947 }
44948
44949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44950         LDKBolt12InvoiceFeatures this_obj_conv;
44951         this_obj_conv.inner = untag_ptr(this_obj);
44952         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44954         Bolt12InvoiceFeatures_free(this_obj_conv);
44955 }
44956
44957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44958         LDKBlindedHopFeatures this_obj_conv;
44959         this_obj_conv.inner = untag_ptr(this_obj);
44960         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44962         BlindedHopFeatures_free(this_obj_conv);
44963 }
44964
44965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44966         LDKChannelTypeFeatures this_obj_conv;
44967         this_obj_conv.inner = untag_ptr(this_obj);
44968         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44970         ChannelTypeFeatures_free(this_obj_conv);
44971 }
44972
44973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
44974         LDKInitFeatures ret_var = InitFeatures_empty();
44975         int64_t ret_ref = 0;
44976         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44977         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44978         return ret_ref;
44979 }
44980
44981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44982         LDKInitFeatures this_arg_conv;
44983         this_arg_conv.inner = untag_ptr(this_arg);
44984         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44986         this_arg_conv.is_owned = false;
44987         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
44988         return ret_conv;
44989 }
44990
44991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
44992         LDKNodeFeatures ret_var = NodeFeatures_empty();
44993         int64_t ret_ref = 0;
44994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44995         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44996         return ret_ref;
44997 }
44998
44999 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45000         LDKNodeFeatures this_arg_conv;
45001         this_arg_conv.inner = untag_ptr(this_arg);
45002         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45004         this_arg_conv.is_owned = false;
45005         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
45006         return ret_conv;
45007 }
45008
45009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
45010         LDKChannelFeatures ret_var = ChannelFeatures_empty();
45011         int64_t ret_ref = 0;
45012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45013         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45014         return ret_ref;
45015 }
45016
45017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45018         LDKChannelFeatures this_arg_conv;
45019         this_arg_conv.inner = untag_ptr(this_arg);
45020         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45022         this_arg_conv.is_owned = false;
45023         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
45024         return ret_conv;
45025 }
45026
45027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
45028         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
45029         int64_t ret_ref = 0;
45030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45031         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45032         return ret_ref;
45033 }
45034
45035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45036         LDKInvoiceFeatures this_arg_conv;
45037         this_arg_conv.inner = untag_ptr(this_arg);
45038         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45040         this_arg_conv.is_owned = false;
45041         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
45042         return ret_conv;
45043 }
45044
45045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1empty(JNIEnv *env, jclass clz) {
45046         LDKOfferFeatures ret_var = OfferFeatures_empty();
45047         int64_t ret_ref = 0;
45048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45050         return ret_ref;
45051 }
45052
45053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45054         LDKOfferFeatures this_arg_conv;
45055         this_arg_conv.inner = untag_ptr(this_arg);
45056         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45058         this_arg_conv.is_owned = false;
45059         jboolean ret_conv = OfferFeatures_requires_unknown_bits(&this_arg_conv);
45060         return ret_conv;
45061 }
45062
45063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1empty(JNIEnv *env, jclass clz) {
45064         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_empty();
45065         int64_t ret_ref = 0;
45066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45067         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45068         return ret_ref;
45069 }
45070
45071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45072         LDKInvoiceRequestFeatures this_arg_conv;
45073         this_arg_conv.inner = untag_ptr(this_arg);
45074         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45076         this_arg_conv.is_owned = false;
45077         jboolean ret_conv = InvoiceRequestFeatures_requires_unknown_bits(&this_arg_conv);
45078         return ret_conv;
45079 }
45080
45081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
45082         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_empty();
45083         int64_t ret_ref = 0;
45084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45085         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45086         return ret_ref;
45087 }
45088
45089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45090         LDKBolt12InvoiceFeatures this_arg_conv;
45091         this_arg_conv.inner = untag_ptr(this_arg);
45092         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45094         this_arg_conv.is_owned = false;
45095         jboolean ret_conv = Bolt12InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
45096         return ret_conv;
45097 }
45098
45099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1empty(JNIEnv *env, jclass clz) {
45100         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_empty();
45101         int64_t ret_ref = 0;
45102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45103         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45104         return ret_ref;
45105 }
45106
45107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45108         LDKBlindedHopFeatures this_arg_conv;
45109         this_arg_conv.inner = untag_ptr(this_arg);
45110         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45112         this_arg_conv.is_owned = false;
45113         jboolean ret_conv = BlindedHopFeatures_requires_unknown_bits(&this_arg_conv);
45114         return ret_conv;
45115 }
45116
45117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
45118         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
45119         int64_t ret_ref = 0;
45120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45121         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45122         return ret_ref;
45123 }
45124
45125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45126         LDKChannelTypeFeatures this_arg_conv;
45127         this_arg_conv.inner = untag_ptr(this_arg);
45128         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45130         this_arg_conv.is_owned = false;
45131         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
45132         return ret_conv;
45133 }
45134
45135 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45136         LDKInitFeatures obj_conv;
45137         obj_conv.inner = untag_ptr(obj);
45138         obj_conv.is_owned = ptr_is_owned(obj);
45139         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45140         obj_conv.is_owned = false;
45141         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
45142         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45143         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45144         CVec_u8Z_free(ret_var);
45145         return ret_arr;
45146 }
45147
45148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45149         LDKu8slice ser_ref;
45150         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45151         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45152         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
45153         *ret_conv = InitFeatures_read(ser_ref);
45154         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45155         return tag_ptr(ret_conv, true);
45156 }
45157
45158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45159         LDKChannelFeatures obj_conv;
45160         obj_conv.inner = untag_ptr(obj);
45161         obj_conv.is_owned = ptr_is_owned(obj);
45162         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45163         obj_conv.is_owned = false;
45164         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
45165         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45166         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45167         CVec_u8Z_free(ret_var);
45168         return ret_arr;
45169 }
45170
45171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45172         LDKu8slice ser_ref;
45173         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45174         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45175         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
45176         *ret_conv = ChannelFeatures_read(ser_ref);
45177         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45178         return tag_ptr(ret_conv, true);
45179 }
45180
45181 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45182         LDKNodeFeatures obj_conv;
45183         obj_conv.inner = untag_ptr(obj);
45184         obj_conv.is_owned = ptr_is_owned(obj);
45185         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45186         obj_conv.is_owned = false;
45187         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
45188         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45189         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45190         CVec_u8Z_free(ret_var);
45191         return ret_arr;
45192 }
45193
45194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45195         LDKu8slice ser_ref;
45196         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45197         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45198         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
45199         *ret_conv = NodeFeatures_read(ser_ref);
45200         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45201         return tag_ptr(ret_conv, true);
45202 }
45203
45204 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45205         LDKInvoiceFeatures obj_conv;
45206         obj_conv.inner = untag_ptr(obj);
45207         obj_conv.is_owned = ptr_is_owned(obj);
45208         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45209         obj_conv.is_owned = false;
45210         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
45211         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45212         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45213         CVec_u8Z_free(ret_var);
45214         return ret_arr;
45215 }
45216
45217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45218         LDKu8slice ser_ref;
45219         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45220         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45221         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
45222         *ret_conv = InvoiceFeatures_read(ser_ref);
45223         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45224         return tag_ptr(ret_conv, true);
45225 }
45226
45227 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45228         LDKBlindedHopFeatures obj_conv;
45229         obj_conv.inner = untag_ptr(obj);
45230         obj_conv.is_owned = ptr_is_owned(obj);
45231         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45232         obj_conv.is_owned = false;
45233         LDKCVec_u8Z ret_var = BlindedHopFeatures_write(&obj_conv);
45234         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45235         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45236         CVec_u8Z_free(ret_var);
45237         return ret_arr;
45238 }
45239
45240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45241         LDKu8slice ser_ref;
45242         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45243         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45244         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
45245         *ret_conv = BlindedHopFeatures_read(ser_ref);
45246         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45247         return tag_ptr(ret_conv, true);
45248 }
45249
45250 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45251         LDKChannelTypeFeatures obj_conv;
45252         obj_conv.inner = untag_ptr(obj);
45253         obj_conv.is_owned = ptr_is_owned(obj);
45254         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45255         obj_conv.is_owned = false;
45256         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
45257         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45258         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45259         CVec_u8Z_free(ret_var);
45260         return ret_arr;
45261 }
45262
45263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45264         LDKu8slice ser_ref;
45265         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45266         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45267         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
45268         *ret_conv = ChannelTypeFeatures_read(ser_ref);
45269         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45270         return tag_ptr(ret_conv, true);
45271 }
45272
45273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45274         LDKInitFeatures this_arg_conv;
45275         this_arg_conv.inner = untag_ptr(this_arg);
45276         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45278         this_arg_conv.is_owned = false;
45279         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
45280 }
45281
45282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45283         LDKInitFeatures this_arg_conv;
45284         this_arg_conv.inner = untag_ptr(this_arg);
45285         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45287         this_arg_conv.is_owned = false;
45288         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
45289 }
45290
45291 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45292         LDKInitFeatures this_arg_conv;
45293         this_arg_conv.inner = untag_ptr(this_arg);
45294         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45296         this_arg_conv.is_owned = false;
45297         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
45298         return ret_conv;
45299 }
45300
45301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45302         LDKNodeFeatures this_arg_conv;
45303         this_arg_conv.inner = untag_ptr(this_arg);
45304         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45306         this_arg_conv.is_owned = false;
45307         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
45308 }
45309
45310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45311         LDKNodeFeatures this_arg_conv;
45312         this_arg_conv.inner = untag_ptr(this_arg);
45313         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45315         this_arg_conv.is_owned = false;
45316         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
45317 }
45318
45319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45320         LDKNodeFeatures this_arg_conv;
45321         this_arg_conv.inner = untag_ptr(this_arg);
45322         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45324         this_arg_conv.is_owned = false;
45325         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
45326         return ret_conv;
45327 }
45328
45329 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45330         LDKInitFeatures this_arg_conv;
45331         this_arg_conv.inner = untag_ptr(this_arg);
45332         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45334         this_arg_conv.is_owned = false;
45335         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
45336         return ret_conv;
45337 }
45338
45339 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45340         LDKNodeFeatures this_arg_conv;
45341         this_arg_conv.inner = untag_ptr(this_arg);
45342         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45344         this_arg_conv.is_owned = false;
45345         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
45346         return ret_conv;
45347 }
45348
45349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45350         LDKInitFeatures this_arg_conv;
45351         this_arg_conv.inner = untag_ptr(this_arg);
45352         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45354         this_arg_conv.is_owned = false;
45355         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
45356 }
45357
45358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45359         LDKInitFeatures this_arg_conv;
45360         this_arg_conv.inner = untag_ptr(this_arg);
45361         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45363         this_arg_conv.is_owned = false;
45364         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
45365 }
45366
45367 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
45368         LDKInitFeatures this_arg_conv;
45369         this_arg_conv.inner = untag_ptr(this_arg);
45370         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45372         this_arg_conv.is_owned = false;
45373         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
45374         return ret_conv;
45375 }
45376
45377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45378         LDKInitFeatures this_arg_conv;
45379         this_arg_conv.inner = untag_ptr(this_arg);
45380         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45382         this_arg_conv.is_owned = false;
45383         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
45384 }
45385
45386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45387         LDKInitFeatures this_arg_conv;
45388         this_arg_conv.inner = untag_ptr(this_arg);
45389         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45391         this_arg_conv.is_owned = false;
45392         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
45393 }
45394
45395 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45396         LDKInitFeatures this_arg_conv;
45397         this_arg_conv.inner = untag_ptr(this_arg);
45398         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45400         this_arg_conv.is_owned = false;
45401         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
45402         return ret_conv;
45403 }
45404
45405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45406         LDKNodeFeatures this_arg_conv;
45407         this_arg_conv.inner = untag_ptr(this_arg);
45408         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45410         this_arg_conv.is_owned = false;
45411         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
45412 }
45413
45414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45415         LDKNodeFeatures this_arg_conv;
45416         this_arg_conv.inner = untag_ptr(this_arg);
45417         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45419         this_arg_conv.is_owned = false;
45420         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
45421 }
45422
45423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45424         LDKNodeFeatures this_arg_conv;
45425         this_arg_conv.inner = untag_ptr(this_arg);
45426         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45428         this_arg_conv.is_owned = false;
45429         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
45430         return ret_conv;
45431 }
45432
45433 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45434         LDKInitFeatures this_arg_conv;
45435         this_arg_conv.inner = untag_ptr(this_arg);
45436         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45438         this_arg_conv.is_owned = false;
45439         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
45440         return ret_conv;
45441 }
45442
45443 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45444         LDKNodeFeatures this_arg_conv;
45445         this_arg_conv.inner = untag_ptr(this_arg);
45446         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45448         this_arg_conv.is_owned = false;
45449         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
45450         return ret_conv;
45451 }
45452
45453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45454         LDKInitFeatures this_arg_conv;
45455         this_arg_conv.inner = untag_ptr(this_arg);
45456         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45458         this_arg_conv.is_owned = false;
45459         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
45460 }
45461
45462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45463         LDKInitFeatures this_arg_conv;
45464         this_arg_conv.inner = untag_ptr(this_arg);
45465         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45467         this_arg_conv.is_owned = false;
45468         InitFeatures_set_gossip_queries_required(&this_arg_conv);
45469 }
45470
45471 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45472         LDKInitFeatures this_arg_conv;
45473         this_arg_conv.inner = untag_ptr(this_arg);
45474         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45476         this_arg_conv.is_owned = false;
45477         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
45478         return ret_conv;
45479 }
45480
45481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45482         LDKNodeFeatures this_arg_conv;
45483         this_arg_conv.inner = untag_ptr(this_arg);
45484         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45486         this_arg_conv.is_owned = false;
45487         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
45488 }
45489
45490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45491         LDKNodeFeatures this_arg_conv;
45492         this_arg_conv.inner = untag_ptr(this_arg);
45493         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45495         this_arg_conv.is_owned = false;
45496         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
45497 }
45498
45499 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45500         LDKNodeFeatures this_arg_conv;
45501         this_arg_conv.inner = untag_ptr(this_arg);
45502         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45504         this_arg_conv.is_owned = false;
45505         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
45506         return ret_conv;
45507 }
45508
45509 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45510         LDKInitFeatures this_arg_conv;
45511         this_arg_conv.inner = untag_ptr(this_arg);
45512         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45514         this_arg_conv.is_owned = false;
45515         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
45516         return ret_conv;
45517 }
45518
45519 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45520         LDKNodeFeatures this_arg_conv;
45521         this_arg_conv.inner = untag_ptr(this_arg);
45522         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45524         this_arg_conv.is_owned = false;
45525         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
45526         return ret_conv;
45527 }
45528
45529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45530         LDKInitFeatures this_arg_conv;
45531         this_arg_conv.inner = untag_ptr(this_arg);
45532         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45534         this_arg_conv.is_owned = false;
45535         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
45536 }
45537
45538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45539         LDKInitFeatures this_arg_conv;
45540         this_arg_conv.inner = untag_ptr(this_arg);
45541         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45543         this_arg_conv.is_owned = false;
45544         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
45545 }
45546
45547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45548         LDKInitFeatures this_arg_conv;
45549         this_arg_conv.inner = untag_ptr(this_arg);
45550         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45552         this_arg_conv.is_owned = false;
45553         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
45554         return ret_conv;
45555 }
45556
45557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45558         LDKNodeFeatures this_arg_conv;
45559         this_arg_conv.inner = untag_ptr(this_arg);
45560         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45562         this_arg_conv.is_owned = false;
45563         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
45564 }
45565
45566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45567         LDKNodeFeatures this_arg_conv;
45568         this_arg_conv.inner = untag_ptr(this_arg);
45569         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45571         this_arg_conv.is_owned = false;
45572         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
45573 }
45574
45575 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45576         LDKNodeFeatures this_arg_conv;
45577         this_arg_conv.inner = untag_ptr(this_arg);
45578         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45580         this_arg_conv.is_owned = false;
45581         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
45582         return ret_conv;
45583 }
45584
45585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45586         LDKInvoiceFeatures this_arg_conv;
45587         this_arg_conv.inner = untag_ptr(this_arg);
45588         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45590         this_arg_conv.is_owned = false;
45591         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
45592 }
45593
45594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45595         LDKInvoiceFeatures this_arg_conv;
45596         this_arg_conv.inner = untag_ptr(this_arg);
45597         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45599         this_arg_conv.is_owned = false;
45600         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
45601 }
45602
45603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45604         LDKInvoiceFeatures this_arg_conv;
45605         this_arg_conv.inner = untag_ptr(this_arg);
45606         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45608         this_arg_conv.is_owned = false;
45609         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
45610         return ret_conv;
45611 }
45612
45613 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45614         LDKInitFeatures this_arg_conv;
45615         this_arg_conv.inner = untag_ptr(this_arg);
45616         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45618         this_arg_conv.is_owned = false;
45619         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
45620         return ret_conv;
45621 }
45622
45623 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45624         LDKNodeFeatures this_arg_conv;
45625         this_arg_conv.inner = untag_ptr(this_arg);
45626         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45628         this_arg_conv.is_owned = false;
45629         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
45630         return ret_conv;
45631 }
45632
45633 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45634         LDKInvoiceFeatures this_arg_conv;
45635         this_arg_conv.inner = untag_ptr(this_arg);
45636         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45638         this_arg_conv.is_owned = false;
45639         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
45640         return ret_conv;
45641 }
45642
45643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45644         LDKInitFeatures this_arg_conv;
45645         this_arg_conv.inner = untag_ptr(this_arg);
45646         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45648         this_arg_conv.is_owned = false;
45649         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
45650 }
45651
45652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45653         LDKInitFeatures this_arg_conv;
45654         this_arg_conv.inner = untag_ptr(this_arg);
45655         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45657         this_arg_conv.is_owned = false;
45658         InitFeatures_set_static_remote_key_required(&this_arg_conv);
45659 }
45660
45661 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45662         LDKInitFeatures this_arg_conv;
45663         this_arg_conv.inner = untag_ptr(this_arg);
45664         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45666         this_arg_conv.is_owned = false;
45667         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
45668         return ret_conv;
45669 }
45670
45671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45672         LDKNodeFeatures this_arg_conv;
45673         this_arg_conv.inner = untag_ptr(this_arg);
45674         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45676         this_arg_conv.is_owned = false;
45677         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
45678 }
45679
45680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45681         LDKNodeFeatures this_arg_conv;
45682         this_arg_conv.inner = untag_ptr(this_arg);
45683         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45685         this_arg_conv.is_owned = false;
45686         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
45687 }
45688
45689 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45690         LDKNodeFeatures this_arg_conv;
45691         this_arg_conv.inner = untag_ptr(this_arg);
45692         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45694         this_arg_conv.is_owned = false;
45695         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
45696         return ret_conv;
45697 }
45698
45699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45700         LDKChannelTypeFeatures this_arg_conv;
45701         this_arg_conv.inner = untag_ptr(this_arg);
45702         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45704         this_arg_conv.is_owned = false;
45705         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
45706 }
45707
45708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45709         LDKChannelTypeFeatures this_arg_conv;
45710         this_arg_conv.inner = untag_ptr(this_arg);
45711         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45713         this_arg_conv.is_owned = false;
45714         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
45715 }
45716
45717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45718         LDKChannelTypeFeatures this_arg_conv;
45719         this_arg_conv.inner = untag_ptr(this_arg);
45720         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45722         this_arg_conv.is_owned = false;
45723         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
45724         return ret_conv;
45725 }
45726
45727 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45728         LDKInitFeatures this_arg_conv;
45729         this_arg_conv.inner = untag_ptr(this_arg);
45730         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45732         this_arg_conv.is_owned = false;
45733         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
45734         return ret_conv;
45735 }
45736
45737 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45738         LDKNodeFeatures this_arg_conv;
45739         this_arg_conv.inner = untag_ptr(this_arg);
45740         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45742         this_arg_conv.is_owned = false;
45743         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
45744         return ret_conv;
45745 }
45746
45747 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45748         LDKChannelTypeFeatures this_arg_conv;
45749         this_arg_conv.inner = untag_ptr(this_arg);
45750         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45752         this_arg_conv.is_owned = false;
45753         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
45754         return ret_conv;
45755 }
45756
45757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45758         LDKInitFeatures this_arg_conv;
45759         this_arg_conv.inner = untag_ptr(this_arg);
45760         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45762         this_arg_conv.is_owned = false;
45763         InitFeatures_set_payment_secret_optional(&this_arg_conv);
45764 }
45765
45766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45767         LDKInitFeatures this_arg_conv;
45768         this_arg_conv.inner = untag_ptr(this_arg);
45769         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45771         this_arg_conv.is_owned = false;
45772         InitFeatures_set_payment_secret_required(&this_arg_conv);
45773 }
45774
45775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45776         LDKInitFeatures this_arg_conv;
45777         this_arg_conv.inner = untag_ptr(this_arg);
45778         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45780         this_arg_conv.is_owned = false;
45781         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
45782         return ret_conv;
45783 }
45784
45785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45786         LDKNodeFeatures this_arg_conv;
45787         this_arg_conv.inner = untag_ptr(this_arg);
45788         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45790         this_arg_conv.is_owned = false;
45791         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
45792 }
45793
45794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45795         LDKNodeFeatures this_arg_conv;
45796         this_arg_conv.inner = untag_ptr(this_arg);
45797         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45799         this_arg_conv.is_owned = false;
45800         NodeFeatures_set_payment_secret_required(&this_arg_conv);
45801 }
45802
45803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45804         LDKNodeFeatures this_arg_conv;
45805         this_arg_conv.inner = untag_ptr(this_arg);
45806         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45808         this_arg_conv.is_owned = false;
45809         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
45810         return ret_conv;
45811 }
45812
45813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45814         LDKInvoiceFeatures this_arg_conv;
45815         this_arg_conv.inner = untag_ptr(this_arg);
45816         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45818         this_arg_conv.is_owned = false;
45819         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
45820 }
45821
45822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45823         LDKInvoiceFeatures this_arg_conv;
45824         this_arg_conv.inner = untag_ptr(this_arg);
45825         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45827         this_arg_conv.is_owned = false;
45828         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
45829 }
45830
45831 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45832         LDKInvoiceFeatures this_arg_conv;
45833         this_arg_conv.inner = untag_ptr(this_arg);
45834         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45836         this_arg_conv.is_owned = false;
45837         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
45838         return ret_conv;
45839 }
45840
45841 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45842         LDKInitFeatures this_arg_conv;
45843         this_arg_conv.inner = untag_ptr(this_arg);
45844         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45846         this_arg_conv.is_owned = false;
45847         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
45848         return ret_conv;
45849 }
45850
45851 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45852         LDKNodeFeatures this_arg_conv;
45853         this_arg_conv.inner = untag_ptr(this_arg);
45854         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45856         this_arg_conv.is_owned = false;
45857         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
45858         return ret_conv;
45859 }
45860
45861 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45862         LDKInvoiceFeatures this_arg_conv;
45863         this_arg_conv.inner = untag_ptr(this_arg);
45864         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45866         this_arg_conv.is_owned = false;
45867         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
45868         return ret_conv;
45869 }
45870
45871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45872         LDKInitFeatures this_arg_conv;
45873         this_arg_conv.inner = untag_ptr(this_arg);
45874         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45876         this_arg_conv.is_owned = false;
45877         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
45878 }
45879
45880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45881         LDKInitFeatures this_arg_conv;
45882         this_arg_conv.inner = untag_ptr(this_arg);
45883         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45885         this_arg_conv.is_owned = false;
45886         InitFeatures_set_basic_mpp_required(&this_arg_conv);
45887 }
45888
45889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45890         LDKInitFeatures this_arg_conv;
45891         this_arg_conv.inner = untag_ptr(this_arg);
45892         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45894         this_arg_conv.is_owned = false;
45895         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
45896         return ret_conv;
45897 }
45898
45899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45900         LDKNodeFeatures this_arg_conv;
45901         this_arg_conv.inner = untag_ptr(this_arg);
45902         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45904         this_arg_conv.is_owned = false;
45905         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
45906 }
45907
45908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45909         LDKNodeFeatures this_arg_conv;
45910         this_arg_conv.inner = untag_ptr(this_arg);
45911         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45913         this_arg_conv.is_owned = false;
45914         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
45915 }
45916
45917 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45918         LDKNodeFeatures this_arg_conv;
45919         this_arg_conv.inner = untag_ptr(this_arg);
45920         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45922         this_arg_conv.is_owned = false;
45923         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
45924         return ret_conv;
45925 }
45926
45927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45928         LDKInvoiceFeatures this_arg_conv;
45929         this_arg_conv.inner = untag_ptr(this_arg);
45930         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45932         this_arg_conv.is_owned = false;
45933         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
45934 }
45935
45936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45937         LDKInvoiceFeatures this_arg_conv;
45938         this_arg_conv.inner = untag_ptr(this_arg);
45939         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45941         this_arg_conv.is_owned = false;
45942         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
45943 }
45944
45945 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45946         LDKInvoiceFeatures this_arg_conv;
45947         this_arg_conv.inner = untag_ptr(this_arg);
45948         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45950         this_arg_conv.is_owned = false;
45951         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
45952         return ret_conv;
45953 }
45954
45955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45956         LDKBolt12InvoiceFeatures this_arg_conv;
45957         this_arg_conv.inner = untag_ptr(this_arg);
45958         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45960         this_arg_conv.is_owned = false;
45961         Bolt12InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
45962 }
45963
45964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45965         LDKBolt12InvoiceFeatures this_arg_conv;
45966         this_arg_conv.inner = untag_ptr(this_arg);
45967         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45969         this_arg_conv.is_owned = false;
45970         Bolt12InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
45971 }
45972
45973 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45974         LDKBolt12InvoiceFeatures this_arg_conv;
45975         this_arg_conv.inner = untag_ptr(this_arg);
45976         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45978         this_arg_conv.is_owned = false;
45979         jboolean ret_conv = Bolt12InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
45980         return ret_conv;
45981 }
45982
45983 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45984         LDKInitFeatures this_arg_conv;
45985         this_arg_conv.inner = untag_ptr(this_arg);
45986         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45988         this_arg_conv.is_owned = false;
45989         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
45990         return ret_conv;
45991 }
45992
45993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45994         LDKNodeFeatures this_arg_conv;
45995         this_arg_conv.inner = untag_ptr(this_arg);
45996         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45998         this_arg_conv.is_owned = false;
45999         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
46000         return ret_conv;
46001 }
46002
46003 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
46004         LDKInvoiceFeatures this_arg_conv;
46005         this_arg_conv.inner = untag_ptr(this_arg);
46006         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46008         this_arg_conv.is_owned = false;
46009         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
46010         return ret_conv;
46011 }
46012
46013 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
46014         LDKBolt12InvoiceFeatures this_arg_conv;
46015         this_arg_conv.inner = untag_ptr(this_arg);
46016         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46018         this_arg_conv.is_owned = false;
46019         jboolean ret_conv = Bolt12InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
46020         return ret_conv;
46021 }
46022
46023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46024         LDKInitFeatures this_arg_conv;
46025         this_arg_conv.inner = untag_ptr(this_arg);
46026         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46028         this_arg_conv.is_owned = false;
46029         InitFeatures_set_wumbo_optional(&this_arg_conv);
46030 }
46031
46032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46033         LDKInitFeatures this_arg_conv;
46034         this_arg_conv.inner = untag_ptr(this_arg);
46035         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46037         this_arg_conv.is_owned = false;
46038         InitFeatures_set_wumbo_required(&this_arg_conv);
46039 }
46040
46041 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46042         LDKInitFeatures this_arg_conv;
46043         this_arg_conv.inner = untag_ptr(this_arg);
46044         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46046         this_arg_conv.is_owned = false;
46047         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
46048         return ret_conv;
46049 }
46050
46051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46052         LDKNodeFeatures this_arg_conv;
46053         this_arg_conv.inner = untag_ptr(this_arg);
46054         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46056         this_arg_conv.is_owned = false;
46057         NodeFeatures_set_wumbo_optional(&this_arg_conv);
46058 }
46059
46060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46061         LDKNodeFeatures this_arg_conv;
46062         this_arg_conv.inner = untag_ptr(this_arg);
46063         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46065         this_arg_conv.is_owned = false;
46066         NodeFeatures_set_wumbo_required(&this_arg_conv);
46067 }
46068
46069 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46070         LDKNodeFeatures this_arg_conv;
46071         this_arg_conv.inner = untag_ptr(this_arg);
46072         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46074         this_arg_conv.is_owned = false;
46075         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
46076         return ret_conv;
46077 }
46078
46079 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46080         LDKInitFeatures this_arg_conv;
46081         this_arg_conv.inner = untag_ptr(this_arg);
46082         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46084         this_arg_conv.is_owned = false;
46085         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
46086         return ret_conv;
46087 }
46088
46089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46090         LDKNodeFeatures this_arg_conv;
46091         this_arg_conv.inner = untag_ptr(this_arg);
46092         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46094         this_arg_conv.is_owned = false;
46095         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
46096         return ret_conv;
46097 }
46098
46099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46100         LDKInitFeatures this_arg_conv;
46101         this_arg_conv.inner = untag_ptr(this_arg);
46102         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46104         this_arg_conv.is_owned = false;
46105         InitFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
46106 }
46107
46108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46109         LDKInitFeatures this_arg_conv;
46110         this_arg_conv.inner = untag_ptr(this_arg);
46111         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46113         this_arg_conv.is_owned = false;
46114         InitFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46115 }
46116
46117 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46118         LDKInitFeatures this_arg_conv;
46119         this_arg_conv.inner = untag_ptr(this_arg);
46120         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46122         this_arg_conv.is_owned = false;
46123         jboolean ret_conv = InitFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46124         return ret_conv;
46125 }
46126
46127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46128         LDKNodeFeatures this_arg_conv;
46129         this_arg_conv.inner = untag_ptr(this_arg);
46130         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46132         this_arg_conv.is_owned = false;
46133         NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
46134 }
46135
46136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46137         LDKNodeFeatures this_arg_conv;
46138         this_arg_conv.inner = untag_ptr(this_arg);
46139         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46141         this_arg_conv.is_owned = false;
46142         NodeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46143 }
46144
46145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46146         LDKNodeFeatures this_arg_conv;
46147         this_arg_conv.inner = untag_ptr(this_arg);
46148         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46150         this_arg_conv.is_owned = false;
46151         jboolean ret_conv = NodeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46152         return ret_conv;
46153 }
46154
46155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46156         LDKChannelTypeFeatures this_arg_conv;
46157         this_arg_conv.inner = untag_ptr(this_arg);
46158         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46160         this_arg_conv.is_owned = false;
46161         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
46162 }
46163
46164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46165         LDKChannelTypeFeatures this_arg_conv;
46166         this_arg_conv.inner = untag_ptr(this_arg);
46167         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46169         this_arg_conv.is_owned = false;
46170         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46171 }
46172
46173 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46174         LDKChannelTypeFeatures this_arg_conv;
46175         this_arg_conv.inner = untag_ptr(this_arg);
46176         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46178         this_arg_conv.is_owned = false;
46179         jboolean ret_conv = ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46180         return ret_conv;
46181 }
46182
46183 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46184         LDKInitFeatures this_arg_conv;
46185         this_arg_conv.inner = untag_ptr(this_arg);
46186         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46188         this_arg_conv.is_owned = false;
46189         jboolean ret_conv = InitFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46190         return ret_conv;
46191 }
46192
46193 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46194         LDKNodeFeatures this_arg_conv;
46195         this_arg_conv.inner = untag_ptr(this_arg);
46196         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46198         this_arg_conv.is_owned = false;
46199         jboolean ret_conv = NodeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46200         return ret_conv;
46201 }
46202
46203 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46204         LDKChannelTypeFeatures this_arg_conv;
46205         this_arg_conv.inner = untag_ptr(this_arg);
46206         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46208         this_arg_conv.is_owned = false;
46209         jboolean ret_conv = ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46210         return ret_conv;
46211 }
46212
46213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46214         LDKInitFeatures this_arg_conv;
46215         this_arg_conv.inner = untag_ptr(this_arg);
46216         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46218         this_arg_conv.is_owned = false;
46219         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
46220 }
46221
46222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46223         LDKInitFeatures this_arg_conv;
46224         this_arg_conv.inner = untag_ptr(this_arg);
46225         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46227         this_arg_conv.is_owned = false;
46228         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
46229 }
46230
46231 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46232         LDKInitFeatures this_arg_conv;
46233         this_arg_conv.inner = untag_ptr(this_arg);
46234         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46236         this_arg_conv.is_owned = false;
46237         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
46238         return ret_conv;
46239 }
46240
46241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46242         LDKNodeFeatures this_arg_conv;
46243         this_arg_conv.inner = untag_ptr(this_arg);
46244         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46246         this_arg_conv.is_owned = false;
46247         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
46248 }
46249
46250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46251         LDKNodeFeatures this_arg_conv;
46252         this_arg_conv.inner = untag_ptr(this_arg);
46253         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46255         this_arg_conv.is_owned = false;
46256         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
46257 }
46258
46259 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46260         LDKNodeFeatures this_arg_conv;
46261         this_arg_conv.inner = untag_ptr(this_arg);
46262         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46264         this_arg_conv.is_owned = false;
46265         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
46266         return ret_conv;
46267 }
46268
46269 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46270         LDKInitFeatures this_arg_conv;
46271         this_arg_conv.inner = untag_ptr(this_arg);
46272         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46274         this_arg_conv.is_owned = false;
46275         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
46276         return ret_conv;
46277 }
46278
46279 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46280         LDKNodeFeatures this_arg_conv;
46281         this_arg_conv.inner = untag_ptr(this_arg);
46282         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46284         this_arg_conv.is_owned = false;
46285         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
46286         return ret_conv;
46287 }
46288
46289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46290         LDKInitFeatures this_arg_conv;
46291         this_arg_conv.inner = untag_ptr(this_arg);
46292         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46294         this_arg_conv.is_owned = false;
46295         InitFeatures_set_onion_messages_optional(&this_arg_conv);
46296 }
46297
46298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46299         LDKInitFeatures this_arg_conv;
46300         this_arg_conv.inner = untag_ptr(this_arg);
46301         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46303         this_arg_conv.is_owned = false;
46304         InitFeatures_set_onion_messages_required(&this_arg_conv);
46305 }
46306
46307 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46308         LDKInitFeatures this_arg_conv;
46309         this_arg_conv.inner = untag_ptr(this_arg);
46310         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46312         this_arg_conv.is_owned = false;
46313         jboolean ret_conv = InitFeatures_supports_onion_messages(&this_arg_conv);
46314         return ret_conv;
46315 }
46316
46317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46318         LDKNodeFeatures this_arg_conv;
46319         this_arg_conv.inner = untag_ptr(this_arg);
46320         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46322         this_arg_conv.is_owned = false;
46323         NodeFeatures_set_onion_messages_optional(&this_arg_conv);
46324 }
46325
46326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46327         LDKNodeFeatures this_arg_conv;
46328         this_arg_conv.inner = untag_ptr(this_arg);
46329         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46331         this_arg_conv.is_owned = false;
46332         NodeFeatures_set_onion_messages_required(&this_arg_conv);
46333 }
46334
46335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46336         LDKNodeFeatures this_arg_conv;
46337         this_arg_conv.inner = untag_ptr(this_arg);
46338         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46340         this_arg_conv.is_owned = false;
46341         jboolean ret_conv = NodeFeatures_supports_onion_messages(&this_arg_conv);
46342         return ret_conv;
46343 }
46344
46345 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46346         LDKInitFeatures this_arg_conv;
46347         this_arg_conv.inner = untag_ptr(this_arg);
46348         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46350         this_arg_conv.is_owned = false;
46351         jboolean ret_conv = InitFeatures_requires_onion_messages(&this_arg_conv);
46352         return ret_conv;
46353 }
46354
46355 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46356         LDKNodeFeatures this_arg_conv;
46357         this_arg_conv.inner = untag_ptr(this_arg);
46358         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46360         this_arg_conv.is_owned = false;
46361         jboolean ret_conv = NodeFeatures_requires_onion_messages(&this_arg_conv);
46362         return ret_conv;
46363 }
46364
46365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46366         LDKInitFeatures this_arg_conv;
46367         this_arg_conv.inner = untag_ptr(this_arg);
46368         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46370         this_arg_conv.is_owned = false;
46371         InitFeatures_set_channel_type_optional(&this_arg_conv);
46372 }
46373
46374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46375         LDKInitFeatures this_arg_conv;
46376         this_arg_conv.inner = untag_ptr(this_arg);
46377         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46379         this_arg_conv.is_owned = false;
46380         InitFeatures_set_channel_type_required(&this_arg_conv);
46381 }
46382
46383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46384         LDKInitFeatures this_arg_conv;
46385         this_arg_conv.inner = untag_ptr(this_arg);
46386         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46388         this_arg_conv.is_owned = false;
46389         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
46390         return ret_conv;
46391 }
46392
46393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46394         LDKNodeFeatures this_arg_conv;
46395         this_arg_conv.inner = untag_ptr(this_arg);
46396         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46398         this_arg_conv.is_owned = false;
46399         NodeFeatures_set_channel_type_optional(&this_arg_conv);
46400 }
46401
46402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46403         LDKNodeFeatures this_arg_conv;
46404         this_arg_conv.inner = untag_ptr(this_arg);
46405         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46407         this_arg_conv.is_owned = false;
46408         NodeFeatures_set_channel_type_required(&this_arg_conv);
46409 }
46410
46411 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46412         LDKNodeFeatures this_arg_conv;
46413         this_arg_conv.inner = untag_ptr(this_arg);
46414         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46416         this_arg_conv.is_owned = false;
46417         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
46418         return ret_conv;
46419 }
46420
46421 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46422         LDKInitFeatures this_arg_conv;
46423         this_arg_conv.inner = untag_ptr(this_arg);
46424         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46426         this_arg_conv.is_owned = false;
46427         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
46428         return ret_conv;
46429 }
46430
46431 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46432         LDKNodeFeatures this_arg_conv;
46433         this_arg_conv.inner = untag_ptr(this_arg);
46434         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46436         this_arg_conv.is_owned = false;
46437         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
46438         return ret_conv;
46439 }
46440
46441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46442         LDKInitFeatures this_arg_conv;
46443         this_arg_conv.inner = untag_ptr(this_arg);
46444         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46446         this_arg_conv.is_owned = false;
46447         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
46448 }
46449
46450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46451         LDKInitFeatures this_arg_conv;
46452         this_arg_conv.inner = untag_ptr(this_arg);
46453         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46455         this_arg_conv.is_owned = false;
46456         InitFeatures_set_scid_privacy_required(&this_arg_conv);
46457 }
46458
46459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46460         LDKInitFeatures this_arg_conv;
46461         this_arg_conv.inner = untag_ptr(this_arg);
46462         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46464         this_arg_conv.is_owned = false;
46465         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
46466         return ret_conv;
46467 }
46468
46469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46470         LDKNodeFeatures this_arg_conv;
46471         this_arg_conv.inner = untag_ptr(this_arg);
46472         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46474         this_arg_conv.is_owned = false;
46475         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
46476 }
46477
46478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46479         LDKNodeFeatures this_arg_conv;
46480         this_arg_conv.inner = untag_ptr(this_arg);
46481         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46483         this_arg_conv.is_owned = false;
46484         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
46485 }
46486
46487 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46488         LDKNodeFeatures this_arg_conv;
46489         this_arg_conv.inner = untag_ptr(this_arg);
46490         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46492         this_arg_conv.is_owned = false;
46493         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
46494         return ret_conv;
46495 }
46496
46497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46498         LDKChannelTypeFeatures this_arg_conv;
46499         this_arg_conv.inner = untag_ptr(this_arg);
46500         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46502         this_arg_conv.is_owned = false;
46503         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
46504 }
46505
46506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46507         LDKChannelTypeFeatures this_arg_conv;
46508         this_arg_conv.inner = untag_ptr(this_arg);
46509         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46511         this_arg_conv.is_owned = false;
46512         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
46513 }
46514
46515 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46516         LDKChannelTypeFeatures this_arg_conv;
46517         this_arg_conv.inner = untag_ptr(this_arg);
46518         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46520         this_arg_conv.is_owned = false;
46521         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
46522         return ret_conv;
46523 }
46524
46525 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46526         LDKInitFeatures this_arg_conv;
46527         this_arg_conv.inner = untag_ptr(this_arg);
46528         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46530         this_arg_conv.is_owned = false;
46531         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
46532         return ret_conv;
46533 }
46534
46535 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46536         LDKNodeFeatures this_arg_conv;
46537         this_arg_conv.inner = untag_ptr(this_arg);
46538         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46540         this_arg_conv.is_owned = false;
46541         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
46542         return ret_conv;
46543 }
46544
46545 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46546         LDKChannelTypeFeatures this_arg_conv;
46547         this_arg_conv.inner = untag_ptr(this_arg);
46548         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46550         this_arg_conv.is_owned = false;
46551         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
46552         return ret_conv;
46553 }
46554
46555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1metadata_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46556         LDKInvoiceFeatures this_arg_conv;
46557         this_arg_conv.inner = untag_ptr(this_arg);
46558         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46560         this_arg_conv.is_owned = false;
46561         InvoiceFeatures_set_payment_metadata_optional(&this_arg_conv);
46562 }
46563
46564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1metadata_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46565         LDKInvoiceFeatures this_arg_conv;
46566         this_arg_conv.inner = untag_ptr(this_arg);
46567         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46569         this_arg_conv.is_owned = false;
46570         InvoiceFeatures_set_payment_metadata_required(&this_arg_conv);
46571 }
46572
46573 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
46574         LDKInvoiceFeatures this_arg_conv;
46575         this_arg_conv.inner = untag_ptr(this_arg);
46576         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46578         this_arg_conv.is_owned = false;
46579         jboolean ret_conv = InvoiceFeatures_supports_payment_metadata(&this_arg_conv);
46580         return ret_conv;
46581 }
46582
46583 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
46584         LDKInvoiceFeatures this_arg_conv;
46585         this_arg_conv.inner = untag_ptr(this_arg);
46586         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46588         this_arg_conv.is_owned = false;
46589         jboolean ret_conv = InvoiceFeatures_requires_payment_metadata(&this_arg_conv);
46590         return ret_conv;
46591 }
46592
46593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46594         LDKInitFeatures this_arg_conv;
46595         this_arg_conv.inner = untag_ptr(this_arg);
46596         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46598         this_arg_conv.is_owned = false;
46599         InitFeatures_set_zero_conf_optional(&this_arg_conv);
46600 }
46601
46602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46603         LDKInitFeatures this_arg_conv;
46604         this_arg_conv.inner = untag_ptr(this_arg);
46605         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46607         this_arg_conv.is_owned = false;
46608         InitFeatures_set_zero_conf_required(&this_arg_conv);
46609 }
46610
46611 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46612         LDKInitFeatures this_arg_conv;
46613         this_arg_conv.inner = untag_ptr(this_arg);
46614         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46616         this_arg_conv.is_owned = false;
46617         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
46618         return ret_conv;
46619 }
46620
46621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46622         LDKNodeFeatures this_arg_conv;
46623         this_arg_conv.inner = untag_ptr(this_arg);
46624         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46626         this_arg_conv.is_owned = false;
46627         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
46628 }
46629
46630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46631         LDKNodeFeatures this_arg_conv;
46632         this_arg_conv.inner = untag_ptr(this_arg);
46633         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46635         this_arg_conv.is_owned = false;
46636         NodeFeatures_set_zero_conf_required(&this_arg_conv);
46637 }
46638
46639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46640         LDKNodeFeatures this_arg_conv;
46641         this_arg_conv.inner = untag_ptr(this_arg);
46642         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46644         this_arg_conv.is_owned = false;
46645         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
46646         return ret_conv;
46647 }
46648
46649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46650         LDKChannelTypeFeatures this_arg_conv;
46651         this_arg_conv.inner = untag_ptr(this_arg);
46652         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46654         this_arg_conv.is_owned = false;
46655         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
46656 }
46657
46658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46659         LDKChannelTypeFeatures this_arg_conv;
46660         this_arg_conv.inner = untag_ptr(this_arg);
46661         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46663         this_arg_conv.is_owned = false;
46664         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
46665 }
46666
46667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46668         LDKChannelTypeFeatures this_arg_conv;
46669         this_arg_conv.inner = untag_ptr(this_arg);
46670         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46672         this_arg_conv.is_owned = false;
46673         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
46674         return ret_conv;
46675 }
46676
46677 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46678         LDKInitFeatures this_arg_conv;
46679         this_arg_conv.inner = untag_ptr(this_arg);
46680         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46682         this_arg_conv.is_owned = false;
46683         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
46684         return ret_conv;
46685 }
46686
46687 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46688         LDKNodeFeatures this_arg_conv;
46689         this_arg_conv.inner = untag_ptr(this_arg);
46690         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46692         this_arg_conv.is_owned = false;
46693         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
46694         return ret_conv;
46695 }
46696
46697 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46698         LDKChannelTypeFeatures this_arg_conv;
46699         this_arg_conv.inner = untag_ptr(this_arg);
46700         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46702         this_arg_conv.is_owned = false;
46703         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
46704         return ret_conv;
46705 }
46706
46707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46708         LDKNodeFeatures this_arg_conv;
46709         this_arg_conv.inner = untag_ptr(this_arg);
46710         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46712         this_arg_conv.is_owned = false;
46713         NodeFeatures_set_keysend_optional(&this_arg_conv);
46714 }
46715
46716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46717         LDKNodeFeatures this_arg_conv;
46718         this_arg_conv.inner = untag_ptr(this_arg);
46719         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46721         this_arg_conv.is_owned = false;
46722         NodeFeatures_set_keysend_required(&this_arg_conv);
46723 }
46724
46725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
46726         LDKNodeFeatures this_arg_conv;
46727         this_arg_conv.inner = untag_ptr(this_arg);
46728         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46730         this_arg_conv.is_owned = false;
46731         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
46732         return ret_conv;
46733 }
46734
46735 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
46736         LDKNodeFeatures this_arg_conv;
46737         this_arg_conv.inner = untag_ptr(this_arg);
46738         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46740         this_arg_conv.is_owned = false;
46741         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
46742         return ret_conv;
46743 }
46744
46745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46746         LDKShutdownScript this_obj_conv;
46747         this_obj_conv.inner = untag_ptr(this_obj);
46748         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46750         ShutdownScript_free(this_obj_conv);
46751 }
46752
46753 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
46754         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
46755         int64_t ret_ref = 0;
46756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46757         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46758         return ret_ref;
46759 }
46760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46761         LDKShutdownScript arg_conv;
46762         arg_conv.inner = untag_ptr(arg);
46763         arg_conv.is_owned = ptr_is_owned(arg);
46764         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46765         arg_conv.is_owned = false;
46766         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
46767         return ret_conv;
46768 }
46769
46770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46771         LDKShutdownScript orig_conv;
46772         orig_conv.inner = untag_ptr(orig);
46773         orig_conv.is_owned = ptr_is_owned(orig);
46774         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46775         orig_conv.is_owned = false;
46776         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
46777         int64_t ret_ref = 0;
46778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46779         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46780         return ret_ref;
46781 }
46782
46783 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46784         LDKShutdownScript a_conv;
46785         a_conv.inner = untag_ptr(a);
46786         a_conv.is_owned = ptr_is_owned(a);
46787         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46788         a_conv.is_owned = false;
46789         LDKShutdownScript b_conv;
46790         b_conv.inner = untag_ptr(b);
46791         b_conv.is_owned = ptr_is_owned(b);
46792         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46793         b_conv.is_owned = false;
46794         jboolean ret_conv = ShutdownScript_eq(&a_conv, &b_conv);
46795         return ret_conv;
46796 }
46797
46798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46799         LDKInvalidShutdownScript this_obj_conv;
46800         this_obj_conv.inner = untag_ptr(this_obj);
46801         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46803         InvalidShutdownScript_free(this_obj_conv);
46804 }
46805
46806 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
46807         LDKInvalidShutdownScript this_ptr_conv;
46808         this_ptr_conv.inner = untag_ptr(this_ptr);
46809         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46811         this_ptr_conv.is_owned = false;
46812         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
46813         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46814         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46815         return ret_arr;
46816 }
46817
46818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46819         LDKInvalidShutdownScript this_ptr_conv;
46820         this_ptr_conv.inner = untag_ptr(this_ptr);
46821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46823         this_ptr_conv.is_owned = false;
46824         LDKCVec_u8Z val_ref;
46825         val_ref.datalen = (*env)->GetArrayLength(env, val);
46826         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
46827         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
46828         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
46829 }
46830
46831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
46832         LDKCVec_u8Z script_arg_ref;
46833         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
46834         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
46835         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
46836         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
46837         int64_t ret_ref = 0;
46838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46839         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46840         return ret_ref;
46841 }
46842
46843 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
46844         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
46845         int64_t ret_ref = 0;
46846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46848         return ret_ref;
46849 }
46850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46851         LDKInvalidShutdownScript arg_conv;
46852         arg_conv.inner = untag_ptr(arg);
46853         arg_conv.is_owned = ptr_is_owned(arg);
46854         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46855         arg_conv.is_owned = false;
46856         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
46857         return ret_conv;
46858 }
46859
46860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46861         LDKInvalidShutdownScript orig_conv;
46862         orig_conv.inner = untag_ptr(orig);
46863         orig_conv.is_owned = ptr_is_owned(orig);
46864         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46865         orig_conv.is_owned = false;
46866         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
46867         int64_t ret_ref = 0;
46868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46869         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46870         return ret_ref;
46871 }
46872
46873 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
46874         LDKShutdownScript obj_conv;
46875         obj_conv.inner = untag_ptr(obj);
46876         obj_conv.is_owned = ptr_is_owned(obj);
46877         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46878         obj_conv.is_owned = false;
46879         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
46880         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46881         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46882         CVec_u8Z_free(ret_var);
46883         return ret_arr;
46884 }
46885
46886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46887         LDKu8slice ser_ref;
46888         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46889         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46890         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
46891         *ret_conv = ShutdownScript_read(ser_ref);
46892         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46893         return tag_ptr(ret_conv, true);
46894 }
46895
46896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
46897         uint8_t pubkey_hash_arr[20];
46898         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
46899         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
46900         uint8_t (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
46901         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
46902         int64_t ret_ref = 0;
46903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46905         return ret_ref;
46906 }
46907
46908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
46909         uint8_t script_hash_arr[32];
46910         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
46911         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
46912         uint8_t (*script_hash_ref)[32] = &script_hash_arr;
46913         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
46914         int64_t ret_ref = 0;
46915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46916         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46917         return ret_ref;
46918 }
46919
46920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
46921         
46922         LDKu8slice program_ref;
46923         program_ref.datalen = (*env)->GetArrayLength(env, program);
46924         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
46925         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
46926         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
46927         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
46928         return tag_ptr(ret_conv, true);
46929 }
46930
46931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
46932         LDKShutdownScript this_arg_conv;
46933         this_arg_conv.inner = untag_ptr(this_arg);
46934         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46936         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
46937         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
46938         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46939         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46940         CVec_u8Z_free(ret_var);
46941         return ret_arr;
46942 }
46943
46944 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
46945         LDKShutdownScript this_arg_conv;
46946         this_arg_conv.inner = untag_ptr(this_arg);
46947         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46949         this_arg_conv.is_owned = false;
46950         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46951         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
46952         return ret_arr;
46953 }
46954
46955 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
46956         LDKShutdownScript this_arg_conv;
46957         this_arg_conv.inner = untag_ptr(this_arg);
46958         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46960         this_arg_conv.is_owned = false;
46961         LDKInitFeatures features_conv;
46962         features_conv.inner = untag_ptr(features);
46963         features_conv.is_owned = ptr_is_owned(features);
46964         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
46965         features_conv.is_owned = false;
46966         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
46967         return ret_conv;
46968 }
46969
46970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46971         if (!ptr_is_owned(this_ptr)) return;
46972         void* this_ptr_ptr = untag_ptr(this_ptr);
46973         CHECK_ACCESS(this_ptr_ptr);
46974         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
46975         FREE(untag_ptr(this_ptr));
46976         Retry_free(this_ptr_conv);
46977 }
46978
46979 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
46980         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46981         *ret_copy = Retry_clone(arg);
46982         int64_t ret_ref = tag_ptr(ret_copy, true);
46983         return ret_ref;
46984 }
46985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46986         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
46987         int64_t ret_conv = Retry_clone_ptr(arg_conv);
46988         return ret_conv;
46989 }
46990
46991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46992         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
46993         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46994         *ret_copy = Retry_clone(orig_conv);
46995         int64_t ret_ref = tag_ptr(ret_copy, true);
46996         return ret_ref;
46997 }
46998
46999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
47000         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
47001         *ret_copy = Retry_attempts(a);
47002         int64_t ret_ref = tag_ptr(ret_copy, true);
47003         return ret_ref;
47004 }
47005
47006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
47007         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
47008         *ret_copy = Retry_timeout(a);
47009         int64_t ret_ref = tag_ptr(ret_copy, true);
47010         return ret_ref;
47011 }
47012
47013 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47014         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
47015         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
47016         jboolean ret_conv = Retry_eq(a_conv, b_conv);
47017         return ret_conv;
47018 }
47019
47020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
47021         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
47022         int64_t ret_conv = Retry_hash(o_conv);
47023         return ret_conv;
47024 }
47025
47026 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47027         LDKRetryableSendFailure* orig_conv = (LDKRetryableSendFailure*)untag_ptr(orig);
47028         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_clone(orig_conv));
47029         return ret_conv;
47030 }
47031
47032 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1payment_1expired(JNIEnv *env, jclass clz) {
47033         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_payment_expired());
47034         return ret_conv;
47035 }
47036
47037 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1route_1not_1found(JNIEnv *env, jclass clz) {
47038         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_route_not_found());
47039         return ret_conv;
47040 }
47041
47042 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1duplicate_1payment(JNIEnv *env, jclass clz) {
47043         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_duplicate_payment());
47044         return ret_conv;
47045 }
47046
47047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47048         if (!ptr_is_owned(this_ptr)) return;
47049         void* this_ptr_ptr = untag_ptr(this_ptr);
47050         CHECK_ACCESS(this_ptr_ptr);
47051         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
47052         FREE(untag_ptr(this_ptr));
47053         PaymentSendFailure_free(this_ptr_conv);
47054 }
47055
47056 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
47057         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47058         *ret_copy = PaymentSendFailure_clone(arg);
47059         int64_t ret_ref = tag_ptr(ret_copy, true);
47060         return ret_ref;
47061 }
47062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47063         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
47064         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
47065         return ret_conv;
47066 }
47067
47068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47069         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
47070         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47071         *ret_copy = PaymentSendFailure_clone(orig_conv);
47072         int64_t ret_ref = tag_ptr(ret_copy, true);
47073         return ret_ref;
47074 }
47075
47076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
47077         void* a_ptr = untag_ptr(a);
47078         CHECK_ACCESS(a_ptr);
47079         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
47080         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
47081         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47082         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
47083         int64_t ret_ref = tag_ptr(ret_copy, true);
47084         return ret_ref;
47085 }
47086
47087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
47088         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
47089         a_constr.datalen = (*env)->GetArrayLength(env, a);
47090         if (a_constr.datalen > 0)
47091                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
47092         else
47093                 a_constr.data = NULL;
47094         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
47095         for (size_t w = 0; w < a_constr.datalen; w++) {
47096                 int64_t a_conv_22 = a_vals[w];
47097                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
47098                 CHECK_ACCESS(a_conv_22_ptr);
47099                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
47100                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
47101                 a_constr.data[w] = a_conv_22_conv;
47102         }
47103         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
47104         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47105         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
47106         int64_t ret_ref = tag_ptr(ret_copy, true);
47107         return ret_ref;
47108 }
47109
47110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1resend_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
47111         LDKCVec_APIErrorZ a_constr;
47112         a_constr.datalen = (*env)->GetArrayLength(env, a);
47113         if (a_constr.datalen > 0)
47114                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
47115         else
47116                 a_constr.data = NULL;
47117         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
47118         for (size_t k = 0; k < a_constr.datalen; k++) {
47119                 int64_t a_conv_10 = a_vals[k];
47120                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
47121                 CHECK_ACCESS(a_conv_10_ptr);
47122                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
47123                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
47124                 a_constr.data[k] = a_conv_10_conv;
47125         }
47126         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
47127         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47128         *ret_copy = PaymentSendFailure_all_failed_resend_safe(a_constr);
47129         int64_t ret_ref = tag_ptr(ret_copy, true);
47130         return ret_ref;
47131 }
47132
47133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1duplicate_1payment(JNIEnv *env, jclass clz) {
47134         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47135         *ret_copy = PaymentSendFailure_duplicate_payment();
47136         int64_t ret_ref = tag_ptr(ret_copy, true);
47137         return ret_ref;
47138 }
47139
47140 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) {
47141         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
47142         results_constr.datalen = (*env)->GetArrayLength(env, results);
47143         if (results_constr.datalen > 0)
47144                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
47145         else
47146                 results_constr.data = NULL;
47147         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
47148         for (size_t w = 0; w < results_constr.datalen; w++) {
47149                 int64_t results_conv_22 = results_vals[w];
47150                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
47151                 CHECK_ACCESS(results_conv_22_ptr);
47152                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
47153                 results_constr.data[w] = results_conv_22_conv;
47154         }
47155         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
47156         LDKRouteParameters failed_paths_retry_conv;
47157         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
47158         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
47159         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
47160         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
47161         LDKThirtyTwoBytes payment_id_ref;
47162         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
47163         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
47164         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47165         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
47166         int64_t ret_ref = tag_ptr(ret_copy, true);
47167         return ret_ref;
47168 }
47169
47170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47171         LDKRecipientOnionFields this_obj_conv;
47172         this_obj_conv.inner = untag_ptr(this_obj);
47173         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47175         RecipientOnionFields_free(this_obj_conv);
47176 }
47177
47178 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1get_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
47179         LDKRecipientOnionFields this_ptr_conv;
47180         this_ptr_conv.inner = untag_ptr(this_ptr);
47181         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47183         this_ptr_conv.is_owned = false;
47184         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47185         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RecipientOnionFields_get_payment_secret(&this_ptr_conv).data);
47186         return ret_arr;
47187 }
47188
47189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1set_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
47190         LDKRecipientOnionFields this_ptr_conv;
47191         this_ptr_conv.inner = untag_ptr(this_ptr);
47192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47194         this_ptr_conv.is_owned = false;
47195         LDKThirtyTwoBytes val_ref;
47196         CHECK((*env)->GetArrayLength(env, val) == 32);
47197         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
47198         RecipientOnionFields_set_payment_secret(&this_ptr_conv, val_ref);
47199 }
47200
47201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1get_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_ptr) {
47202         LDKRecipientOnionFields this_ptr_conv;
47203         this_ptr_conv.inner = untag_ptr(this_ptr);
47204         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47206         this_ptr_conv.is_owned = false;
47207         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
47208         *ret_copy = RecipientOnionFields_get_payment_metadata(&this_ptr_conv);
47209         int64_t ret_ref = tag_ptr(ret_copy, true);
47210         return ret_ref;
47211 }
47212
47213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1set_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47214         LDKRecipientOnionFields this_ptr_conv;
47215         this_ptr_conv.inner = untag_ptr(this_ptr);
47216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47218         this_ptr_conv.is_owned = false;
47219         void* val_ptr = untag_ptr(val);
47220         CHECK_ACCESS(val_ptr);
47221         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
47222         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
47223         RecipientOnionFields_set_payment_metadata(&this_ptr_conv, val_conv);
47224 }
47225
47226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1new(JNIEnv *env, jclass clz, int8_tArray payment_secret_arg, int64_t payment_metadata_arg) {
47227         LDKThirtyTwoBytes payment_secret_arg_ref;
47228         CHECK((*env)->GetArrayLength(env, payment_secret_arg) == 32);
47229         (*env)->GetByteArrayRegion(env, payment_secret_arg, 0, 32, payment_secret_arg_ref.data);
47230         void* payment_metadata_arg_ptr = untag_ptr(payment_metadata_arg);
47231         CHECK_ACCESS(payment_metadata_arg_ptr);
47232         LDKCOption_CVec_u8ZZ payment_metadata_arg_conv = *(LDKCOption_CVec_u8ZZ*)(payment_metadata_arg_ptr);
47233         payment_metadata_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(payment_metadata_arg));
47234         LDKRecipientOnionFields ret_var = RecipientOnionFields_new(payment_secret_arg_ref, payment_metadata_arg_conv);
47235         int64_t ret_ref = 0;
47236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47237         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47238         return ret_ref;
47239 }
47240
47241 static inline uint64_t RecipientOnionFields_clone_ptr(LDKRecipientOnionFields *NONNULL_PTR arg) {
47242         LDKRecipientOnionFields ret_var = RecipientOnionFields_clone(arg);
47243         int64_t ret_ref = 0;
47244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47245         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47246         return ret_ref;
47247 }
47248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47249         LDKRecipientOnionFields arg_conv;
47250         arg_conv.inner = untag_ptr(arg);
47251         arg_conv.is_owned = ptr_is_owned(arg);
47252         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47253         arg_conv.is_owned = false;
47254         int64_t ret_conv = RecipientOnionFields_clone_ptr(&arg_conv);
47255         return ret_conv;
47256 }
47257
47258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47259         LDKRecipientOnionFields orig_conv;
47260         orig_conv.inner = untag_ptr(orig);
47261         orig_conv.is_owned = ptr_is_owned(orig);
47262         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47263         orig_conv.is_owned = false;
47264         LDKRecipientOnionFields ret_var = RecipientOnionFields_clone(&orig_conv);
47265         int64_t ret_ref = 0;
47266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47267         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47268         return ret_ref;
47269 }
47270
47271 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47272         LDKRecipientOnionFields a_conv;
47273         a_conv.inner = untag_ptr(a);
47274         a_conv.is_owned = ptr_is_owned(a);
47275         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47276         a_conv.is_owned = false;
47277         LDKRecipientOnionFields b_conv;
47278         b_conv.inner = untag_ptr(b);
47279         b_conv.is_owned = ptr_is_owned(b);
47280         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47281         b_conv.is_owned = false;
47282         jboolean ret_conv = RecipientOnionFields_eq(&a_conv, &b_conv);
47283         return ret_conv;
47284 }
47285
47286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1write(JNIEnv *env, jclass clz, int64_t obj) {
47287         LDKRecipientOnionFields obj_conv;
47288         obj_conv.inner = untag_ptr(obj);
47289         obj_conv.is_owned = ptr_is_owned(obj);
47290         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47291         obj_conv.is_owned = false;
47292         LDKCVec_u8Z ret_var = RecipientOnionFields_write(&obj_conv);
47293         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47294         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47295         CVec_u8Z_free(ret_var);
47296         return ret_arr;
47297 }
47298
47299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47300         LDKu8slice ser_ref;
47301         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47302         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47303         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
47304         *ret_conv = RecipientOnionFields_read(ser_ref);
47305         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47306         return tag_ptr(ret_conv, true);
47307 }
47308
47309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1secret_1only(JNIEnv *env, jclass clz, int8_tArray payment_secret) {
47310         LDKThirtyTwoBytes payment_secret_ref;
47311         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
47312         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
47313         LDKRecipientOnionFields ret_var = RecipientOnionFields_secret_only(payment_secret_ref);
47314         int64_t ret_ref = 0;
47315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47316         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47317         return ret_ref;
47318 }
47319
47320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1spontaneous_1empty(JNIEnv *env, jclass clz) {
47321         LDKRecipientOnionFields ret_var = RecipientOnionFields_spontaneous_empty();
47322         int64_t ret_ref = 0;
47323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47324         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47325         return ret_ref;
47326 }
47327
47328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47329         if (!ptr_is_owned(this_ptr)) return;
47330         void* this_ptr_ptr = untag_ptr(this_ptr);
47331         CHECK_ACCESS(this_ptr_ptr);
47332         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
47333         FREE(untag_ptr(this_ptr));
47334         CustomMessageReader_free(this_ptr_conv);
47335 }
47336
47337 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
47338         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
47339         *ret_ret = Type_clone(arg);
47340         return tag_ptr(ret_ret, true);
47341 }
47342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47343         void* arg_ptr = untag_ptr(arg);
47344         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
47345         LDKType* arg_conv = (LDKType*)arg_ptr;
47346         int64_t ret_conv = Type_clone_ptr(arg_conv);
47347         return ret_conv;
47348 }
47349
47350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47351         void* orig_ptr = untag_ptr(orig);
47352         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
47353         LDKType* orig_conv = (LDKType*)orig_ptr;
47354         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
47355         *ret_ret = Type_clone(orig_conv);
47356         return tag_ptr(ret_ret, true);
47357 }
47358
47359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47360         if (!ptr_is_owned(this_ptr)) return;
47361         void* this_ptr_ptr = untag_ptr(this_ptr);
47362         CHECK_ACCESS(this_ptr_ptr);
47363         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
47364         FREE(untag_ptr(this_ptr));
47365         Type_free(this_ptr_conv);
47366 }
47367
47368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47369         LDKUnsignedInvoice this_obj_conv;
47370         this_obj_conv.inner = untag_ptr(this_obj);
47371         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47373         UnsignedInvoice_free(this_obj_conv);
47374 }
47375
47376 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedInvoice_1signing_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
47377         LDKUnsignedInvoice this_arg_conv;
47378         this_arg_conv.inner = untag_ptr(this_arg);
47379         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47381         this_arg_conv.is_owned = false;
47382         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47383         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedInvoice_signing_pubkey(&this_arg_conv).compressed_form);
47384         return ret_arr;
47385 }
47386
47387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47388         LDKBlindedPayInfo this_obj_conv;
47389         this_obj_conv.inner = untag_ptr(this_obj);
47390         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47392         BlindedPayInfo_free(this_obj_conv);
47393 }
47394
47395 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47396         LDKBlindedPayInfo this_ptr_conv;
47397         this_ptr_conv.inner = untag_ptr(this_ptr);
47398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47400         this_ptr_conv.is_owned = false;
47401         int32_t ret_conv = BlindedPayInfo_get_fee_base_msat(&this_ptr_conv);
47402         return ret_conv;
47403 }
47404
47405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
47406         LDKBlindedPayInfo this_ptr_conv;
47407         this_ptr_conv.inner = untag_ptr(this_ptr);
47408         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47410         this_ptr_conv.is_owned = false;
47411         BlindedPayInfo_set_fee_base_msat(&this_ptr_conv, val);
47412 }
47413
47414 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
47415         LDKBlindedPayInfo this_ptr_conv;
47416         this_ptr_conv.inner = untag_ptr(this_ptr);
47417         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47419         this_ptr_conv.is_owned = false;
47420         int32_t ret_conv = BlindedPayInfo_get_fee_proportional_millionths(&this_ptr_conv);
47421         return ret_conv;
47422 }
47423
47424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
47425         LDKBlindedPayInfo this_ptr_conv;
47426         this_ptr_conv.inner = untag_ptr(this_ptr);
47427         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47429         this_ptr_conv.is_owned = false;
47430         BlindedPayInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
47431 }
47432
47433 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
47434         LDKBlindedPayInfo this_ptr_conv;
47435         this_ptr_conv.inner = untag_ptr(this_ptr);
47436         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47438         this_ptr_conv.is_owned = false;
47439         int16_t ret_conv = BlindedPayInfo_get_cltv_expiry_delta(&this_ptr_conv);
47440         return ret_conv;
47441 }
47442
47443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
47444         LDKBlindedPayInfo this_ptr_conv;
47445         this_ptr_conv.inner = untag_ptr(this_ptr);
47446         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47448         this_ptr_conv.is_owned = false;
47449         BlindedPayInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
47450 }
47451
47452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47453         LDKBlindedPayInfo this_ptr_conv;
47454         this_ptr_conv.inner = untag_ptr(this_ptr);
47455         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47457         this_ptr_conv.is_owned = false;
47458         int64_t ret_conv = BlindedPayInfo_get_htlc_minimum_msat(&this_ptr_conv);
47459         return ret_conv;
47460 }
47461
47462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47463         LDKBlindedPayInfo this_ptr_conv;
47464         this_ptr_conv.inner = untag_ptr(this_ptr);
47465         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47467         this_ptr_conv.is_owned = false;
47468         BlindedPayInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
47469 }
47470
47471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47472         LDKBlindedPayInfo this_ptr_conv;
47473         this_ptr_conv.inner = untag_ptr(this_ptr);
47474         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47476         this_ptr_conv.is_owned = false;
47477         int64_t ret_conv = BlindedPayInfo_get_htlc_maximum_msat(&this_ptr_conv);
47478         return ret_conv;
47479 }
47480
47481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47482         LDKBlindedPayInfo this_ptr_conv;
47483         this_ptr_conv.inner = untag_ptr(this_ptr);
47484         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47486         this_ptr_conv.is_owned = false;
47487         BlindedPayInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
47488 }
47489
47490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
47491         LDKBlindedPayInfo this_ptr_conv;
47492         this_ptr_conv.inner = untag_ptr(this_ptr);
47493         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47495         this_ptr_conv.is_owned = false;
47496         LDKBlindedHopFeatures ret_var = BlindedPayInfo_get_features(&this_ptr_conv);
47497         int64_t ret_ref = 0;
47498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47499         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47500         return ret_ref;
47501 }
47502
47503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47504         LDKBlindedPayInfo this_ptr_conv;
47505         this_ptr_conv.inner = untag_ptr(this_ptr);
47506         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47508         this_ptr_conv.is_owned = false;
47509         LDKBlindedHopFeatures val_conv;
47510         val_conv.inner = untag_ptr(val);
47511         val_conv.is_owned = ptr_is_owned(val);
47512         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47513         val_conv = BlindedHopFeatures_clone(&val_conv);
47514         BlindedPayInfo_set_features(&this_ptr_conv, val_conv);
47515 }
47516
47517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1new(JNIEnv *env, jclass clz, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int64_t features_arg) {
47518         LDKBlindedHopFeatures features_arg_conv;
47519         features_arg_conv.inner = untag_ptr(features_arg);
47520         features_arg_conv.is_owned = ptr_is_owned(features_arg);
47521         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
47522         features_arg_conv = BlindedHopFeatures_clone(&features_arg_conv);
47523         LDKBlindedPayInfo ret_var = BlindedPayInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, features_arg_conv);
47524         int64_t ret_ref = 0;
47525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47526         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47527         return ret_ref;
47528 }
47529
47530 static inline uint64_t BlindedPayInfo_clone_ptr(LDKBlindedPayInfo *NONNULL_PTR arg) {
47531         LDKBlindedPayInfo ret_var = BlindedPayInfo_clone(arg);
47532         int64_t ret_ref = 0;
47533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47534         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47535         return ret_ref;
47536 }
47537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47538         LDKBlindedPayInfo arg_conv;
47539         arg_conv.inner = untag_ptr(arg);
47540         arg_conv.is_owned = ptr_is_owned(arg);
47541         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47542         arg_conv.is_owned = false;
47543         int64_t ret_conv = BlindedPayInfo_clone_ptr(&arg_conv);
47544         return ret_conv;
47545 }
47546
47547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47548         LDKBlindedPayInfo orig_conv;
47549         orig_conv.inner = untag_ptr(orig);
47550         orig_conv.is_owned = ptr_is_owned(orig);
47551         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47552         orig_conv.is_owned = false;
47553         LDKBlindedPayInfo ret_var = BlindedPayInfo_clone(&orig_conv);
47554         int64_t ret_ref = 0;
47555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47556         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47557         return ret_ref;
47558 }
47559
47560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1hash(JNIEnv *env, jclass clz, int64_t o) {
47561         LDKBlindedPayInfo o_conv;
47562         o_conv.inner = untag_ptr(o);
47563         o_conv.is_owned = ptr_is_owned(o);
47564         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47565         o_conv.is_owned = false;
47566         int64_t ret_conv = BlindedPayInfo_hash(&o_conv);
47567         return ret_conv;
47568 }
47569
47570 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47571         LDKBlindedPayInfo a_conv;
47572         a_conv.inner = untag_ptr(a);
47573         a_conv.is_owned = ptr_is_owned(a);
47574         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47575         a_conv.is_owned = false;
47576         LDKBlindedPayInfo b_conv;
47577         b_conv.inner = untag_ptr(b);
47578         b_conv.is_owned = ptr_is_owned(b);
47579         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47580         b_conv.is_owned = false;
47581         jboolean ret_conv = BlindedPayInfo_eq(&a_conv, &b_conv);
47582         return ret_conv;
47583 }
47584
47585 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
47586         LDKBlindedPayInfo obj_conv;
47587         obj_conv.inner = untag_ptr(obj);
47588         obj_conv.is_owned = ptr_is_owned(obj);
47589         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47590         obj_conv.is_owned = false;
47591         LDKCVec_u8Z ret_var = BlindedPayInfo_write(&obj_conv);
47592         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47593         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47594         CVec_u8Z_free(ret_var);
47595         return ret_arr;
47596 }
47597
47598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47599         LDKu8slice ser_ref;
47600         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47601         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47602         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
47603         *ret_conv = BlindedPayInfo_read(ser_ref);
47604         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47605         return tag_ptr(ret_conv, true);
47606 }
47607
47608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedInvoiceRequest_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47609         LDKUnsignedInvoiceRequest this_obj_conv;
47610         this_obj_conv.inner = untag_ptr(this_obj);
47611         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47613         UnsignedInvoiceRequest_free(this_obj_conv);
47614 }
47615
47616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47617         LDKInvoiceRequest this_obj_conv;
47618         this_obj_conv.inner = untag_ptr(this_obj);
47619         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47621         InvoiceRequest_free(this_obj_conv);
47622 }
47623
47624 static inline uint64_t InvoiceRequest_clone_ptr(LDKInvoiceRequest *NONNULL_PTR arg) {
47625         LDKInvoiceRequest ret_var = InvoiceRequest_clone(arg);
47626         int64_t ret_ref = 0;
47627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47628         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47629         return ret_ref;
47630 }
47631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47632         LDKInvoiceRequest arg_conv;
47633         arg_conv.inner = untag_ptr(arg);
47634         arg_conv.is_owned = ptr_is_owned(arg);
47635         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47636         arg_conv.is_owned = false;
47637         int64_t ret_conv = InvoiceRequest_clone_ptr(&arg_conv);
47638         return ret_conv;
47639 }
47640
47641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47642         LDKInvoiceRequest orig_conv;
47643         orig_conv.inner = untag_ptr(orig);
47644         orig_conv.is_owned = ptr_is_owned(orig);
47645         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47646         orig_conv.is_owned = false;
47647         LDKInvoiceRequest ret_var = InvoiceRequest_clone(&orig_conv);
47648         int64_t ret_ref = 0;
47649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47650         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47651         return ret_ref;
47652 }
47653
47654 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
47655         LDKInvoiceRequest this_arg_conv;
47656         this_arg_conv.inner = untag_ptr(this_arg);
47657         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47659         this_arg_conv.is_owned = false;
47660         LDKu8slice ret_var = InvoiceRequest_metadata(&this_arg_conv);
47661         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47662         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47663         return ret_arr;
47664 }
47665
47666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1chain(JNIEnv *env, jclass clz, int64_t this_arg) {
47667         LDKInvoiceRequest this_arg_conv;
47668         this_arg_conv.inner = untag_ptr(this_arg);
47669         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47671         this_arg_conv.is_owned = false;
47672         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47673         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, InvoiceRequest_chain(&this_arg_conv).data);
47674         return ret_arr;
47675 }
47676
47677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1amount_1msats(JNIEnv *env, jclass clz, int64_t this_arg) {
47678         LDKInvoiceRequest this_arg_conv;
47679         this_arg_conv.inner = untag_ptr(this_arg);
47680         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47682         this_arg_conv.is_owned = false;
47683         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47684         *ret_copy = InvoiceRequest_amount_msats(&this_arg_conv);
47685         int64_t ret_ref = tag_ptr(ret_copy, true);
47686         return ret_ref;
47687 }
47688
47689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47690         LDKInvoiceRequest this_arg_conv;
47691         this_arg_conv.inner = untag_ptr(this_arg);
47692         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47694         this_arg_conv.is_owned = false;
47695         LDKInvoiceRequestFeatures ret_var = InvoiceRequest_features(&this_arg_conv);
47696         int64_t ret_ref = 0;
47697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47698         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47699         return ret_ref;
47700 }
47701
47702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
47703         LDKInvoiceRequest this_arg_conv;
47704         this_arg_conv.inner = untag_ptr(this_arg);
47705         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47707         this_arg_conv.is_owned = false;
47708         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47709         *ret_copy = InvoiceRequest_quantity(&this_arg_conv);
47710         int64_t ret_ref = tag_ptr(ret_copy, true);
47711         return ret_ref;
47712 }
47713
47714 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1payer_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
47715         LDKInvoiceRequest this_arg_conv;
47716         this_arg_conv.inner = untag_ptr(this_arg);
47717         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47719         this_arg_conv.is_owned = false;
47720         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47721         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, InvoiceRequest_payer_id(&this_arg_conv).compressed_form);
47722         return ret_arr;
47723 }
47724
47725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1payer_1note(JNIEnv *env, jclass clz, int64_t this_arg) {
47726         LDKInvoiceRequest this_arg_conv;
47727         this_arg_conv.inner = untag_ptr(this_arg);
47728         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47730         this_arg_conv.is_owned = false;
47731         LDKPrintableString ret_var = InvoiceRequest_payer_note(&this_arg_conv);
47732         int64_t ret_ref = 0;
47733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47735         return ret_ref;
47736 }
47737
47738 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1write(JNIEnv *env, jclass clz, int64_t obj) {
47739         LDKInvoiceRequest obj_conv;
47740         obj_conv.inner = untag_ptr(obj);
47741         obj_conv.is_owned = ptr_is_owned(obj);
47742         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47743         obj_conv.is_owned = false;
47744         LDKCVec_u8Z ret_var = InvoiceRequest_write(&obj_conv);
47745         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47746         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47747         CVec_u8Z_free(ret_var);
47748         return ret_arr;
47749 }
47750
47751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Offer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47752         LDKOffer this_obj_conv;
47753         this_obj_conv.inner = untag_ptr(this_obj);
47754         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47756         Offer_free(this_obj_conv);
47757 }
47758
47759 static inline uint64_t Offer_clone_ptr(LDKOffer *NONNULL_PTR arg) {
47760         LDKOffer ret_var = Offer_clone(arg);
47761         int64_t ret_ref = 0;
47762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47763         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47764         return ret_ref;
47765 }
47766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47767         LDKOffer arg_conv;
47768         arg_conv.inner = untag_ptr(arg);
47769         arg_conv.is_owned = ptr_is_owned(arg);
47770         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47771         arg_conv.is_owned = false;
47772         int64_t ret_conv = Offer_clone_ptr(&arg_conv);
47773         return ret_conv;
47774 }
47775
47776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47777         LDKOffer orig_conv;
47778         orig_conv.inner = untag_ptr(orig);
47779         orig_conv.is_owned = ptr_is_owned(orig);
47780         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47781         orig_conv.is_owned = false;
47782         LDKOffer ret_var = Offer_clone(&orig_conv);
47783         int64_t ret_ref = 0;
47784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47785         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47786         return ret_ref;
47787 }
47788
47789 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Offer_1chains(JNIEnv *env, jclass clz, int64_t this_arg) {
47790         LDKOffer this_arg_conv;
47791         this_arg_conv.inner = untag_ptr(this_arg);
47792         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47794         this_arg_conv.is_owned = false;
47795         LDKCVec_ChainHashZ ret_var = Offer_chains(&this_arg_conv);
47796         jobjectArray ret_arr = NULL;
47797         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
47798         ;
47799         for (size_t i = 0; i < ret_var.datalen; i++) {
47800                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
47801                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
47802                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
47803         }
47804         
47805         FREE(ret_var.data);
47806         return ret_arr;
47807 }
47808
47809 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1supports_1chain(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray chain) {
47810         LDKOffer this_arg_conv;
47811         this_arg_conv.inner = untag_ptr(this_arg);
47812         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47814         this_arg_conv.is_owned = false;
47815         LDKThirtyTwoBytes chain_ref;
47816         CHECK((*env)->GetArrayLength(env, chain) == 32);
47817         (*env)->GetByteArrayRegion(env, chain, 0, 32, chain_ref.data);
47818         jboolean ret_conv = Offer_supports_chain(&this_arg_conv, chain_ref);
47819         return ret_conv;
47820 }
47821
47822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
47823         LDKOffer this_arg_conv;
47824         this_arg_conv.inner = untag_ptr(this_arg);
47825         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47827         this_arg_conv.is_owned = false;
47828         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
47829         *ret_copy = Offer_metadata(&this_arg_conv);
47830         int64_t ret_ref = tag_ptr(ret_copy, true);
47831         return ret_ref;
47832 }
47833
47834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
47835         LDKOffer this_arg_conv;
47836         this_arg_conv.inner = untag_ptr(this_arg);
47837         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47839         this_arg_conv.is_owned = false;
47840         LDKAmount ret_var = Offer_amount(&this_arg_conv);
47841         int64_t ret_ref = 0;
47842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47843         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47844         return ret_ref;
47845 }
47846
47847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
47848         LDKOffer this_arg_conv;
47849         this_arg_conv.inner = untag_ptr(this_arg);
47850         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47852         this_arg_conv.is_owned = false;
47853         LDKPrintableString ret_var = Offer_description(&this_arg_conv);
47854         int64_t ret_ref = 0;
47855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47856         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47857         return ret_ref;
47858 }
47859
47860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47861         LDKOffer this_arg_conv;
47862         this_arg_conv.inner = untag_ptr(this_arg);
47863         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47865         this_arg_conv.is_owned = false;
47866         LDKOfferFeatures ret_var = Offer_features(&this_arg_conv);
47867         int64_t ret_ref = 0;
47868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47869         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47870         return ret_ref;
47871 }
47872
47873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1absolute_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
47874         LDKOffer this_arg_conv;
47875         this_arg_conv.inner = untag_ptr(this_arg);
47876         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47878         this_arg_conv.is_owned = false;
47879         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
47880         *ret_copy = Offer_absolute_expiry(&this_arg_conv);
47881         int64_t ret_ref = tag_ptr(ret_copy, true);
47882         return ret_ref;
47883 }
47884
47885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
47886         LDKOffer this_arg_conv;
47887         this_arg_conv.inner = untag_ptr(this_arg);
47888         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47890         this_arg_conv.is_owned = false;
47891         jboolean ret_conv = Offer_is_expired(&this_arg_conv);
47892         return ret_conv;
47893 }
47894
47895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1issuer(JNIEnv *env, jclass clz, int64_t this_arg) {
47896         LDKOffer this_arg_conv;
47897         this_arg_conv.inner = untag_ptr(this_arg);
47898         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47900         this_arg_conv.is_owned = false;
47901         LDKPrintableString ret_var = Offer_issuer(&this_arg_conv);
47902         int64_t ret_ref = 0;
47903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47905         return ret_ref;
47906 }
47907
47908 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Offer_1paths(JNIEnv *env, jclass clz, int64_t this_arg) {
47909         LDKOffer this_arg_conv;
47910         this_arg_conv.inner = untag_ptr(this_arg);
47911         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47913         this_arg_conv.is_owned = false;
47914         LDKCVec_BlindedPathZ ret_var = Offer_paths(&this_arg_conv);
47915         int64_tArray ret_arr = NULL;
47916         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47917         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47918         for (size_t n = 0; n < ret_var.datalen; n++) {
47919                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
47920                 int64_t ret_conv_13_ref = 0;
47921                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
47922                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
47923                 ret_arr_ptr[n] = ret_conv_13_ref;
47924         }
47925         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47926         FREE(ret_var.data);
47927         return ret_arr;
47928 }
47929
47930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1supported_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
47931         LDKOffer this_arg_conv;
47932         this_arg_conv.inner = untag_ptr(this_arg);
47933         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47935         this_arg_conv.is_owned = false;
47936         LDKQuantity ret_var = Offer_supported_quantity(&this_arg_conv);
47937         int64_t ret_ref = 0;
47938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47939         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47940         return ret_ref;
47941 }
47942
47943 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1is_1valid_1quantity(JNIEnv *env, jclass clz, int64_t this_arg, int64_t quantity) {
47944         LDKOffer this_arg_conv;
47945         this_arg_conv.inner = untag_ptr(this_arg);
47946         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47948         this_arg_conv.is_owned = false;
47949         jboolean ret_conv = Offer_is_valid_quantity(&this_arg_conv, quantity);
47950         return ret_conv;
47951 }
47952
47953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1expects_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
47954         LDKOffer this_arg_conv;
47955         this_arg_conv.inner = untag_ptr(this_arg);
47956         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47958         this_arg_conv.is_owned = false;
47959         jboolean ret_conv = Offer_expects_quantity(&this_arg_conv);
47960         return ret_conv;
47961 }
47962
47963 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Offer_1signing_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
47964         LDKOffer this_arg_conv;
47965         this_arg_conv.inner = untag_ptr(this_arg);
47966         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47968         this_arg_conv.is_owned = false;
47969         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47970         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Offer_signing_pubkey(&this_arg_conv).compressed_form);
47971         return ret_arr;
47972 }
47973
47974 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Offer_1write(JNIEnv *env, jclass clz, int64_t obj) {
47975         LDKOffer obj_conv;
47976         obj_conv.inner = untag_ptr(obj);
47977         obj_conv.is_owned = ptr_is_owned(obj);
47978         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47979         obj_conv.is_owned = false;
47980         LDKCVec_u8Z ret_var = Offer_write(&obj_conv);
47981         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47982         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47983         CVec_u8Z_free(ret_var);
47984         return ret_arr;
47985 }
47986
47987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Amount_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47988         LDKAmount this_obj_conv;
47989         this_obj_conv.inner = untag_ptr(this_obj);
47990         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47992         Amount_free(this_obj_conv);
47993 }
47994
47995 static inline uint64_t Amount_clone_ptr(LDKAmount *NONNULL_PTR arg) {
47996         LDKAmount ret_var = Amount_clone(arg);
47997         int64_t ret_ref = 0;
47998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47999         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48000         return ret_ref;
48001 }
48002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Amount_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48003         LDKAmount arg_conv;
48004         arg_conv.inner = untag_ptr(arg);
48005         arg_conv.is_owned = ptr_is_owned(arg);
48006         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48007         arg_conv.is_owned = false;
48008         int64_t ret_conv = Amount_clone_ptr(&arg_conv);
48009         return ret_conv;
48010 }
48011
48012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Amount_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48013         LDKAmount orig_conv;
48014         orig_conv.inner = untag_ptr(orig);
48015         orig_conv.is_owned = ptr_is_owned(orig);
48016         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48017         orig_conv.is_owned = false;
48018         LDKAmount ret_var = Amount_clone(&orig_conv);
48019         int64_t ret_ref = 0;
48020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48021         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48022         return ret_ref;
48023 }
48024
48025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Quantity_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48026         LDKQuantity this_obj_conv;
48027         this_obj_conv.inner = untag_ptr(this_obj);
48028         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48030         Quantity_free(this_obj_conv);
48031 }
48032
48033 static inline uint64_t Quantity_clone_ptr(LDKQuantity *NONNULL_PTR arg) {
48034         LDKQuantity ret_var = Quantity_clone(arg);
48035         int64_t ret_ref = 0;
48036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48037         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48038         return ret_ref;
48039 }
48040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Quantity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48041         LDKQuantity arg_conv;
48042         arg_conv.inner = untag_ptr(arg);
48043         arg_conv.is_owned = ptr_is_owned(arg);
48044         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48045         arg_conv.is_owned = false;
48046         int64_t ret_conv = Quantity_clone_ptr(&arg_conv);
48047         return ret_conv;
48048 }
48049
48050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Quantity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48051         LDKQuantity orig_conv;
48052         orig_conv.inner = untag_ptr(orig);
48053         orig_conv.is_owned = ptr_is_owned(orig);
48054         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48055         orig_conv.is_owned = false;
48056         LDKQuantity ret_var = Quantity_clone(&orig_conv);
48057         int64_t ret_ref = 0;
48058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48059         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48060         return ret_ref;
48061 }
48062
48063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Refund_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48064         LDKRefund this_obj_conv;
48065         this_obj_conv.inner = untag_ptr(this_obj);
48066         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48068         Refund_free(this_obj_conv);
48069 }
48070
48071 static inline uint64_t Refund_clone_ptr(LDKRefund *NONNULL_PTR arg) {
48072         LDKRefund ret_var = Refund_clone(arg);
48073         int64_t ret_ref = 0;
48074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48075         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48076         return ret_ref;
48077 }
48078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48079         LDKRefund arg_conv;
48080         arg_conv.inner = untag_ptr(arg);
48081         arg_conv.is_owned = ptr_is_owned(arg);
48082         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48083         arg_conv.is_owned = false;
48084         int64_t ret_conv = Refund_clone_ptr(&arg_conv);
48085         return ret_conv;
48086 }
48087
48088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48089         LDKRefund orig_conv;
48090         orig_conv.inner = untag_ptr(orig);
48091         orig_conv.is_owned = ptr_is_owned(orig);
48092         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48093         orig_conv.is_owned = false;
48094         LDKRefund ret_var = Refund_clone(&orig_conv);
48095         int64_t ret_ref = 0;
48096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48097         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48098         return ret_ref;
48099 }
48100
48101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
48102         LDKRefund this_arg_conv;
48103         this_arg_conv.inner = untag_ptr(this_arg);
48104         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48106         this_arg_conv.is_owned = false;
48107         LDKPrintableString ret_var = Refund_description(&this_arg_conv);
48108         int64_t ret_ref = 0;
48109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48110         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48111         return ret_ref;
48112 }
48113
48114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1absolute_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
48115         LDKRefund this_arg_conv;
48116         this_arg_conv.inner = untag_ptr(this_arg);
48117         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48119         this_arg_conv.is_owned = false;
48120         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
48121         *ret_copy = Refund_absolute_expiry(&this_arg_conv);
48122         int64_t ret_ref = tag_ptr(ret_copy, true);
48123         return ret_ref;
48124 }
48125
48126 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Refund_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
48127         LDKRefund this_arg_conv;
48128         this_arg_conv.inner = untag_ptr(this_arg);
48129         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48131         this_arg_conv.is_owned = false;
48132         jboolean ret_conv = Refund_is_expired(&this_arg_conv);
48133         return ret_conv;
48134 }
48135
48136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1issuer(JNIEnv *env, jclass clz, int64_t this_arg) {
48137         LDKRefund this_arg_conv;
48138         this_arg_conv.inner = untag_ptr(this_arg);
48139         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48141         this_arg_conv.is_owned = false;
48142         LDKPrintableString ret_var = Refund_issuer(&this_arg_conv);
48143         int64_t ret_ref = 0;
48144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48145         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48146         return ret_ref;
48147 }
48148
48149 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1paths(JNIEnv *env, jclass clz, int64_t this_arg) {
48150         LDKRefund this_arg_conv;
48151         this_arg_conv.inner = untag_ptr(this_arg);
48152         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48154         this_arg_conv.is_owned = false;
48155         LDKCVec_BlindedPathZ ret_var = Refund_paths(&this_arg_conv);
48156         int64_tArray ret_arr = NULL;
48157         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48158         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48159         for (size_t n = 0; n < ret_var.datalen; n++) {
48160                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
48161                 int64_t ret_conv_13_ref = 0;
48162                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
48163                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
48164                 ret_arr_ptr[n] = ret_conv_13_ref;
48165         }
48166         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48167         FREE(ret_var.data);
48168         return ret_arr;
48169 }
48170
48171 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
48172         LDKRefund this_arg_conv;
48173         this_arg_conv.inner = untag_ptr(this_arg);
48174         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48176         this_arg_conv.is_owned = false;
48177         LDKu8slice ret_var = Refund_metadata(&this_arg_conv);
48178         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48179         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48180         return ret_arr;
48181 }
48182
48183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1chain(JNIEnv *env, jclass clz, int64_t this_arg) {
48184         LDKRefund this_arg_conv;
48185         this_arg_conv.inner = untag_ptr(this_arg);
48186         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48188         this_arg_conv.is_owned = false;
48189         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48190         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Refund_chain(&this_arg_conv).data);
48191         return ret_arr;
48192 }
48193
48194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1amount_1msats(JNIEnv *env, jclass clz, int64_t this_arg) {
48195         LDKRefund this_arg_conv;
48196         this_arg_conv.inner = untag_ptr(this_arg);
48197         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48199         this_arg_conv.is_owned = false;
48200         int64_t ret_conv = Refund_amount_msats(&this_arg_conv);
48201         return ret_conv;
48202 }
48203
48204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
48205         LDKRefund this_arg_conv;
48206         this_arg_conv.inner = untag_ptr(this_arg);
48207         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48209         this_arg_conv.is_owned = false;
48210         LDKInvoiceRequestFeatures ret_var = Refund_features(&this_arg_conv);
48211         int64_t ret_ref = 0;
48212         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48213         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48214         return ret_ref;
48215 }
48216
48217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
48218         LDKRefund this_arg_conv;
48219         this_arg_conv.inner = untag_ptr(this_arg);
48220         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48222         this_arg_conv.is_owned = false;
48223         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48224         *ret_copy = Refund_quantity(&this_arg_conv);
48225         int64_t ret_ref = tag_ptr(ret_copy, true);
48226         return ret_ref;
48227 }
48228
48229 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1payer_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
48230         LDKRefund this_arg_conv;
48231         this_arg_conv.inner = untag_ptr(this_arg);
48232         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48234         this_arg_conv.is_owned = false;
48235         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48236         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Refund_payer_id(&this_arg_conv).compressed_form);
48237         return ret_arr;
48238 }
48239
48240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1payer_1note(JNIEnv *env, jclass clz, int64_t this_arg) {
48241         LDKRefund this_arg_conv;
48242         this_arg_conv.inner = untag_ptr(this_arg);
48243         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48245         this_arg_conv.is_owned = false;
48246         LDKPrintableString ret_var = Refund_payer_note(&this_arg_conv);
48247         int64_t ret_ref = 0;
48248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48249         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48250         return ret_ref;
48251 }
48252
48253 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1write(JNIEnv *env, jclass clz, int64_t obj) {
48254         LDKRefund obj_conv;
48255         obj_conv.inner = untag_ptr(obj);
48256         obj_conv.is_owned = ptr_is_owned(obj);
48257         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48258         obj_conv.is_owned = false;
48259         LDKCVec_u8Z ret_var = Refund_write(&obj_conv);
48260         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48261         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48262         CVec_u8Z_free(ret_var);
48263         return ret_arr;
48264 }
48265
48266 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48267         LDKUtxoLookupError* orig_conv = (LDKUtxoLookupError*)untag_ptr(orig);
48268         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_clone(orig_conv));
48269         return ret_conv;
48270 }
48271
48272 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1unknown_1chain(JNIEnv *env, jclass clz) {
48273         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_unknown_chain());
48274         return ret_conv;
48275 }
48276
48277 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1unknown_1tx(JNIEnv *env, jclass clz) {
48278         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_unknown_tx());
48279         return ret_conv;
48280 }
48281
48282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoResult_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48283         if (!ptr_is_owned(this_ptr)) return;
48284         void* this_ptr_ptr = untag_ptr(this_ptr);
48285         CHECK_ACCESS(this_ptr_ptr);
48286         LDKUtxoResult this_ptr_conv = *(LDKUtxoResult*)(this_ptr_ptr);
48287         FREE(untag_ptr(this_ptr));
48288         UtxoResult_free(this_ptr_conv);
48289 }
48290
48291 static inline uint64_t UtxoResult_clone_ptr(LDKUtxoResult *NONNULL_PTR arg) {
48292         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48293         *ret_copy = UtxoResult_clone(arg);
48294         int64_t ret_ref = tag_ptr(ret_copy, true);
48295         return ret_ref;
48296 }
48297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48298         LDKUtxoResult* arg_conv = (LDKUtxoResult*)untag_ptr(arg);
48299         int64_t ret_conv = UtxoResult_clone_ptr(arg_conv);
48300         return ret_conv;
48301 }
48302
48303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48304         LDKUtxoResult* orig_conv = (LDKUtxoResult*)untag_ptr(orig);
48305         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48306         *ret_copy = UtxoResult_clone(orig_conv);
48307         int64_t ret_ref = tag_ptr(ret_copy, true);
48308         return ret_ref;
48309 }
48310
48311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1sync(JNIEnv *env, jclass clz, int64_t a) {
48312         void* a_ptr = untag_ptr(a);
48313         CHECK_ACCESS(a_ptr);
48314         LDKCResult_TxOutUtxoLookupErrorZ a_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(a_ptr);
48315         a_conv = CResult_TxOutUtxoLookupErrorZ_clone((LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(a));
48316         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48317         *ret_copy = UtxoResult_sync(a_conv);
48318         int64_t ret_ref = tag_ptr(ret_copy, true);
48319         return ret_ref;
48320 }
48321
48322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1async(JNIEnv *env, jclass clz, int64_t a) {
48323         LDKUtxoFuture a_conv;
48324         a_conv.inner = untag_ptr(a);
48325         a_conv.is_owned = ptr_is_owned(a);
48326         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48327         a_conv = UtxoFuture_clone(&a_conv);
48328         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48329         *ret_copy = UtxoResult_async(a_conv);
48330         int64_t ret_ref = tag_ptr(ret_copy, true);
48331         return ret_ref;
48332 }
48333
48334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoLookup_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48335         if (!ptr_is_owned(this_ptr)) return;
48336         void* this_ptr_ptr = untag_ptr(this_ptr);
48337         CHECK_ACCESS(this_ptr_ptr);
48338         LDKUtxoLookup this_ptr_conv = *(LDKUtxoLookup*)(this_ptr_ptr);
48339         FREE(untag_ptr(this_ptr));
48340         UtxoLookup_free(this_ptr_conv);
48341 }
48342
48343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48344         LDKUtxoFuture this_obj_conv;
48345         this_obj_conv.inner = untag_ptr(this_obj);
48346         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48348         UtxoFuture_free(this_obj_conv);
48349 }
48350
48351 static inline uint64_t UtxoFuture_clone_ptr(LDKUtxoFuture *NONNULL_PTR arg) {
48352         LDKUtxoFuture ret_var = UtxoFuture_clone(arg);
48353         int64_t ret_ref = 0;
48354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48355         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48356         return ret_ref;
48357 }
48358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48359         LDKUtxoFuture arg_conv;
48360         arg_conv.inner = untag_ptr(arg);
48361         arg_conv.is_owned = ptr_is_owned(arg);
48362         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48363         arg_conv.is_owned = false;
48364         int64_t ret_conv = UtxoFuture_clone_ptr(&arg_conv);
48365         return ret_conv;
48366 }
48367
48368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48369         LDKUtxoFuture orig_conv;
48370         orig_conv.inner = untag_ptr(orig);
48371         orig_conv.is_owned = ptr_is_owned(orig);
48372         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48373         orig_conv.is_owned = false;
48374         LDKUtxoFuture ret_var = UtxoFuture_clone(&orig_conv);
48375         int64_t ret_ref = 0;
48376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48377         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48378         return ret_ref;
48379 }
48380
48381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1new(JNIEnv *env, jclass clz) {
48382         LDKUtxoFuture ret_var = UtxoFuture_new();
48383         int64_t ret_ref = 0;
48384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48385         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48386         return ret_ref;
48387 }
48388
48389 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) {
48390         LDKUtxoFuture this_arg_conv;
48391         this_arg_conv.inner = untag_ptr(this_arg);
48392         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48394         this_arg_conv.is_owned = false;
48395         LDKNetworkGraph graph_conv;
48396         graph_conv.inner = untag_ptr(graph);
48397         graph_conv.is_owned = ptr_is_owned(graph);
48398         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
48399         graph_conv.is_owned = false;
48400         void* result_ptr = untag_ptr(result);
48401         CHECK_ACCESS(result_ptr);
48402         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
48403         UtxoFuture_resolve_without_forwarding(&this_arg_conv, &graph_conv, result_conv);
48404 }
48405
48406 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) {
48407         LDKUtxoFuture this_arg_conv;
48408         this_arg_conv.inner = untag_ptr(this_arg);
48409         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48411         this_arg_conv.is_owned = false;
48412         LDKNetworkGraph graph_conv;
48413         graph_conv.inner = untag_ptr(graph);
48414         graph_conv.is_owned = ptr_is_owned(graph);
48415         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
48416         graph_conv.is_owned = false;
48417         LDKP2PGossipSync gossip_conv;
48418         gossip_conv.inner = untag_ptr(gossip);
48419         gossip_conv.is_owned = ptr_is_owned(gossip);
48420         CHECK_INNER_FIELD_ACCESS_OR_NULL(gossip_conv);
48421         gossip_conv.is_owned = false;
48422         void* result_ptr = untag_ptr(result);
48423         CHECK_ACCESS(result_ptr);
48424         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
48425         UtxoFuture_resolve(&this_arg_conv, &graph_conv, &gossip_conv, result_conv);
48426 }
48427
48428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48429         LDKNodeId this_obj_conv;
48430         this_obj_conv.inner = untag_ptr(this_obj);
48431         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48433         NodeId_free(this_obj_conv);
48434 }
48435
48436 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
48437         LDKNodeId ret_var = NodeId_clone(arg);
48438         int64_t ret_ref = 0;
48439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48440         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48441         return ret_ref;
48442 }
48443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48444         LDKNodeId arg_conv;
48445         arg_conv.inner = untag_ptr(arg);
48446         arg_conv.is_owned = ptr_is_owned(arg);
48447         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48448         arg_conv.is_owned = false;
48449         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
48450         return ret_conv;
48451 }
48452
48453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48454         LDKNodeId orig_conv;
48455         orig_conv.inner = untag_ptr(orig);
48456         orig_conv.is_owned = ptr_is_owned(orig);
48457         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48458         orig_conv.is_owned = false;
48459         LDKNodeId ret_var = NodeId_clone(&orig_conv);
48460         int64_t ret_ref = 0;
48461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48462         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48463         return ret_ref;
48464 }
48465
48466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
48467         LDKPublicKey pubkey_ref;
48468         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
48469         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
48470         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
48471         int64_t ret_ref = 0;
48472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48473         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48474         return ret_ref;
48475 }
48476
48477 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
48478         LDKNodeId this_arg_conv;
48479         this_arg_conv.inner = untag_ptr(this_arg);
48480         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48482         this_arg_conv.is_owned = false;
48483         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
48484         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48485         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48486         return ret_arr;
48487 }
48488
48489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
48490         LDKNodeId this_arg_conv;
48491         this_arg_conv.inner = untag_ptr(this_arg);
48492         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48494         this_arg_conv.is_owned = false;
48495         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
48496         *ret_conv = NodeId_as_pubkey(&this_arg_conv);
48497         return tag_ptr(ret_conv, true);
48498 }
48499
48500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
48501         LDKNodeId o_conv;
48502         o_conv.inner = untag_ptr(o);
48503         o_conv.is_owned = ptr_is_owned(o);
48504         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48505         o_conv.is_owned = false;
48506         int64_t ret_conv = NodeId_hash(&o_conv);
48507         return ret_conv;
48508 }
48509
48510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
48511         LDKNodeId obj_conv;
48512         obj_conv.inner = untag_ptr(obj);
48513         obj_conv.is_owned = ptr_is_owned(obj);
48514         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48515         obj_conv.is_owned = false;
48516         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
48517         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48518         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48519         CVec_u8Z_free(ret_var);
48520         return ret_arr;
48521 }
48522
48523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48524         LDKu8slice ser_ref;
48525         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48526         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48527         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
48528         *ret_conv = NodeId_read(ser_ref);
48529         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48530         return tag_ptr(ret_conv, true);
48531 }
48532
48533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48534         LDKNetworkGraph this_obj_conv;
48535         this_obj_conv.inner = untag_ptr(this_obj);
48536         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48538         NetworkGraph_free(this_obj_conv);
48539 }
48540
48541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48542         LDKReadOnlyNetworkGraph this_obj_conv;
48543         this_obj_conv.inner = untag_ptr(this_obj);
48544         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48546         ReadOnlyNetworkGraph_free(this_obj_conv);
48547 }
48548
48549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48550         if (!ptr_is_owned(this_ptr)) return;
48551         void* this_ptr_ptr = untag_ptr(this_ptr);
48552         CHECK_ACCESS(this_ptr_ptr);
48553         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
48554         FREE(untag_ptr(this_ptr));
48555         NetworkUpdate_free(this_ptr_conv);
48556 }
48557
48558 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
48559         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48560         *ret_copy = NetworkUpdate_clone(arg);
48561         int64_t ret_ref = tag_ptr(ret_copy, true);
48562         return ret_ref;
48563 }
48564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48565         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
48566         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
48567         return ret_conv;
48568 }
48569
48570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48571         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
48572         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48573         *ret_copy = NetworkUpdate_clone(orig_conv);
48574         int64_t ret_ref = tag_ptr(ret_copy, true);
48575         return ret_ref;
48576 }
48577
48578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
48579         LDKChannelUpdate msg_conv;
48580         msg_conv.inner = untag_ptr(msg);
48581         msg_conv.is_owned = ptr_is_owned(msg);
48582         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
48583         msg_conv = ChannelUpdate_clone(&msg_conv);
48584         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48585         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
48586         int64_t ret_ref = tag_ptr(ret_copy, true);
48587         return ret_ref;
48588 }
48589
48590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
48591         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48592         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
48593         int64_t ret_ref = tag_ptr(ret_copy, true);
48594         return ret_ref;
48595 }
48596
48597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
48598         LDKPublicKey node_id_ref;
48599         CHECK((*env)->GetArrayLength(env, node_id) == 33);
48600         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
48601         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48602         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
48603         int64_t ret_ref = tag_ptr(ret_copy, true);
48604         return ret_ref;
48605 }
48606
48607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48608         LDKNetworkUpdate* a_conv = (LDKNetworkUpdate*)untag_ptr(a);
48609         LDKNetworkUpdate* b_conv = (LDKNetworkUpdate*)untag_ptr(b);
48610         jboolean ret_conv = NetworkUpdate_eq(a_conv, b_conv);
48611         return ret_conv;
48612 }
48613
48614 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
48615         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
48616         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
48617         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48618         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48619         CVec_u8Z_free(ret_var);
48620         return ret_arr;
48621 }
48622
48623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48624         LDKu8slice ser_ref;
48625         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48626         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48627         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
48628         *ret_conv = NetworkUpdate_read(ser_ref);
48629         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48630         return tag_ptr(ret_conv, true);
48631 }
48632
48633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48634         LDKP2PGossipSync this_obj_conv;
48635         this_obj_conv.inner = untag_ptr(this_obj);
48636         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48638         P2PGossipSync_free(this_obj_conv);
48639 }
48640
48641 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) {
48642         LDKNetworkGraph network_graph_conv;
48643         network_graph_conv.inner = untag_ptr(network_graph);
48644         network_graph_conv.is_owned = ptr_is_owned(network_graph);
48645         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
48646         network_graph_conv.is_owned = false;
48647         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
48648         CHECK_ACCESS(utxo_lookup_ptr);
48649         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
48650         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
48651         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
48652                 // Manually implement clone for Java trait instances
48653                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
48654                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48655                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
48656                 }
48657         }
48658         void* logger_ptr = untag_ptr(logger);
48659         CHECK_ACCESS(logger_ptr);
48660         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48661         if (logger_conv.free == LDKLogger_JCalls_free) {
48662                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48663                 LDKLogger_JCalls_cloned(&logger_conv);
48664         }
48665         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, utxo_lookup_conv, logger_conv);
48666         int64_t ret_ref = 0;
48667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48668         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48669         return ret_ref;
48670 }
48671
48672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1utxo_1lookup(JNIEnv *env, jclass clz, int64_t this_arg, int64_t utxo_lookup) {
48673         LDKP2PGossipSync this_arg_conv;
48674         this_arg_conv.inner = untag_ptr(this_arg);
48675         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48677         this_arg_conv.is_owned = false;
48678         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
48679         CHECK_ACCESS(utxo_lookup_ptr);
48680         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
48681         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
48682         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
48683                 // Manually implement clone for Java trait instances
48684                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
48685                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48686                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
48687                 }
48688         }
48689         P2PGossipSync_add_utxo_lookup(&this_arg_conv, utxo_lookup_conv);
48690 }
48691
48692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1handle_1network_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_update) {
48693         LDKNetworkGraph this_arg_conv;
48694         this_arg_conv.inner = untag_ptr(this_arg);
48695         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48697         this_arg_conv.is_owned = false;
48698         LDKNetworkUpdate* network_update_conv = (LDKNetworkUpdate*)untag_ptr(network_update);
48699         NetworkGraph_handle_network_update(&this_arg_conv, network_update_conv);
48700 }
48701
48702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
48703         LDKP2PGossipSync this_arg_conv;
48704         this_arg_conv.inner = untag_ptr(this_arg);
48705         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48707         this_arg_conv.is_owned = false;
48708         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
48709         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
48710         return tag_ptr(ret_ret, true);
48711 }
48712
48713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
48714         LDKP2PGossipSync this_arg_conv;
48715         this_arg_conv.inner = untag_ptr(this_arg);
48716         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48718         this_arg_conv.is_owned = false;
48719         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
48720         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
48721         return tag_ptr(ret_ret, true);
48722 }
48723
48724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48725         LDKChannelUpdateInfo this_obj_conv;
48726         this_obj_conv.inner = untag_ptr(this_obj);
48727         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48729         ChannelUpdateInfo_free(this_obj_conv);
48730 }
48731
48732 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
48733         LDKChannelUpdateInfo this_ptr_conv;
48734         this_ptr_conv.inner = untag_ptr(this_ptr);
48735         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48737         this_ptr_conv.is_owned = false;
48738         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
48739         return ret_conv;
48740 }
48741
48742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
48743         LDKChannelUpdateInfo this_ptr_conv;
48744         this_ptr_conv.inner = untag_ptr(this_ptr);
48745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48747         this_ptr_conv.is_owned = false;
48748         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
48749 }
48750
48751 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
48752         LDKChannelUpdateInfo this_ptr_conv;
48753         this_ptr_conv.inner = untag_ptr(this_ptr);
48754         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48756         this_ptr_conv.is_owned = false;
48757         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
48758         return ret_conv;
48759 }
48760
48761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
48762         LDKChannelUpdateInfo this_ptr_conv;
48763         this_ptr_conv.inner = untag_ptr(this_ptr);
48764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48766         this_ptr_conv.is_owned = false;
48767         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
48768 }
48769
48770 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
48771         LDKChannelUpdateInfo this_ptr_conv;
48772         this_ptr_conv.inner = untag_ptr(this_ptr);
48773         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48775         this_ptr_conv.is_owned = false;
48776         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
48777         return ret_conv;
48778 }
48779
48780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
48781         LDKChannelUpdateInfo this_ptr_conv;
48782         this_ptr_conv.inner = untag_ptr(this_ptr);
48783         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48785         this_ptr_conv.is_owned = false;
48786         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
48787 }
48788
48789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48790         LDKChannelUpdateInfo this_ptr_conv;
48791         this_ptr_conv.inner = untag_ptr(this_ptr);
48792         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48794         this_ptr_conv.is_owned = false;
48795         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
48796         return ret_conv;
48797 }
48798
48799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48800         LDKChannelUpdateInfo this_ptr_conv;
48801         this_ptr_conv.inner = untag_ptr(this_ptr);
48802         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48804         this_ptr_conv.is_owned = false;
48805         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
48806 }
48807
48808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48809         LDKChannelUpdateInfo this_ptr_conv;
48810         this_ptr_conv.inner = untag_ptr(this_ptr);
48811         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48813         this_ptr_conv.is_owned = false;
48814         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
48815         return ret_conv;
48816 }
48817
48818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48819         LDKChannelUpdateInfo this_ptr_conv;
48820         this_ptr_conv.inner = untag_ptr(this_ptr);
48821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48823         this_ptr_conv.is_owned = false;
48824         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
48825 }
48826
48827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
48828         LDKChannelUpdateInfo this_ptr_conv;
48829         this_ptr_conv.inner = untag_ptr(this_ptr);
48830         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48832         this_ptr_conv.is_owned = false;
48833         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
48834         int64_t ret_ref = 0;
48835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48836         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48837         return ret_ref;
48838 }
48839
48840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48841         LDKChannelUpdateInfo this_ptr_conv;
48842         this_ptr_conv.inner = untag_ptr(this_ptr);
48843         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48845         this_ptr_conv.is_owned = false;
48846         LDKRoutingFees val_conv;
48847         val_conv.inner = untag_ptr(val);
48848         val_conv.is_owned = ptr_is_owned(val);
48849         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48850         val_conv = RoutingFees_clone(&val_conv);
48851         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
48852 }
48853
48854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
48855         LDKChannelUpdateInfo this_ptr_conv;
48856         this_ptr_conv.inner = untag_ptr(this_ptr);
48857         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48859         this_ptr_conv.is_owned = false;
48860         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
48861         int64_t ret_ref = 0;
48862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48863         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48864         return ret_ref;
48865 }
48866
48867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48868         LDKChannelUpdateInfo this_ptr_conv;
48869         this_ptr_conv.inner = untag_ptr(this_ptr);
48870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48872         this_ptr_conv.is_owned = false;
48873         LDKChannelUpdate val_conv;
48874         val_conv.inner = untag_ptr(val);
48875         val_conv.is_owned = ptr_is_owned(val);
48876         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48877         val_conv = ChannelUpdate_clone(&val_conv);
48878         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
48879 }
48880
48881 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) {
48882         LDKRoutingFees fees_arg_conv;
48883         fees_arg_conv.inner = untag_ptr(fees_arg);
48884         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
48885         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
48886         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
48887         LDKChannelUpdate last_update_message_arg_conv;
48888         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
48889         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
48890         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
48891         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
48892         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);
48893         int64_t ret_ref = 0;
48894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48895         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48896         return ret_ref;
48897 }
48898
48899 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
48900         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
48901         int64_t ret_ref = 0;
48902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48903         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48904         return ret_ref;
48905 }
48906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48907         LDKChannelUpdateInfo arg_conv;
48908         arg_conv.inner = untag_ptr(arg);
48909         arg_conv.is_owned = ptr_is_owned(arg);
48910         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48911         arg_conv.is_owned = false;
48912         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
48913         return ret_conv;
48914 }
48915
48916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48917         LDKChannelUpdateInfo orig_conv;
48918         orig_conv.inner = untag_ptr(orig);
48919         orig_conv.is_owned = ptr_is_owned(orig);
48920         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48921         orig_conv.is_owned = false;
48922         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
48923         int64_t ret_ref = 0;
48924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48925         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48926         return ret_ref;
48927 }
48928
48929 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48930         LDKChannelUpdateInfo a_conv;
48931         a_conv.inner = untag_ptr(a);
48932         a_conv.is_owned = ptr_is_owned(a);
48933         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48934         a_conv.is_owned = false;
48935         LDKChannelUpdateInfo b_conv;
48936         b_conv.inner = untag_ptr(b);
48937         b_conv.is_owned = ptr_is_owned(b);
48938         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48939         b_conv.is_owned = false;
48940         jboolean ret_conv = ChannelUpdateInfo_eq(&a_conv, &b_conv);
48941         return ret_conv;
48942 }
48943
48944 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
48945         LDKChannelUpdateInfo obj_conv;
48946         obj_conv.inner = untag_ptr(obj);
48947         obj_conv.is_owned = ptr_is_owned(obj);
48948         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48949         obj_conv.is_owned = false;
48950         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
48951         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48952         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48953         CVec_u8Z_free(ret_var);
48954         return ret_arr;
48955 }
48956
48957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48958         LDKu8slice ser_ref;
48959         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48960         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48961         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
48962         *ret_conv = ChannelUpdateInfo_read(ser_ref);
48963         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48964         return tag_ptr(ret_conv, true);
48965 }
48966
48967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48968         LDKChannelInfo this_obj_conv;
48969         this_obj_conv.inner = untag_ptr(this_obj);
48970         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48972         ChannelInfo_free(this_obj_conv);
48973 }
48974
48975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
48976         LDKChannelInfo this_ptr_conv;
48977         this_ptr_conv.inner = untag_ptr(this_ptr);
48978         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48980         this_ptr_conv.is_owned = false;
48981         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
48982         int64_t ret_ref = 0;
48983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48984         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48985         return ret_ref;
48986 }
48987
48988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48989         LDKChannelInfo this_ptr_conv;
48990         this_ptr_conv.inner = untag_ptr(this_ptr);
48991         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48993         this_ptr_conv.is_owned = false;
48994         LDKChannelFeatures val_conv;
48995         val_conv.inner = untag_ptr(val);
48996         val_conv.is_owned = ptr_is_owned(val);
48997         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48998         val_conv = ChannelFeatures_clone(&val_conv);
48999         ChannelInfo_set_features(&this_ptr_conv, val_conv);
49000 }
49001
49002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
49003         LDKChannelInfo this_ptr_conv;
49004         this_ptr_conv.inner = untag_ptr(this_ptr);
49005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49007         this_ptr_conv.is_owned = false;
49008         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
49009         int64_t ret_ref = 0;
49010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49011         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49012         return ret_ref;
49013 }
49014
49015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49016         LDKChannelInfo this_ptr_conv;
49017         this_ptr_conv.inner = untag_ptr(this_ptr);
49018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49020         this_ptr_conv.is_owned = false;
49021         LDKNodeId val_conv;
49022         val_conv.inner = untag_ptr(val);
49023         val_conv.is_owned = ptr_is_owned(val);
49024         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49025         val_conv = NodeId_clone(&val_conv);
49026         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
49027 }
49028
49029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
49030         LDKChannelInfo this_ptr_conv;
49031         this_ptr_conv.inner = untag_ptr(this_ptr);
49032         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49034         this_ptr_conv.is_owned = false;
49035         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
49036         int64_t ret_ref = 0;
49037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49038         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49039         return ret_ref;
49040 }
49041
49042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49043         LDKChannelInfo this_ptr_conv;
49044         this_ptr_conv.inner = untag_ptr(this_ptr);
49045         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49047         this_ptr_conv.is_owned = false;
49048         LDKChannelUpdateInfo val_conv;
49049         val_conv.inner = untag_ptr(val);
49050         val_conv.is_owned = ptr_is_owned(val);
49051         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49052         val_conv = ChannelUpdateInfo_clone(&val_conv);
49053         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
49054 }
49055
49056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
49057         LDKChannelInfo this_ptr_conv;
49058         this_ptr_conv.inner = untag_ptr(this_ptr);
49059         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49061         this_ptr_conv.is_owned = false;
49062         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
49063         int64_t ret_ref = 0;
49064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49065         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49066         return ret_ref;
49067 }
49068
49069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49070         LDKChannelInfo this_ptr_conv;
49071         this_ptr_conv.inner = untag_ptr(this_ptr);
49072         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49074         this_ptr_conv.is_owned = false;
49075         LDKNodeId val_conv;
49076         val_conv.inner = untag_ptr(val);
49077         val_conv.is_owned = ptr_is_owned(val);
49078         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49079         val_conv = NodeId_clone(&val_conv);
49080         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
49081 }
49082
49083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
49084         LDKChannelInfo this_ptr_conv;
49085         this_ptr_conv.inner = untag_ptr(this_ptr);
49086         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49088         this_ptr_conv.is_owned = false;
49089         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
49090         int64_t ret_ref = 0;
49091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49092         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49093         return ret_ref;
49094 }
49095
49096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49097         LDKChannelInfo this_ptr_conv;
49098         this_ptr_conv.inner = untag_ptr(this_ptr);
49099         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49101         this_ptr_conv.is_owned = false;
49102         LDKChannelUpdateInfo val_conv;
49103         val_conv.inner = untag_ptr(val);
49104         val_conv.is_owned = ptr_is_owned(val);
49105         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49106         val_conv = ChannelUpdateInfo_clone(&val_conv);
49107         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
49108 }
49109
49110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
49111         LDKChannelInfo this_ptr_conv;
49112         this_ptr_conv.inner = untag_ptr(this_ptr);
49113         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49115         this_ptr_conv.is_owned = false;
49116         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
49117         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
49118         int64_t ret_ref = tag_ptr(ret_copy, true);
49119         return ret_ref;
49120 }
49121
49122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49123         LDKChannelInfo this_ptr_conv;
49124         this_ptr_conv.inner = untag_ptr(this_ptr);
49125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49127         this_ptr_conv.is_owned = false;
49128         void* val_ptr = untag_ptr(val);
49129         CHECK_ACCESS(val_ptr);
49130         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
49131         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
49132         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
49133 }
49134
49135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
49136         LDKChannelInfo this_ptr_conv;
49137         this_ptr_conv.inner = untag_ptr(this_ptr);
49138         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49140         this_ptr_conv.is_owned = false;
49141         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
49142         int64_t ret_ref = 0;
49143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49144         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49145         return ret_ref;
49146 }
49147
49148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49149         LDKChannelInfo this_ptr_conv;
49150         this_ptr_conv.inner = untag_ptr(this_ptr);
49151         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49153         this_ptr_conv.is_owned = false;
49154         LDKChannelAnnouncement val_conv;
49155         val_conv.inner = untag_ptr(val);
49156         val_conv.is_owned = ptr_is_owned(val);
49157         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49158         val_conv = ChannelAnnouncement_clone(&val_conv);
49159         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
49160 }
49161
49162 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
49163         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
49164         int64_t ret_ref = 0;
49165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49166         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49167         return ret_ref;
49168 }
49169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49170         LDKChannelInfo arg_conv;
49171         arg_conv.inner = untag_ptr(arg);
49172         arg_conv.is_owned = ptr_is_owned(arg);
49173         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49174         arg_conv.is_owned = false;
49175         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
49176         return ret_conv;
49177 }
49178
49179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49180         LDKChannelInfo orig_conv;
49181         orig_conv.inner = untag_ptr(orig);
49182         orig_conv.is_owned = ptr_is_owned(orig);
49183         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49184         orig_conv.is_owned = false;
49185         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
49186         int64_t ret_ref = 0;
49187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49188         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49189         return ret_ref;
49190 }
49191
49192 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49193         LDKChannelInfo a_conv;
49194         a_conv.inner = untag_ptr(a);
49195         a_conv.is_owned = ptr_is_owned(a);
49196         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49197         a_conv.is_owned = false;
49198         LDKChannelInfo b_conv;
49199         b_conv.inner = untag_ptr(b);
49200         b_conv.is_owned = ptr_is_owned(b);
49201         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49202         b_conv.is_owned = false;
49203         jboolean ret_conv = ChannelInfo_eq(&a_conv, &b_conv);
49204         return ret_conv;
49205 }
49206
49207 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) {
49208         LDKChannelInfo this_arg_conv;
49209         this_arg_conv.inner = untag_ptr(this_arg);
49210         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49212         this_arg_conv.is_owned = false;
49213         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
49214         int64_t ret_ref = 0;
49215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49216         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49217         return ret_ref;
49218 }
49219
49220 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
49221         LDKChannelInfo obj_conv;
49222         obj_conv.inner = untag_ptr(obj);
49223         obj_conv.is_owned = ptr_is_owned(obj);
49224         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49225         obj_conv.is_owned = false;
49226         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
49227         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49228         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49229         CVec_u8Z_free(ret_var);
49230         return ret_arr;
49231 }
49232
49233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49234         LDKu8slice ser_ref;
49235         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49236         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49237         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
49238         *ret_conv = ChannelInfo_read(ser_ref);
49239         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49240         return tag_ptr(ret_conv, true);
49241 }
49242
49243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49244         LDKDirectedChannelInfo this_obj_conv;
49245         this_obj_conv.inner = untag_ptr(this_obj);
49246         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49248         DirectedChannelInfo_free(this_obj_conv);
49249 }
49250
49251 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
49252         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
49253         int64_t ret_ref = 0;
49254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49255         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49256         return ret_ref;
49257 }
49258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49259         LDKDirectedChannelInfo arg_conv;
49260         arg_conv.inner = untag_ptr(arg);
49261         arg_conv.is_owned = ptr_is_owned(arg);
49262         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49263         arg_conv.is_owned = false;
49264         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
49265         return ret_conv;
49266 }
49267
49268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49269         LDKDirectedChannelInfo orig_conv;
49270         orig_conv.inner = untag_ptr(orig);
49271         orig_conv.is_owned = ptr_is_owned(orig);
49272         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49273         orig_conv.is_owned = false;
49274         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
49275         int64_t ret_ref = 0;
49276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49277         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49278         return ret_ref;
49279 }
49280
49281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
49282         LDKDirectedChannelInfo this_arg_conv;
49283         this_arg_conv.inner = untag_ptr(this_arg);
49284         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49286         this_arg_conv.is_owned = false;
49287         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
49288         int64_t ret_ref = 0;
49289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49290         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49291         return ret_ref;
49292 }
49293
49294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
49295         LDKDirectedChannelInfo this_arg_conv;
49296         this_arg_conv.inner = untag_ptr(this_arg);
49297         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49299         this_arg_conv.is_owned = false;
49300         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
49301         return ret_conv;
49302 }
49303
49304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
49305         LDKDirectedChannelInfo this_arg_conv;
49306         this_arg_conv.inner = untag_ptr(this_arg);
49307         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49309         this_arg_conv.is_owned = false;
49310         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49311         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
49312         int64_t ret_ref = tag_ptr(ret_copy, true);
49313         return ret_ref;
49314 }
49315
49316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49317         if (!ptr_is_owned(this_ptr)) return;
49318         void* this_ptr_ptr = untag_ptr(this_ptr);
49319         CHECK_ACCESS(this_ptr_ptr);
49320         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
49321         FREE(untag_ptr(this_ptr));
49322         EffectiveCapacity_free(this_ptr_conv);
49323 }
49324
49325 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
49326         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49327         *ret_copy = EffectiveCapacity_clone(arg);
49328         int64_t ret_ref = tag_ptr(ret_copy, true);
49329         return ret_ref;
49330 }
49331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49332         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
49333         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
49334         return ret_conv;
49335 }
49336
49337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49338         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
49339         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49340         *ret_copy = EffectiveCapacity_clone(orig_conv);
49341         int64_t ret_ref = tag_ptr(ret_copy, true);
49342         return ret_ref;
49343 }
49344
49345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
49346         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49347         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
49348         int64_t ret_ref = tag_ptr(ret_copy, true);
49349         return ret_ref;
49350 }
49351
49352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
49353         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49354         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
49355         int64_t ret_ref = tag_ptr(ret_copy, true);
49356         return ret_ref;
49357 }
49358
49359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
49360         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49361         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat);
49362         int64_t ret_ref = tag_ptr(ret_copy, true);
49363         return ret_ref;
49364 }
49365
49366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
49367         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49368         *ret_copy = EffectiveCapacity_infinite();
49369         int64_t ret_ref = tag_ptr(ret_copy, true);
49370         return ret_ref;
49371 }
49372
49373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
49374         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49375         *ret_copy = EffectiveCapacity_unknown();
49376         int64_t ret_ref = tag_ptr(ret_copy, true);
49377         return ret_ref;
49378 }
49379
49380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
49381         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
49382         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
49383         return ret_conv;
49384 }
49385
49386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49387         LDKRoutingFees this_obj_conv;
49388         this_obj_conv.inner = untag_ptr(this_obj);
49389         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49391         RoutingFees_free(this_obj_conv);
49392 }
49393
49394 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49395         LDKRoutingFees this_ptr_conv;
49396         this_ptr_conv.inner = untag_ptr(this_ptr);
49397         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49399         this_ptr_conv.is_owned = false;
49400         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
49401         return ret_conv;
49402 }
49403
49404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
49405         LDKRoutingFees this_ptr_conv;
49406         this_ptr_conv.inner = untag_ptr(this_ptr);
49407         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49409         this_ptr_conv.is_owned = false;
49410         RoutingFees_set_base_msat(&this_ptr_conv, val);
49411 }
49412
49413 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
49414         LDKRoutingFees this_ptr_conv;
49415         this_ptr_conv.inner = untag_ptr(this_ptr);
49416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49418         this_ptr_conv.is_owned = false;
49419         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
49420         return ret_conv;
49421 }
49422
49423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
49424         LDKRoutingFees this_ptr_conv;
49425         this_ptr_conv.inner = untag_ptr(this_ptr);
49426         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49428         this_ptr_conv.is_owned = false;
49429         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
49430 }
49431
49432 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) {
49433         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
49434         int64_t ret_ref = 0;
49435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49436         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49437         return ret_ref;
49438 }
49439
49440 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49441         LDKRoutingFees a_conv;
49442         a_conv.inner = untag_ptr(a);
49443         a_conv.is_owned = ptr_is_owned(a);
49444         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49445         a_conv.is_owned = false;
49446         LDKRoutingFees b_conv;
49447         b_conv.inner = untag_ptr(b);
49448         b_conv.is_owned = ptr_is_owned(b);
49449         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49450         b_conv.is_owned = false;
49451         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
49452         return ret_conv;
49453 }
49454
49455 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
49456         LDKRoutingFees ret_var = RoutingFees_clone(arg);
49457         int64_t ret_ref = 0;
49458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49459         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49460         return ret_ref;
49461 }
49462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49463         LDKRoutingFees arg_conv;
49464         arg_conv.inner = untag_ptr(arg);
49465         arg_conv.is_owned = ptr_is_owned(arg);
49466         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49467         arg_conv.is_owned = false;
49468         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
49469         return ret_conv;
49470 }
49471
49472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49473         LDKRoutingFees orig_conv;
49474         orig_conv.inner = untag_ptr(orig);
49475         orig_conv.is_owned = ptr_is_owned(orig);
49476         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49477         orig_conv.is_owned = false;
49478         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
49479         int64_t ret_ref = 0;
49480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49481         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49482         return ret_ref;
49483 }
49484
49485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
49486         LDKRoutingFees o_conv;
49487         o_conv.inner = untag_ptr(o);
49488         o_conv.is_owned = ptr_is_owned(o);
49489         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49490         o_conv.is_owned = false;
49491         int64_t ret_conv = RoutingFees_hash(&o_conv);
49492         return ret_conv;
49493 }
49494
49495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
49496         LDKRoutingFees obj_conv;
49497         obj_conv.inner = untag_ptr(obj);
49498         obj_conv.is_owned = ptr_is_owned(obj);
49499         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49500         obj_conv.is_owned = false;
49501         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
49502         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49503         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49504         CVec_u8Z_free(ret_var);
49505         return ret_arr;
49506 }
49507
49508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49509         LDKu8slice ser_ref;
49510         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49511         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49512         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
49513         *ret_conv = RoutingFees_read(ser_ref);
49514         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49515         return tag_ptr(ret_conv, true);
49516 }
49517
49518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49519         LDKNodeAnnouncementInfo this_obj_conv;
49520         this_obj_conv.inner = untag_ptr(this_obj);
49521         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49523         NodeAnnouncementInfo_free(this_obj_conv);
49524 }
49525
49526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
49527         LDKNodeAnnouncementInfo this_ptr_conv;
49528         this_ptr_conv.inner = untag_ptr(this_ptr);
49529         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49531         this_ptr_conv.is_owned = false;
49532         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
49533         int64_t ret_ref = 0;
49534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49535         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49536         return ret_ref;
49537 }
49538
49539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49540         LDKNodeAnnouncementInfo this_ptr_conv;
49541         this_ptr_conv.inner = untag_ptr(this_ptr);
49542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49544         this_ptr_conv.is_owned = false;
49545         LDKNodeFeatures val_conv;
49546         val_conv.inner = untag_ptr(val);
49547         val_conv.is_owned = ptr_is_owned(val);
49548         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49549         val_conv = NodeFeatures_clone(&val_conv);
49550         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
49551 }
49552
49553 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
49554         LDKNodeAnnouncementInfo this_ptr_conv;
49555         this_ptr_conv.inner = untag_ptr(this_ptr);
49556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49558         this_ptr_conv.is_owned = false;
49559         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
49560         return ret_conv;
49561 }
49562
49563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
49564         LDKNodeAnnouncementInfo this_ptr_conv;
49565         this_ptr_conv.inner = untag_ptr(this_ptr);
49566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49568         this_ptr_conv.is_owned = false;
49569         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
49570 }
49571
49572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
49573         LDKNodeAnnouncementInfo this_ptr_conv;
49574         this_ptr_conv.inner = untag_ptr(this_ptr);
49575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49577         this_ptr_conv.is_owned = false;
49578         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
49579         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
49580         return ret_arr;
49581 }
49582
49583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
49584         LDKNodeAnnouncementInfo this_ptr_conv;
49585         this_ptr_conv.inner = untag_ptr(this_ptr);
49586         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49588         this_ptr_conv.is_owned = false;
49589         LDKThreeBytes val_ref;
49590         CHECK((*env)->GetArrayLength(env, val) == 3);
49591         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
49592         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
49593 }
49594
49595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
49596         LDKNodeAnnouncementInfo this_ptr_conv;
49597         this_ptr_conv.inner = untag_ptr(this_ptr);
49598         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49600         this_ptr_conv.is_owned = false;
49601         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
49602         int64_t ret_ref = 0;
49603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49604         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49605         return ret_ref;
49606 }
49607
49608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49609         LDKNodeAnnouncementInfo this_ptr_conv;
49610         this_ptr_conv.inner = untag_ptr(this_ptr);
49611         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49613         this_ptr_conv.is_owned = false;
49614         LDKNodeAlias val_conv;
49615         val_conv.inner = untag_ptr(val);
49616         val_conv.is_owned = ptr_is_owned(val);
49617         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49618         val_conv = NodeAlias_clone(&val_conv);
49619         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
49620 }
49621
49622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
49623         LDKNodeAnnouncementInfo this_ptr_conv;
49624         this_ptr_conv.inner = untag_ptr(this_ptr);
49625         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49627         this_ptr_conv.is_owned = false;
49628         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
49629         int64_t ret_ref = 0;
49630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49631         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49632         return ret_ref;
49633 }
49634
49635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49636         LDKNodeAnnouncementInfo this_ptr_conv;
49637         this_ptr_conv.inner = untag_ptr(this_ptr);
49638         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49640         this_ptr_conv.is_owned = false;
49641         LDKNodeAnnouncement val_conv;
49642         val_conv.inner = untag_ptr(val);
49643         val_conv.is_owned = ptr_is_owned(val);
49644         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49645         val_conv = NodeAnnouncement_clone(&val_conv);
49646         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
49647 }
49648
49649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int64_t alias_arg, int64_t announcement_message_arg) {
49650         LDKNodeFeatures features_arg_conv;
49651         features_arg_conv.inner = untag_ptr(features_arg);
49652         features_arg_conv.is_owned = ptr_is_owned(features_arg);
49653         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
49654         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
49655         LDKThreeBytes rgb_arg_ref;
49656         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
49657         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
49658         LDKNodeAlias alias_arg_conv;
49659         alias_arg_conv.inner = untag_ptr(alias_arg);
49660         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
49661         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
49662         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
49663         LDKNodeAnnouncement announcement_message_arg_conv;
49664         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
49665         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
49666         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
49667         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
49668         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, announcement_message_arg_conv);
49669         int64_t ret_ref = 0;
49670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49671         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49672         return ret_ref;
49673 }
49674
49675 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
49676         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
49677         int64_t ret_ref = 0;
49678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49679         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49680         return ret_ref;
49681 }
49682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49683         LDKNodeAnnouncementInfo arg_conv;
49684         arg_conv.inner = untag_ptr(arg);
49685         arg_conv.is_owned = ptr_is_owned(arg);
49686         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49687         arg_conv.is_owned = false;
49688         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
49689         return ret_conv;
49690 }
49691
49692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49693         LDKNodeAnnouncementInfo orig_conv;
49694         orig_conv.inner = untag_ptr(orig);
49695         orig_conv.is_owned = ptr_is_owned(orig);
49696         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49697         orig_conv.is_owned = false;
49698         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
49699         int64_t ret_ref = 0;
49700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49701         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49702         return ret_ref;
49703 }
49704
49705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49706         LDKNodeAnnouncementInfo a_conv;
49707         a_conv.inner = untag_ptr(a);
49708         a_conv.is_owned = ptr_is_owned(a);
49709         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49710         a_conv.is_owned = false;
49711         LDKNodeAnnouncementInfo b_conv;
49712         b_conv.inner = untag_ptr(b);
49713         b_conv.is_owned = ptr_is_owned(b);
49714         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49715         b_conv.is_owned = false;
49716         jboolean ret_conv = NodeAnnouncementInfo_eq(&a_conv, &b_conv);
49717         return ret_conv;
49718 }
49719
49720 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1addresses(JNIEnv *env, jclass clz, int64_t this_arg) {
49721         LDKNodeAnnouncementInfo this_arg_conv;
49722         this_arg_conv.inner = untag_ptr(this_arg);
49723         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49725         this_arg_conv.is_owned = false;
49726         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_addresses(&this_arg_conv);
49727         int64_tArray ret_arr = NULL;
49728         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49729         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49730         for (size_t m = 0; m < ret_var.datalen; m++) {
49731                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
49732                 *ret_conv_12_copy = ret_var.data[m];
49733                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
49734                 ret_arr_ptr[m] = ret_conv_12_ref;
49735         }
49736         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49737         FREE(ret_var.data);
49738         return ret_arr;
49739 }
49740
49741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
49742         LDKNodeAnnouncementInfo obj_conv;
49743         obj_conv.inner = untag_ptr(obj);
49744         obj_conv.is_owned = ptr_is_owned(obj);
49745         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49746         obj_conv.is_owned = false;
49747         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
49748         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49749         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49750         CVec_u8Z_free(ret_var);
49751         return ret_arr;
49752 }
49753
49754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49755         LDKu8slice ser_ref;
49756         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49757         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49758         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
49759         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
49760         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49761         return tag_ptr(ret_conv, true);
49762 }
49763
49764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49765         LDKNodeAlias this_obj_conv;
49766         this_obj_conv.inner = untag_ptr(this_obj);
49767         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49769         NodeAlias_free(this_obj_conv);
49770 }
49771
49772 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
49773         LDKNodeAlias this_ptr_conv;
49774         this_ptr_conv.inner = untag_ptr(this_ptr);
49775         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49777         this_ptr_conv.is_owned = false;
49778         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
49779         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
49780         return ret_arr;
49781 }
49782
49783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
49784         LDKNodeAlias this_ptr_conv;
49785         this_ptr_conv.inner = untag_ptr(this_ptr);
49786         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49788         this_ptr_conv.is_owned = false;
49789         LDKThirtyTwoBytes val_ref;
49790         CHECK((*env)->GetArrayLength(env, val) == 32);
49791         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
49792         NodeAlias_set_a(&this_ptr_conv, val_ref);
49793 }
49794
49795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
49796         LDKThirtyTwoBytes a_arg_ref;
49797         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
49798         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
49799         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
49800         int64_t ret_ref = 0;
49801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49802         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49803         return ret_ref;
49804 }
49805
49806 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
49807         LDKNodeAlias ret_var = NodeAlias_clone(arg);
49808         int64_t ret_ref = 0;
49809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49810         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49811         return ret_ref;
49812 }
49813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49814         LDKNodeAlias arg_conv;
49815         arg_conv.inner = untag_ptr(arg);
49816         arg_conv.is_owned = ptr_is_owned(arg);
49817         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49818         arg_conv.is_owned = false;
49819         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
49820         return ret_conv;
49821 }
49822
49823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49824         LDKNodeAlias orig_conv;
49825         orig_conv.inner = untag_ptr(orig);
49826         orig_conv.is_owned = ptr_is_owned(orig);
49827         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49828         orig_conv.is_owned = false;
49829         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
49830         int64_t ret_ref = 0;
49831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49832         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49833         return ret_ref;
49834 }
49835
49836 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAlias_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49837         LDKNodeAlias a_conv;
49838         a_conv.inner = untag_ptr(a);
49839         a_conv.is_owned = ptr_is_owned(a);
49840         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49841         a_conv.is_owned = false;
49842         LDKNodeAlias b_conv;
49843         b_conv.inner = untag_ptr(b);
49844         b_conv.is_owned = ptr_is_owned(b);
49845         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49846         b_conv.is_owned = false;
49847         jboolean ret_conv = NodeAlias_eq(&a_conv, &b_conv);
49848         return ret_conv;
49849 }
49850
49851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
49852         LDKNodeAlias obj_conv;
49853         obj_conv.inner = untag_ptr(obj);
49854         obj_conv.is_owned = ptr_is_owned(obj);
49855         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49856         obj_conv.is_owned = false;
49857         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
49858         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49859         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49860         CVec_u8Z_free(ret_var);
49861         return ret_arr;
49862 }
49863
49864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49865         LDKu8slice ser_ref;
49866         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49867         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49868         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
49869         *ret_conv = NodeAlias_read(ser_ref);
49870         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49871         return tag_ptr(ret_conv, true);
49872 }
49873
49874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49875         LDKNodeInfo this_obj_conv;
49876         this_obj_conv.inner = untag_ptr(this_obj);
49877         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49879         NodeInfo_free(this_obj_conv);
49880 }
49881
49882 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
49883         LDKNodeInfo this_ptr_conv;
49884         this_ptr_conv.inner = untag_ptr(this_ptr);
49885         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49887         this_ptr_conv.is_owned = false;
49888         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
49889         int64_tArray ret_arr = NULL;
49890         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49891         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49892         for (size_t g = 0; g < ret_var.datalen; g++) {
49893                 int64_t ret_conv_6_conv = ret_var.data[g];
49894                 ret_arr_ptr[g] = ret_conv_6_conv;
49895         }
49896         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49897         FREE(ret_var.data);
49898         return ret_arr;
49899 }
49900
49901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
49902         LDKNodeInfo this_ptr_conv;
49903         this_ptr_conv.inner = untag_ptr(this_ptr);
49904         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49906         this_ptr_conv.is_owned = false;
49907         LDKCVec_u64Z val_constr;
49908         val_constr.datalen = (*env)->GetArrayLength(env, val);
49909         if (val_constr.datalen > 0)
49910                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
49911         else
49912                 val_constr.data = NULL;
49913         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
49914         for (size_t g = 0; g < val_constr.datalen; g++) {
49915                 int64_t val_conv_6 = val_vals[g];
49916                 val_constr.data[g] = val_conv_6;
49917         }
49918         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
49919         NodeInfo_set_channels(&this_ptr_conv, val_constr);
49920 }
49921
49922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
49923         LDKNodeInfo this_ptr_conv;
49924         this_ptr_conv.inner = untag_ptr(this_ptr);
49925         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49927         this_ptr_conv.is_owned = false;
49928         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
49929         int64_t ret_ref = 0;
49930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49932         return ret_ref;
49933 }
49934
49935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49936         LDKNodeInfo this_ptr_conv;
49937         this_ptr_conv.inner = untag_ptr(this_ptr);
49938         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49940         this_ptr_conv.is_owned = false;
49941         LDKNodeAnnouncementInfo val_conv;
49942         val_conv.inner = untag_ptr(val);
49943         val_conv.is_owned = ptr_is_owned(val);
49944         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49945         val_conv = NodeAnnouncementInfo_clone(&val_conv);
49946         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
49947 }
49948
49949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv *env, jclass clz, int64_tArray channels_arg, int64_t announcement_info_arg) {
49950         LDKCVec_u64Z channels_arg_constr;
49951         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
49952         if (channels_arg_constr.datalen > 0)
49953                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
49954         else
49955                 channels_arg_constr.data = NULL;
49956         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
49957         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
49958                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
49959                 channels_arg_constr.data[g] = channels_arg_conv_6;
49960         }
49961         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
49962         LDKNodeAnnouncementInfo announcement_info_arg_conv;
49963         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
49964         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
49965         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
49966         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
49967         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, announcement_info_arg_conv);
49968         int64_t ret_ref = 0;
49969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49970         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49971         return ret_ref;
49972 }
49973
49974 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
49975         LDKNodeInfo ret_var = NodeInfo_clone(arg);
49976         int64_t ret_ref = 0;
49977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49978         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49979         return ret_ref;
49980 }
49981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49982         LDKNodeInfo arg_conv;
49983         arg_conv.inner = untag_ptr(arg);
49984         arg_conv.is_owned = ptr_is_owned(arg);
49985         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49986         arg_conv.is_owned = false;
49987         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
49988         return ret_conv;
49989 }
49990
49991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49992         LDKNodeInfo orig_conv;
49993         orig_conv.inner = untag_ptr(orig);
49994         orig_conv.is_owned = ptr_is_owned(orig);
49995         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49996         orig_conv.is_owned = false;
49997         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
49998         int64_t ret_ref = 0;
49999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50000         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50001         return ret_ref;
50002 }
50003
50004 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50005         LDKNodeInfo a_conv;
50006         a_conv.inner = untag_ptr(a);
50007         a_conv.is_owned = ptr_is_owned(a);
50008         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50009         a_conv.is_owned = false;
50010         LDKNodeInfo b_conv;
50011         b_conv.inner = untag_ptr(b);
50012         b_conv.is_owned = ptr_is_owned(b);
50013         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50014         b_conv.is_owned = false;
50015         jboolean ret_conv = NodeInfo_eq(&a_conv, &b_conv);
50016         return ret_conv;
50017 }
50018
50019 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
50020         LDKNodeInfo obj_conv;
50021         obj_conv.inner = untag_ptr(obj);
50022         obj_conv.is_owned = ptr_is_owned(obj);
50023         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50024         obj_conv.is_owned = false;
50025         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
50026         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50027         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50028         CVec_u8Z_free(ret_var);
50029         return ret_arr;
50030 }
50031
50032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50033         LDKu8slice ser_ref;
50034         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50035         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50036         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
50037         *ret_conv = NodeInfo_read(ser_ref);
50038         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50039         return tag_ptr(ret_conv, true);
50040 }
50041
50042 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
50043         LDKNetworkGraph obj_conv;
50044         obj_conv.inner = untag_ptr(obj);
50045         obj_conv.is_owned = ptr_is_owned(obj);
50046         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50047         obj_conv.is_owned = false;
50048         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
50049         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50050         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50051         CVec_u8Z_free(ret_var);
50052         return ret_arr;
50053 }
50054
50055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
50056         LDKu8slice ser_ref;
50057         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50058         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50059         void* arg_ptr = untag_ptr(arg);
50060         CHECK_ACCESS(arg_ptr);
50061         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
50062         if (arg_conv.free == LDKLogger_JCalls_free) {
50063                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50064                 LDKLogger_JCalls_cloned(&arg_conv);
50065         }
50066         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
50067         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
50068         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50069         return tag_ptr(ret_conv, true);
50070 }
50071
50072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, jclass network, int64_t logger) {
50073         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
50074         void* logger_ptr = untag_ptr(logger);
50075         CHECK_ACCESS(logger_ptr);
50076         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50077         if (logger_conv.free == LDKLogger_JCalls_free) {
50078                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50079                 LDKLogger_JCalls_cloned(&logger_conv);
50080         }
50081         LDKNetworkGraph ret_var = NetworkGraph_new(network_conv, logger_conv);
50082         int64_t ret_ref = 0;
50083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50084         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50085         return ret_ref;
50086 }
50087
50088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
50089         LDKNetworkGraph this_arg_conv;
50090         this_arg_conv.inner = untag_ptr(this_arg);
50091         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50093         this_arg_conv.is_owned = false;
50094         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
50095         int64_t ret_ref = 0;
50096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50097         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50098         return ret_ref;
50099 }
50100
50101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
50102         LDKNetworkGraph this_arg_conv;
50103         this_arg_conv.inner = untag_ptr(this_arg);
50104         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50106         this_arg_conv.is_owned = false;
50107         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
50108         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
50109         int64_t ret_ref = tag_ptr(ret_copy, true);
50110         return ret_ref;
50111 }
50112
50113 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) {
50114         LDKNetworkGraph this_arg_conv;
50115         this_arg_conv.inner = untag_ptr(this_arg);
50116         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50118         this_arg_conv.is_owned = false;
50119         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
50120 }
50121
50122 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) {
50123         LDKNetworkGraph this_arg_conv;
50124         this_arg_conv.inner = untag_ptr(this_arg);
50125         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50127         this_arg_conv.is_owned = false;
50128         LDKNodeAnnouncement msg_conv;
50129         msg_conv.inner = untag_ptr(msg);
50130         msg_conv.is_owned = ptr_is_owned(msg);
50131         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50132         msg_conv.is_owned = false;
50133         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50134         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
50135         return tag_ptr(ret_conv, true);
50136 }
50137
50138 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) {
50139         LDKNetworkGraph this_arg_conv;
50140         this_arg_conv.inner = untag_ptr(this_arg);
50141         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50143         this_arg_conv.is_owned = false;
50144         LDKUnsignedNodeAnnouncement msg_conv;
50145         msg_conv.inner = untag_ptr(msg);
50146         msg_conv.is_owned = ptr_is_owned(msg);
50147         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50148         msg_conv.is_owned = false;
50149         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50150         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
50151         return tag_ptr(ret_conv, true);
50152 }
50153
50154 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) {
50155         LDKNetworkGraph this_arg_conv;
50156         this_arg_conv.inner = untag_ptr(this_arg);
50157         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50159         this_arg_conv.is_owned = false;
50160         LDKChannelAnnouncement msg_conv;
50161         msg_conv.inner = untag_ptr(msg);
50162         msg_conv.is_owned = ptr_is_owned(msg);
50163         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50164         msg_conv.is_owned = false;
50165         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
50166         CHECK_ACCESS(utxo_lookup_ptr);
50167         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
50168         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
50169         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
50170                 // Manually implement clone for Java trait instances
50171                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
50172                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50173                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
50174                 }
50175         }
50176         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50177         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
50178         return tag_ptr(ret_conv, true);
50179 }
50180
50181 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) {
50182         LDKNetworkGraph this_arg_conv;
50183         this_arg_conv.inner = untag_ptr(this_arg);
50184         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50186         this_arg_conv.is_owned = false;
50187         LDKUnsignedChannelAnnouncement msg_conv;
50188         msg_conv.inner = untag_ptr(msg);
50189         msg_conv.is_owned = ptr_is_owned(msg);
50190         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50191         msg_conv.is_owned = false;
50192         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
50193         CHECK_ACCESS(utxo_lookup_ptr);
50194         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
50195         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
50196         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
50197                 // Manually implement clone for Java trait instances
50198                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
50199                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50200                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
50201                 }
50202         }
50203         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50204         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
50205         return tag_ptr(ret_conv, true);
50206 }
50207
50208 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) {
50209         LDKNetworkGraph this_arg_conv;
50210         this_arg_conv.inner = untag_ptr(this_arg);
50211         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50213         this_arg_conv.is_owned = false;
50214         LDKChannelFeatures features_conv;
50215         features_conv.inner = untag_ptr(features);
50216         features_conv.is_owned = ptr_is_owned(features);
50217         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
50218         features_conv = ChannelFeatures_clone(&features_conv);
50219         LDKPublicKey node_id_1_ref;
50220         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
50221         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
50222         LDKPublicKey node_id_2_ref;
50223         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
50224         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
50225         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50226         *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);
50227         return tag_ptr(ret_conv, true);
50228 }
50229
50230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1channel_1failed_1permanent(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
50231         LDKNetworkGraph this_arg_conv;
50232         this_arg_conv.inner = untag_ptr(this_arg);
50233         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50235         this_arg_conv.is_owned = false;
50236         NetworkGraph_channel_failed_permanent(&this_arg_conv, short_channel_id);
50237 }
50238
50239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed_1permanent(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray node_id) {
50240         LDKNetworkGraph this_arg_conv;
50241         this_arg_conv.inner = untag_ptr(this_arg);
50242         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50244         this_arg_conv.is_owned = false;
50245         LDKPublicKey node_id_ref;
50246         CHECK((*env)->GetArrayLength(env, node_id) == 33);
50247         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
50248         NetworkGraph_node_failed_permanent(&this_arg_conv, node_id_ref);
50249 }
50250
50251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels_1and_1tracking(JNIEnv *env, jclass clz, int64_t this_arg) {
50252         LDKNetworkGraph this_arg_conv;
50253         this_arg_conv.inner = untag_ptr(this_arg);
50254         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50256         this_arg_conv.is_owned = false;
50257         NetworkGraph_remove_stale_channels_and_tracking(&this_arg_conv);
50258 }
50259
50260 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) {
50261         LDKNetworkGraph this_arg_conv;
50262         this_arg_conv.inner = untag_ptr(this_arg);
50263         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50265         this_arg_conv.is_owned = false;
50266         NetworkGraph_remove_stale_channels_and_tracking_with_time(&this_arg_conv, current_time_unix);
50267 }
50268
50269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
50270         LDKNetworkGraph this_arg_conv;
50271         this_arg_conv.inner = untag_ptr(this_arg);
50272         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50274         this_arg_conv.is_owned = false;
50275         LDKChannelUpdate msg_conv;
50276         msg_conv.inner = untag_ptr(msg);
50277         msg_conv.is_owned = ptr_is_owned(msg);
50278         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50279         msg_conv.is_owned = false;
50280         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50281         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
50282         return tag_ptr(ret_conv, true);
50283 }
50284
50285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
50286         LDKNetworkGraph this_arg_conv;
50287         this_arg_conv.inner = untag_ptr(this_arg);
50288         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50290         this_arg_conv.is_owned = false;
50291         LDKUnsignedChannelUpdate msg_conv;
50292         msg_conv.inner = untag_ptr(msg);
50293         msg_conv.is_owned = ptr_is_owned(msg);
50294         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50295         msg_conv.is_owned = false;
50296         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50297         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
50298         return tag_ptr(ret_conv, true);
50299 }
50300
50301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
50302         LDKReadOnlyNetworkGraph this_arg_conv;
50303         this_arg_conv.inner = untag_ptr(this_arg);
50304         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50306         this_arg_conv.is_owned = false;
50307         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
50308         int64_t ret_ref = 0;
50309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50310         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50311         return ret_ref;
50312 }
50313
50314 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
50315         LDKReadOnlyNetworkGraph this_arg_conv;
50316         this_arg_conv.inner = untag_ptr(this_arg);
50317         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50319         this_arg_conv.is_owned = false;
50320         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
50321         int64_tArray ret_arr = NULL;
50322         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50323         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50324         for (size_t g = 0; g < ret_var.datalen; g++) {
50325                 int64_t ret_conv_6_conv = ret_var.data[g];
50326                 ret_arr_ptr[g] = ret_conv_6_conv;
50327         }
50328         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50329         FREE(ret_var.data);
50330         return ret_arr;
50331 }
50332
50333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
50334         LDKReadOnlyNetworkGraph this_arg_conv;
50335         this_arg_conv.inner = untag_ptr(this_arg);
50336         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50338         this_arg_conv.is_owned = false;
50339         LDKNodeId node_id_conv;
50340         node_id_conv.inner = untag_ptr(node_id);
50341         node_id_conv.is_owned = ptr_is_owned(node_id);
50342         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
50343         node_id_conv.is_owned = false;
50344         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
50345         int64_t ret_ref = 0;
50346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50347         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50348         return ret_ref;
50349 }
50350
50351 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1nodes(JNIEnv *env, jclass clz, int64_t this_arg) {
50352         LDKReadOnlyNetworkGraph this_arg_conv;
50353         this_arg_conv.inner = untag_ptr(this_arg);
50354         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50356         this_arg_conv.is_owned = false;
50357         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
50358         int64_tArray ret_arr = NULL;
50359         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50360         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50361         for (size_t i = 0; i < ret_var.datalen; i++) {
50362                 LDKNodeId ret_conv_8_var = ret_var.data[i];
50363                 int64_t ret_conv_8_ref = 0;
50364                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
50365                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
50366                 ret_arr_ptr[i] = ret_conv_8_ref;
50367         }
50368         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50369         FREE(ret_var.data);
50370         return ret_arr;
50371 }
50372
50373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
50374         LDKReadOnlyNetworkGraph this_arg_conv;
50375         this_arg_conv.inner = untag_ptr(this_arg);
50376         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50378         this_arg_conv.is_owned = false;
50379         LDKPublicKey pubkey_ref;
50380         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
50381         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
50382         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
50383         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
50384         int64_t ret_ref = tag_ptr(ret_copy, true);
50385         return ret_ref;
50386 }
50387
50388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50389         LDKDefaultRouter this_obj_conv;
50390         this_obj_conv.inner = untag_ptr(this_obj);
50391         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50393         DefaultRouter_free(this_obj_conv);
50394 }
50395
50396 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) {
50397         LDKNetworkGraph network_graph_conv;
50398         network_graph_conv.inner = untag_ptr(network_graph);
50399         network_graph_conv.is_owned = ptr_is_owned(network_graph);
50400         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
50401         network_graph_conv.is_owned = false;
50402         void* logger_ptr = untag_ptr(logger);
50403         CHECK_ACCESS(logger_ptr);
50404         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50405         if (logger_conv.free == LDKLogger_JCalls_free) {
50406                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50407                 LDKLogger_JCalls_cloned(&logger_conv);
50408         }
50409         LDKThirtyTwoBytes random_seed_bytes_ref;
50410         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
50411         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
50412         void* scorer_ptr = untag_ptr(scorer);
50413         CHECK_ACCESS(scorer_ptr);
50414         LDKLockableScore scorer_conv = *(LDKLockableScore*)(scorer_ptr);
50415         if (scorer_conv.free == LDKLockableScore_JCalls_free) {
50416                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50417                 LDKLockableScore_JCalls_cloned(&scorer_conv);
50418         }
50419         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref, scorer_conv);
50420         int64_t ret_ref = 0;
50421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50423         return ret_ref;
50424 }
50425
50426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
50427         LDKDefaultRouter this_arg_conv;
50428         this_arg_conv.inner = untag_ptr(this_arg);
50429         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50431         this_arg_conv.is_owned = false;
50432         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
50433         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
50434         return tag_ptr(ret_ret, true);
50435 }
50436
50437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50438         if (!ptr_is_owned(this_ptr)) return;
50439         void* this_ptr_ptr = untag_ptr(this_ptr);
50440         CHECK_ACCESS(this_ptr_ptr);
50441         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
50442         FREE(untag_ptr(this_ptr));
50443         Router_free(this_ptr_conv);
50444 }
50445
50446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50447         LDKScorerAccountingForInFlightHtlcs this_obj_conv;
50448         this_obj_conv.inner = untag_ptr(this_obj);
50449         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50451         ScorerAccountingForInFlightHtlcs_free(this_obj_conv);
50452 }
50453
50454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1new(JNIEnv *env, jclass clz, int64_t scorer, int64_t inflight_htlcs) {
50455         void* scorer_ptr = untag_ptr(scorer);
50456         CHECK_ACCESS(scorer_ptr);
50457         LDKScore scorer_conv = *(LDKScore*)(scorer_ptr);
50458         if (scorer_conv.free == LDKScore_JCalls_free) {
50459                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50460                 LDKScore_JCalls_cloned(&scorer_conv);
50461         }
50462         LDKInFlightHtlcs inflight_htlcs_conv;
50463         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
50464         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
50465         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
50466         inflight_htlcs_conv.is_owned = false;
50467         LDKScorerAccountingForInFlightHtlcs ret_var = ScorerAccountingForInFlightHtlcs_new(scorer_conv, &inflight_htlcs_conv);
50468         int64_t ret_ref = 0;
50469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50470         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50471         return ret_ref;
50472 }
50473
50474 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
50475         LDKScorerAccountingForInFlightHtlcs obj_conv;
50476         obj_conv.inner = untag_ptr(obj);
50477         obj_conv.is_owned = ptr_is_owned(obj);
50478         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50479         obj_conv.is_owned = false;
50480         LDKCVec_u8Z ret_var = ScorerAccountingForInFlightHtlcs_write(&obj_conv);
50481         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50482         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50483         CVec_u8Z_free(ret_var);
50484         return ret_arr;
50485 }
50486
50487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
50488         LDKScorerAccountingForInFlightHtlcs this_arg_conv;
50489         this_arg_conv.inner = untag_ptr(this_arg);
50490         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50492         this_arg_conv.is_owned = false;
50493         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
50494         *ret_ret = ScorerAccountingForInFlightHtlcs_as_Score(&this_arg_conv);
50495         return tag_ptr(ret_ret, true);
50496 }
50497
50498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50499         LDKInFlightHtlcs this_obj_conv;
50500         this_obj_conv.inner = untag_ptr(this_obj);
50501         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50503         InFlightHtlcs_free(this_obj_conv);
50504 }
50505
50506 static inline uint64_t InFlightHtlcs_clone_ptr(LDKInFlightHtlcs *NONNULL_PTR arg) {
50507         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(arg);
50508         int64_t ret_ref = 0;
50509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50510         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50511         return ret_ref;
50512 }
50513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50514         LDKInFlightHtlcs arg_conv;
50515         arg_conv.inner = untag_ptr(arg);
50516         arg_conv.is_owned = ptr_is_owned(arg);
50517         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50518         arg_conv.is_owned = false;
50519         int64_t ret_conv = InFlightHtlcs_clone_ptr(&arg_conv);
50520         return ret_conv;
50521 }
50522
50523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50524         LDKInFlightHtlcs orig_conv;
50525         orig_conv.inner = untag_ptr(orig);
50526         orig_conv.is_owned = ptr_is_owned(orig);
50527         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50528         orig_conv.is_owned = false;
50529         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(&orig_conv);
50530         int64_t ret_ref = 0;
50531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50532         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50533         return ret_ref;
50534 }
50535
50536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1new(JNIEnv *env, jclass clz) {
50537         LDKInFlightHtlcs ret_var = InFlightHtlcs_new();
50538         int64_t ret_ref = 0;
50539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50540         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50541         return ret_ref;
50542 }
50543
50544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1process_1path(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path, int8_tArray payer_node_id) {
50545         LDKInFlightHtlcs this_arg_conv;
50546         this_arg_conv.inner = untag_ptr(this_arg);
50547         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50549         this_arg_conv.is_owned = false;
50550         LDKPath path_conv;
50551         path_conv.inner = untag_ptr(path);
50552         path_conv.is_owned = ptr_is_owned(path);
50553         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
50554         path_conv.is_owned = false;
50555         LDKPublicKey payer_node_id_ref;
50556         CHECK((*env)->GetArrayLength(env, payer_node_id) == 33);
50557         (*env)->GetByteArrayRegion(env, payer_node_id, 0, 33, payer_node_id_ref.compressed_form);
50558         InFlightHtlcs_process_path(&this_arg_conv, &path_conv, payer_node_id_ref);
50559 }
50560
50561 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) {
50562         LDKInFlightHtlcs this_arg_conv;
50563         this_arg_conv.inner = untag_ptr(this_arg);
50564         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50566         this_arg_conv.is_owned = false;
50567         LDKNodeId source_conv;
50568         source_conv.inner = untag_ptr(source);
50569         source_conv.is_owned = ptr_is_owned(source);
50570         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
50571         source_conv.is_owned = false;
50572         LDKNodeId target_conv;
50573         target_conv.inner = untag_ptr(target);
50574         target_conv.is_owned = ptr_is_owned(target);
50575         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
50576         target_conv.is_owned = false;
50577         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
50578         *ret_copy = InFlightHtlcs_used_liquidity_msat(&this_arg_conv, &source_conv, &target_conv, channel_scid);
50579         int64_t ret_ref = tag_ptr(ret_copy, true);
50580         return ret_ref;
50581 }
50582
50583 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
50584         LDKInFlightHtlcs obj_conv;
50585         obj_conv.inner = untag_ptr(obj);
50586         obj_conv.is_owned = ptr_is_owned(obj);
50587         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50588         obj_conv.is_owned = false;
50589         LDKCVec_u8Z ret_var = InFlightHtlcs_write(&obj_conv);
50590         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50591         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50592         CVec_u8Z_free(ret_var);
50593         return ret_arr;
50594 }
50595
50596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50597         LDKu8slice ser_ref;
50598         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50599         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50600         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
50601         *ret_conv = InFlightHtlcs_read(ser_ref);
50602         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50603         return tag_ptr(ret_conv, true);
50604 }
50605
50606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50607         LDKRouteHop this_obj_conv;
50608         this_obj_conv.inner = untag_ptr(this_obj);
50609         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50611         RouteHop_free(this_obj_conv);
50612 }
50613
50614 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
50615         LDKRouteHop this_ptr_conv;
50616         this_ptr_conv.inner = untag_ptr(this_ptr);
50617         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50619         this_ptr_conv.is_owned = false;
50620         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50621         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
50622         return ret_arr;
50623 }
50624
50625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
50626         LDKRouteHop this_ptr_conv;
50627         this_ptr_conv.inner = untag_ptr(this_ptr);
50628         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50630         this_ptr_conv.is_owned = false;
50631         LDKPublicKey val_ref;
50632         CHECK((*env)->GetArrayLength(env, val) == 33);
50633         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
50634         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
50635 }
50636
50637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
50638         LDKRouteHop this_ptr_conv;
50639         this_ptr_conv.inner = untag_ptr(this_ptr);
50640         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50642         this_ptr_conv.is_owned = false;
50643         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
50644         int64_t ret_ref = 0;
50645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50646         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50647         return ret_ref;
50648 }
50649
50650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50651         LDKRouteHop this_ptr_conv;
50652         this_ptr_conv.inner = untag_ptr(this_ptr);
50653         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50655         this_ptr_conv.is_owned = false;
50656         LDKNodeFeatures val_conv;
50657         val_conv.inner = untag_ptr(val);
50658         val_conv.is_owned = ptr_is_owned(val);
50659         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
50660         val_conv = NodeFeatures_clone(&val_conv);
50661         RouteHop_set_node_features(&this_ptr_conv, val_conv);
50662 }
50663
50664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
50665         LDKRouteHop this_ptr_conv;
50666         this_ptr_conv.inner = untag_ptr(this_ptr);
50667         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50669         this_ptr_conv.is_owned = false;
50670         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
50671         return ret_conv;
50672 }
50673
50674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50675         LDKRouteHop this_ptr_conv;
50676         this_ptr_conv.inner = untag_ptr(this_ptr);
50677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50679         this_ptr_conv.is_owned = false;
50680         RouteHop_set_short_channel_id(&this_ptr_conv, val);
50681 }
50682
50683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
50684         LDKRouteHop this_ptr_conv;
50685         this_ptr_conv.inner = untag_ptr(this_ptr);
50686         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50688         this_ptr_conv.is_owned = false;
50689         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
50690         int64_t ret_ref = 0;
50691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50692         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50693         return ret_ref;
50694 }
50695
50696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50697         LDKRouteHop this_ptr_conv;
50698         this_ptr_conv.inner = untag_ptr(this_ptr);
50699         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50701         this_ptr_conv.is_owned = false;
50702         LDKChannelFeatures val_conv;
50703         val_conv.inner = untag_ptr(val);
50704         val_conv.is_owned = ptr_is_owned(val);
50705         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
50706         val_conv = ChannelFeatures_clone(&val_conv);
50707         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
50708 }
50709
50710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50711         LDKRouteHop this_ptr_conv;
50712         this_ptr_conv.inner = untag_ptr(this_ptr);
50713         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50715         this_ptr_conv.is_owned = false;
50716         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
50717         return ret_conv;
50718 }
50719
50720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50721         LDKRouteHop this_ptr_conv;
50722         this_ptr_conv.inner = untag_ptr(this_ptr);
50723         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50725         this_ptr_conv.is_owned = false;
50726         RouteHop_set_fee_msat(&this_ptr_conv, val);
50727 }
50728
50729 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
50730         LDKRouteHop this_ptr_conv;
50731         this_ptr_conv.inner = untag_ptr(this_ptr);
50732         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50734         this_ptr_conv.is_owned = false;
50735         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
50736         return ret_conv;
50737 }
50738
50739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
50740         LDKRouteHop this_ptr_conv;
50741         this_ptr_conv.inner = untag_ptr(this_ptr);
50742         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50744         this_ptr_conv.is_owned = false;
50745         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
50746 }
50747
50748 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) {
50749         LDKPublicKey pubkey_arg_ref;
50750         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
50751         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
50752         LDKNodeFeatures node_features_arg_conv;
50753         node_features_arg_conv.inner = untag_ptr(node_features_arg);
50754         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
50755         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
50756         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
50757         LDKChannelFeatures channel_features_arg_conv;
50758         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
50759         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
50760         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
50761         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
50762         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);
50763         int64_t ret_ref = 0;
50764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50765         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50766         return ret_ref;
50767 }
50768
50769 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
50770         LDKRouteHop ret_var = RouteHop_clone(arg);
50771         int64_t ret_ref = 0;
50772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50773         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50774         return ret_ref;
50775 }
50776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50777         LDKRouteHop arg_conv;
50778         arg_conv.inner = untag_ptr(arg);
50779         arg_conv.is_owned = ptr_is_owned(arg);
50780         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50781         arg_conv.is_owned = false;
50782         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
50783         return ret_conv;
50784 }
50785
50786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50787         LDKRouteHop orig_conv;
50788         orig_conv.inner = untag_ptr(orig);
50789         orig_conv.is_owned = ptr_is_owned(orig);
50790         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50791         orig_conv.is_owned = false;
50792         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
50793         int64_t ret_ref = 0;
50794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50795         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50796         return ret_ref;
50797 }
50798
50799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
50800         LDKRouteHop o_conv;
50801         o_conv.inner = untag_ptr(o);
50802         o_conv.is_owned = ptr_is_owned(o);
50803         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50804         o_conv.is_owned = false;
50805         int64_t ret_conv = RouteHop_hash(&o_conv);
50806         return ret_conv;
50807 }
50808
50809 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50810         LDKRouteHop a_conv;
50811         a_conv.inner = untag_ptr(a);
50812         a_conv.is_owned = ptr_is_owned(a);
50813         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50814         a_conv.is_owned = false;
50815         LDKRouteHop b_conv;
50816         b_conv.inner = untag_ptr(b);
50817         b_conv.is_owned = ptr_is_owned(b);
50818         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50819         b_conv.is_owned = false;
50820         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
50821         return ret_conv;
50822 }
50823
50824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
50825         LDKRouteHop obj_conv;
50826         obj_conv.inner = untag_ptr(obj);
50827         obj_conv.is_owned = ptr_is_owned(obj);
50828         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50829         obj_conv.is_owned = false;
50830         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
50831         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50832         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50833         CVec_u8Z_free(ret_var);
50834         return ret_arr;
50835 }
50836
50837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50838         LDKu8slice ser_ref;
50839         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50840         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50841         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
50842         *ret_conv = RouteHop_read(ser_ref);
50843         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50844         return tag_ptr(ret_conv, true);
50845 }
50846
50847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50848         LDKBlindedTail this_obj_conv;
50849         this_obj_conv.inner = untag_ptr(this_obj);
50850         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50852         BlindedTail_free(this_obj_conv);
50853 }
50854
50855 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1hops(JNIEnv *env, jclass clz, int64_t this_ptr) {
50856         LDKBlindedTail this_ptr_conv;
50857         this_ptr_conv.inner = untag_ptr(this_ptr);
50858         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50860         this_ptr_conv.is_owned = false;
50861         LDKCVec_BlindedHopZ ret_var = BlindedTail_get_hops(&this_ptr_conv);
50862         int64_tArray ret_arr = NULL;
50863         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50864         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50865         for (size_t m = 0; m < ret_var.datalen; m++) {
50866                 LDKBlindedHop ret_conv_12_var = ret_var.data[m];
50867                 int64_t ret_conv_12_ref = 0;
50868                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_var);
50869                 ret_conv_12_ref = tag_ptr(ret_conv_12_var.inner, ret_conv_12_var.is_owned);
50870                 ret_arr_ptr[m] = ret_conv_12_ref;
50871         }
50872         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50873         FREE(ret_var.data);
50874         return ret_arr;
50875 }
50876
50877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1hops(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
50878         LDKBlindedTail this_ptr_conv;
50879         this_ptr_conv.inner = untag_ptr(this_ptr);
50880         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50882         this_ptr_conv.is_owned = false;
50883         LDKCVec_BlindedHopZ val_constr;
50884         val_constr.datalen = (*env)->GetArrayLength(env, val);
50885         if (val_constr.datalen > 0)
50886                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
50887         else
50888                 val_constr.data = NULL;
50889         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
50890         for (size_t m = 0; m < val_constr.datalen; m++) {
50891                 int64_t val_conv_12 = val_vals[m];
50892                 LDKBlindedHop val_conv_12_conv;
50893                 val_conv_12_conv.inner = untag_ptr(val_conv_12);
50894                 val_conv_12_conv.is_owned = ptr_is_owned(val_conv_12);
50895                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv);
50896                 val_conv_12_conv = BlindedHop_clone(&val_conv_12_conv);
50897                 val_constr.data[m] = val_conv_12_conv;
50898         }
50899         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
50900         BlindedTail_set_hops(&this_ptr_conv, val_constr);
50901 }
50902
50903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
50904         LDKBlindedTail this_ptr_conv;
50905         this_ptr_conv.inner = untag_ptr(this_ptr);
50906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50908         this_ptr_conv.is_owned = false;
50909         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50910         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, BlindedTail_get_blinding_point(&this_ptr_conv).compressed_form);
50911         return ret_arr;
50912 }
50913
50914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
50915         LDKBlindedTail this_ptr_conv;
50916         this_ptr_conv.inner = untag_ptr(this_ptr);
50917         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50919         this_ptr_conv.is_owned = false;
50920         LDKPublicKey val_ref;
50921         CHECK((*env)->GetArrayLength(env, val) == 33);
50922         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
50923         BlindedTail_set_blinding_point(&this_ptr_conv, val_ref);
50924 }
50925
50926 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1excess_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
50927         LDKBlindedTail this_ptr_conv;
50928         this_ptr_conv.inner = untag_ptr(this_ptr);
50929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50931         this_ptr_conv.is_owned = false;
50932         int32_t ret_conv = BlindedTail_get_excess_final_cltv_expiry_delta(&this_ptr_conv);
50933         return ret_conv;
50934 }
50935
50936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1excess_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
50937         LDKBlindedTail this_ptr_conv;
50938         this_ptr_conv.inner = untag_ptr(this_ptr);
50939         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50941         this_ptr_conv.is_owned = false;
50942         BlindedTail_set_excess_final_cltv_expiry_delta(&this_ptr_conv, val);
50943 }
50944
50945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50946         LDKBlindedTail this_ptr_conv;
50947         this_ptr_conv.inner = untag_ptr(this_ptr);
50948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50950         this_ptr_conv.is_owned = false;
50951         int64_t ret_conv = BlindedTail_get_final_value_msat(&this_ptr_conv);
50952         return ret_conv;
50953 }
50954
50955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50956         LDKBlindedTail this_ptr_conv;
50957         this_ptr_conv.inner = untag_ptr(this_ptr);
50958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50960         this_ptr_conv.is_owned = false;
50961         BlindedTail_set_final_value_msat(&this_ptr_conv, val);
50962 }
50963
50964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1new(JNIEnv *env, jclass clz, int64_tArray hops_arg, int8_tArray blinding_point_arg, int32_t excess_final_cltv_expiry_delta_arg, int64_t final_value_msat_arg) {
50965         LDKCVec_BlindedHopZ hops_arg_constr;
50966         hops_arg_constr.datalen = (*env)->GetArrayLength(env, hops_arg);
50967         if (hops_arg_constr.datalen > 0)
50968                 hops_arg_constr.data = MALLOC(hops_arg_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
50969         else
50970                 hops_arg_constr.data = NULL;
50971         int64_t* hops_arg_vals = (*env)->GetLongArrayElements (env, hops_arg, NULL);
50972         for (size_t m = 0; m < hops_arg_constr.datalen; m++) {
50973                 int64_t hops_arg_conv_12 = hops_arg_vals[m];
50974                 LDKBlindedHop hops_arg_conv_12_conv;
50975                 hops_arg_conv_12_conv.inner = untag_ptr(hops_arg_conv_12);
50976                 hops_arg_conv_12_conv.is_owned = ptr_is_owned(hops_arg_conv_12);
50977                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_arg_conv_12_conv);
50978                 hops_arg_conv_12_conv = BlindedHop_clone(&hops_arg_conv_12_conv);
50979                 hops_arg_constr.data[m] = hops_arg_conv_12_conv;
50980         }
50981         (*env)->ReleaseLongArrayElements(env, hops_arg, hops_arg_vals, 0);
50982         LDKPublicKey blinding_point_arg_ref;
50983         CHECK((*env)->GetArrayLength(env, blinding_point_arg) == 33);
50984         (*env)->GetByteArrayRegion(env, blinding_point_arg, 0, 33, blinding_point_arg_ref.compressed_form);
50985         LDKBlindedTail ret_var = BlindedTail_new(hops_arg_constr, blinding_point_arg_ref, excess_final_cltv_expiry_delta_arg, final_value_msat_arg);
50986         int64_t ret_ref = 0;
50987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50989         return ret_ref;
50990 }
50991
50992 static inline uint64_t BlindedTail_clone_ptr(LDKBlindedTail *NONNULL_PTR arg) {
50993         LDKBlindedTail ret_var = BlindedTail_clone(arg);
50994         int64_t ret_ref = 0;
50995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50996         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50997         return ret_ref;
50998 }
50999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51000         LDKBlindedTail arg_conv;
51001         arg_conv.inner = untag_ptr(arg);
51002         arg_conv.is_owned = ptr_is_owned(arg);
51003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51004         arg_conv.is_owned = false;
51005         int64_t ret_conv = BlindedTail_clone_ptr(&arg_conv);
51006         return ret_conv;
51007 }
51008
51009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51010         LDKBlindedTail orig_conv;
51011         orig_conv.inner = untag_ptr(orig);
51012         orig_conv.is_owned = ptr_is_owned(orig);
51013         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51014         orig_conv.is_owned = false;
51015         LDKBlindedTail ret_var = BlindedTail_clone(&orig_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 int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1hash(JNIEnv *env, jclass clz, int64_t o) {
51023         LDKBlindedTail o_conv;
51024         o_conv.inner = untag_ptr(o);
51025         o_conv.is_owned = ptr_is_owned(o);
51026         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51027         o_conv.is_owned = false;
51028         int64_t ret_conv = BlindedTail_hash(&o_conv);
51029         return ret_conv;
51030 }
51031
51032 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedTail_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51033         LDKBlindedTail a_conv;
51034         a_conv.inner = untag_ptr(a);
51035         a_conv.is_owned = ptr_is_owned(a);
51036         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51037         a_conv.is_owned = false;
51038         LDKBlindedTail b_conv;
51039         b_conv.inner = untag_ptr(b);
51040         b_conv.is_owned = ptr_is_owned(b);
51041         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51042         b_conv.is_owned = false;
51043         jboolean ret_conv = BlindedTail_eq(&a_conv, &b_conv);
51044         return ret_conv;
51045 }
51046
51047 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedTail_1write(JNIEnv *env, jclass clz, int64_t obj) {
51048         LDKBlindedTail obj_conv;
51049         obj_conv.inner = untag_ptr(obj);
51050         obj_conv.is_owned = ptr_is_owned(obj);
51051         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51052         obj_conv.is_owned = false;
51053         LDKCVec_u8Z ret_var = BlindedTail_write(&obj_conv);
51054         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51055         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51056         CVec_u8Z_free(ret_var);
51057         return ret_arr;
51058 }
51059
51060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51061         LDKu8slice ser_ref;
51062         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51063         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51064         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
51065         *ret_conv = BlindedTail_read(ser_ref);
51066         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51067         return tag_ptr(ret_conv, true);
51068 }
51069
51070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Path_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51071         LDKPath this_obj_conv;
51072         this_obj_conv.inner = untag_ptr(this_obj);
51073         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51075         Path_free(this_obj_conv);
51076 }
51077
51078 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Path_1get_1hops(JNIEnv *env, jclass clz, int64_t this_ptr) {
51079         LDKPath this_ptr_conv;
51080         this_ptr_conv.inner = untag_ptr(this_ptr);
51081         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51083         this_ptr_conv.is_owned = false;
51084         LDKCVec_RouteHopZ ret_var = Path_get_hops(&this_ptr_conv);
51085         int64_tArray ret_arr = NULL;
51086         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
51087         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
51088         for (size_t k = 0; k < ret_var.datalen; k++) {
51089                 LDKRouteHop ret_conv_10_var = ret_var.data[k];
51090                 int64_t ret_conv_10_ref = 0;
51091                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
51092                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
51093                 ret_arr_ptr[k] = ret_conv_10_ref;
51094         }
51095         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
51096         FREE(ret_var.data);
51097         return ret_arr;
51098 }
51099
51100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Path_1set_1hops(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
51101         LDKPath this_ptr_conv;
51102         this_ptr_conv.inner = untag_ptr(this_ptr);
51103         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51105         this_ptr_conv.is_owned = false;
51106         LDKCVec_RouteHopZ val_constr;
51107         val_constr.datalen = (*env)->GetArrayLength(env, val);
51108         if (val_constr.datalen > 0)
51109                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
51110         else
51111                 val_constr.data = NULL;
51112         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
51113         for (size_t k = 0; k < val_constr.datalen; k++) {
51114                 int64_t val_conv_10 = val_vals[k];
51115                 LDKRouteHop val_conv_10_conv;
51116                 val_conv_10_conv.inner = untag_ptr(val_conv_10);
51117                 val_conv_10_conv.is_owned = ptr_is_owned(val_conv_10);
51118                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_10_conv);
51119                 val_conv_10_conv = RouteHop_clone(&val_conv_10_conv);
51120                 val_constr.data[k] = val_conv_10_conv;
51121         }
51122         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
51123         Path_set_hops(&this_ptr_conv, val_constr);
51124 }
51125
51126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1get_1blinded_1tail(JNIEnv *env, jclass clz, int64_t this_ptr) {
51127         LDKPath this_ptr_conv;
51128         this_ptr_conv.inner = untag_ptr(this_ptr);
51129         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51131         this_ptr_conv.is_owned = false;
51132         LDKBlindedTail ret_var = Path_get_blinded_tail(&this_ptr_conv);
51133         int64_t ret_ref = 0;
51134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51135         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51136         return ret_ref;
51137 }
51138
51139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Path_1set_1blinded_1tail(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51140         LDKPath this_ptr_conv;
51141         this_ptr_conv.inner = untag_ptr(this_ptr);
51142         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51144         this_ptr_conv.is_owned = false;
51145         LDKBlindedTail val_conv;
51146         val_conv.inner = untag_ptr(val);
51147         val_conv.is_owned = ptr_is_owned(val);
51148         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51149         val_conv = BlindedTail_clone(&val_conv);
51150         Path_set_blinded_tail(&this_ptr_conv, val_conv);
51151 }
51152
51153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1new(JNIEnv *env, jclass clz, int64_tArray hops_arg, int64_t blinded_tail_arg) {
51154         LDKCVec_RouteHopZ hops_arg_constr;
51155         hops_arg_constr.datalen = (*env)->GetArrayLength(env, hops_arg);
51156         if (hops_arg_constr.datalen > 0)
51157                 hops_arg_constr.data = MALLOC(hops_arg_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
51158         else
51159                 hops_arg_constr.data = NULL;
51160         int64_t* hops_arg_vals = (*env)->GetLongArrayElements (env, hops_arg, NULL);
51161         for (size_t k = 0; k < hops_arg_constr.datalen; k++) {
51162                 int64_t hops_arg_conv_10 = hops_arg_vals[k];
51163                 LDKRouteHop hops_arg_conv_10_conv;
51164                 hops_arg_conv_10_conv.inner = untag_ptr(hops_arg_conv_10);
51165                 hops_arg_conv_10_conv.is_owned = ptr_is_owned(hops_arg_conv_10);
51166                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_arg_conv_10_conv);
51167                 hops_arg_conv_10_conv = RouteHop_clone(&hops_arg_conv_10_conv);
51168                 hops_arg_constr.data[k] = hops_arg_conv_10_conv;
51169         }
51170         (*env)->ReleaseLongArrayElements(env, hops_arg, hops_arg_vals, 0);
51171         LDKBlindedTail blinded_tail_arg_conv;
51172         blinded_tail_arg_conv.inner = untag_ptr(blinded_tail_arg);
51173         blinded_tail_arg_conv.is_owned = ptr_is_owned(blinded_tail_arg);
51174         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_tail_arg_conv);
51175         blinded_tail_arg_conv = BlindedTail_clone(&blinded_tail_arg_conv);
51176         LDKPath ret_var = Path_new(hops_arg_constr, blinded_tail_arg_conv);
51177         int64_t ret_ref = 0;
51178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51179         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51180         return ret_ref;
51181 }
51182
51183 static inline uint64_t Path_clone_ptr(LDKPath *NONNULL_PTR arg) {
51184         LDKPath ret_var = Path_clone(arg);
51185         int64_t ret_ref = 0;
51186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51187         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51188         return ret_ref;
51189 }
51190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51191         LDKPath arg_conv;
51192         arg_conv.inner = untag_ptr(arg);
51193         arg_conv.is_owned = ptr_is_owned(arg);
51194         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51195         arg_conv.is_owned = false;
51196         int64_t ret_conv = Path_clone_ptr(&arg_conv);
51197         return ret_conv;
51198 }
51199
51200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51201         LDKPath orig_conv;
51202         orig_conv.inner = untag_ptr(orig);
51203         orig_conv.is_owned = ptr_is_owned(orig);
51204         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51205         orig_conv.is_owned = false;
51206         LDKPath ret_var = Path_clone(&orig_conv);
51207         int64_t ret_ref = 0;
51208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51209         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51210         return ret_ref;
51211 }
51212
51213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1hash(JNIEnv *env, jclass clz, int64_t o) {
51214         LDKPath o_conv;
51215         o_conv.inner = untag_ptr(o);
51216         o_conv.is_owned = ptr_is_owned(o);
51217         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51218         o_conv.is_owned = false;
51219         int64_t ret_conv = Path_hash(&o_conv);
51220         return ret_conv;
51221 }
51222
51223 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Path_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51224         LDKPath a_conv;
51225         a_conv.inner = untag_ptr(a);
51226         a_conv.is_owned = ptr_is_owned(a);
51227         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51228         a_conv.is_owned = false;
51229         LDKPath b_conv;
51230         b_conv.inner = untag_ptr(b);
51231         b_conv.is_owned = ptr_is_owned(b);
51232         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51233         b_conv.is_owned = false;
51234         jboolean ret_conv = Path_eq(&a_conv, &b_conv);
51235         return ret_conv;
51236 }
51237
51238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
51239         LDKPath this_arg_conv;
51240         this_arg_conv.inner = untag_ptr(this_arg);
51241         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51243         this_arg_conv.is_owned = false;
51244         int64_t ret_conv = Path_fee_msat(&this_arg_conv);
51245         return ret_conv;
51246 }
51247
51248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
51249         LDKPath this_arg_conv;
51250         this_arg_conv.inner = untag_ptr(this_arg);
51251         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51253         this_arg_conv.is_owned = false;
51254         int64_t ret_conv = Path_final_value_msat(&this_arg_conv);
51255         return ret_conv;
51256 }
51257
51258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_arg) {
51259         LDKPath this_arg_conv;
51260         this_arg_conv.inner = untag_ptr(this_arg);
51261         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51263         this_arg_conv.is_owned = false;
51264         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
51265         *ret_copy = Path_final_cltv_expiry_delta(&this_arg_conv);
51266         int64_t ret_ref = tag_ptr(ret_copy, true);
51267         return ret_ref;
51268 }
51269
51270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51271         LDKRoute this_obj_conv;
51272         this_obj_conv.inner = untag_ptr(this_obj);
51273         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51275         Route_free(this_obj_conv);
51276 }
51277
51278 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
51279         LDKRoute this_ptr_conv;
51280         this_ptr_conv.inner = untag_ptr(this_ptr);
51281         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51283         this_ptr_conv.is_owned = false;
51284         LDKCVec_PathZ ret_var = Route_get_paths(&this_ptr_conv);
51285         int64_tArray ret_arr = NULL;
51286         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
51287         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
51288         for (size_t g = 0; g < ret_var.datalen; g++) {
51289                 LDKPath ret_conv_6_var = ret_var.data[g];
51290                 int64_t ret_conv_6_ref = 0;
51291                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_6_var);
51292                 ret_conv_6_ref = tag_ptr(ret_conv_6_var.inner, ret_conv_6_var.is_owned);
51293                 ret_arr_ptr[g] = ret_conv_6_ref;
51294         }
51295         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
51296         FREE(ret_var.data);
51297         return ret_arr;
51298 }
51299
51300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
51301         LDKRoute this_ptr_conv;
51302         this_ptr_conv.inner = untag_ptr(this_ptr);
51303         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51305         this_ptr_conv.is_owned = false;
51306         LDKCVec_PathZ val_constr;
51307         val_constr.datalen = (*env)->GetArrayLength(env, val);
51308         if (val_constr.datalen > 0)
51309                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
51310         else
51311                 val_constr.data = NULL;
51312         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
51313         for (size_t g = 0; g < val_constr.datalen; g++) {
51314                 int64_t val_conv_6 = val_vals[g];
51315                 LDKPath val_conv_6_conv;
51316                 val_conv_6_conv.inner = untag_ptr(val_conv_6);
51317                 val_conv_6_conv.is_owned = ptr_is_owned(val_conv_6);
51318                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_6_conv);
51319                 val_conv_6_conv = Path_clone(&val_conv_6_conv);
51320                 val_constr.data[g] = val_conv_6_conv;
51321         }
51322         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
51323         Route_set_paths(&this_ptr_conv, val_constr);
51324 }
51325
51326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
51327         LDKRoute 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         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
51333         int64_t ret_ref = 0;
51334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51335         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51336         return ret_ref;
51337 }
51338
51339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51340         LDKRoute this_ptr_conv;
51341         this_ptr_conv.inner = untag_ptr(this_ptr);
51342         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51344         this_ptr_conv.is_owned = false;
51345         LDKPaymentParameters val_conv;
51346         val_conv.inner = untag_ptr(val);
51347         val_conv.is_owned = ptr_is_owned(val);
51348         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51349         val_conv = PaymentParameters_clone(&val_conv);
51350         Route_set_payment_params(&this_ptr_conv, val_conv);
51351 }
51352
51353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, int64_tArray paths_arg, int64_t payment_params_arg) {
51354         LDKCVec_PathZ paths_arg_constr;
51355         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
51356         if (paths_arg_constr.datalen > 0)
51357                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
51358         else
51359                 paths_arg_constr.data = NULL;
51360         int64_t* paths_arg_vals = (*env)->GetLongArrayElements (env, paths_arg, NULL);
51361         for (size_t g = 0; g < paths_arg_constr.datalen; g++) {
51362                 int64_t paths_arg_conv_6 = paths_arg_vals[g];
51363                 LDKPath paths_arg_conv_6_conv;
51364                 paths_arg_conv_6_conv.inner = untag_ptr(paths_arg_conv_6);
51365                 paths_arg_conv_6_conv.is_owned = ptr_is_owned(paths_arg_conv_6);
51366                 CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_6_conv);
51367                 paths_arg_conv_6_conv = Path_clone(&paths_arg_conv_6_conv);
51368                 paths_arg_constr.data[g] = paths_arg_conv_6_conv;
51369         }
51370         (*env)->ReleaseLongArrayElements(env, paths_arg, paths_arg_vals, 0);
51371         LDKPaymentParameters payment_params_arg_conv;
51372         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
51373         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
51374         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
51375         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
51376         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
51377         int64_t ret_ref = 0;
51378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51379         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51380         return ret_ref;
51381 }
51382
51383 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
51384         LDKRoute ret_var = Route_clone(arg);
51385         int64_t ret_ref = 0;
51386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51387         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51388         return ret_ref;
51389 }
51390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51391         LDKRoute arg_conv;
51392         arg_conv.inner = untag_ptr(arg);
51393         arg_conv.is_owned = ptr_is_owned(arg);
51394         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51395         arg_conv.is_owned = false;
51396         int64_t ret_conv = Route_clone_ptr(&arg_conv);
51397         return ret_conv;
51398 }
51399
51400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51401         LDKRoute orig_conv;
51402         orig_conv.inner = untag_ptr(orig);
51403         orig_conv.is_owned = ptr_is_owned(orig);
51404         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51405         orig_conv.is_owned = false;
51406         LDKRoute ret_var = Route_clone(&orig_conv);
51407         int64_t ret_ref = 0;
51408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51409         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51410         return ret_ref;
51411 }
51412
51413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
51414         LDKRoute o_conv;
51415         o_conv.inner = untag_ptr(o);
51416         o_conv.is_owned = ptr_is_owned(o);
51417         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51418         o_conv.is_owned = false;
51419         int64_t ret_conv = Route_hash(&o_conv);
51420         return ret_conv;
51421 }
51422
51423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51424         LDKRoute a_conv;
51425         a_conv.inner = untag_ptr(a);
51426         a_conv.is_owned = ptr_is_owned(a);
51427         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51428         a_conv.is_owned = false;
51429         LDKRoute b_conv;
51430         b_conv.inner = untag_ptr(b);
51431         b_conv.is_owned = ptr_is_owned(b);
51432         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51433         b_conv.is_owned = false;
51434         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
51435         return ret_conv;
51436 }
51437
51438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
51439         LDKRoute this_arg_conv;
51440         this_arg_conv.inner = untag_ptr(this_arg);
51441         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51443         this_arg_conv.is_owned = false;
51444         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
51445         return ret_conv;
51446 }
51447
51448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
51449         LDKRoute this_arg_conv;
51450         this_arg_conv.inner = untag_ptr(this_arg);
51451         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51453         this_arg_conv.is_owned = false;
51454         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
51455         return ret_conv;
51456 }
51457
51458 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
51459         LDKRoute obj_conv;
51460         obj_conv.inner = untag_ptr(obj);
51461         obj_conv.is_owned = ptr_is_owned(obj);
51462         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51463         obj_conv.is_owned = false;
51464         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
51465         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51466         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51467         CVec_u8Z_free(ret_var);
51468         return ret_arr;
51469 }
51470
51471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51472         LDKu8slice ser_ref;
51473         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51474         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51475         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
51476         *ret_conv = Route_read(ser_ref);
51477         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51478         return tag_ptr(ret_conv, true);
51479 }
51480
51481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51482         LDKRouteParameters this_obj_conv;
51483         this_obj_conv.inner = untag_ptr(this_obj);
51484         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51486         RouteParameters_free(this_obj_conv);
51487 }
51488
51489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
51490         LDKRouteParameters this_ptr_conv;
51491         this_ptr_conv.inner = untag_ptr(this_ptr);
51492         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51494         this_ptr_conv.is_owned = false;
51495         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
51496         int64_t ret_ref = 0;
51497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51498         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51499         return ret_ref;
51500 }
51501
51502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51503         LDKRouteParameters this_ptr_conv;
51504         this_ptr_conv.inner = untag_ptr(this_ptr);
51505         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51507         this_ptr_conv.is_owned = false;
51508         LDKPaymentParameters val_conv;
51509         val_conv.inner = untag_ptr(val);
51510         val_conv.is_owned = ptr_is_owned(val);
51511         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51512         val_conv = PaymentParameters_clone(&val_conv);
51513         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
51514 }
51515
51516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
51517         LDKRouteParameters this_ptr_conv;
51518         this_ptr_conv.inner = untag_ptr(this_ptr);
51519         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51521         this_ptr_conv.is_owned = false;
51522         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
51523         return ret_conv;
51524 }
51525
51526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51527         LDKRouteParameters this_ptr_conv;
51528         this_ptr_conv.inner = untag_ptr(this_ptr);
51529         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51531         this_ptr_conv.is_owned = false;
51532         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
51533 }
51534
51535 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) {
51536         LDKPaymentParameters payment_params_arg_conv;
51537         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
51538         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
51539         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
51540         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
51541         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg);
51542         int64_t ret_ref = 0;
51543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51544         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51545         return ret_ref;
51546 }
51547
51548 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
51549         LDKRouteParameters ret_var = RouteParameters_clone(arg);
51550         int64_t ret_ref = 0;
51551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51552         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51553         return ret_ref;
51554 }
51555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51556         LDKRouteParameters arg_conv;
51557         arg_conv.inner = untag_ptr(arg);
51558         arg_conv.is_owned = ptr_is_owned(arg);
51559         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51560         arg_conv.is_owned = false;
51561         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
51562         return ret_conv;
51563 }
51564
51565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51566         LDKRouteParameters orig_conv;
51567         orig_conv.inner = untag_ptr(orig);
51568         orig_conv.is_owned = ptr_is_owned(orig);
51569         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51570         orig_conv.is_owned = false;
51571         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
51572         int64_t ret_ref = 0;
51573         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51574         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51575         return ret_ref;
51576 }
51577
51578 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51579         LDKRouteParameters a_conv;
51580         a_conv.inner = untag_ptr(a);
51581         a_conv.is_owned = ptr_is_owned(a);
51582         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51583         a_conv.is_owned = false;
51584         LDKRouteParameters b_conv;
51585         b_conv.inner = untag_ptr(b);
51586         b_conv.is_owned = ptr_is_owned(b);
51587         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51588         b_conv.is_owned = false;
51589         jboolean ret_conv = RouteParameters_eq(&a_conv, &b_conv);
51590         return ret_conv;
51591 }
51592
51593 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
51594         LDKRouteParameters obj_conv;
51595         obj_conv.inner = untag_ptr(obj);
51596         obj_conv.is_owned = ptr_is_owned(obj);
51597         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51598         obj_conv.is_owned = false;
51599         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
51600         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51601         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51602         CVec_u8Z_free(ret_var);
51603         return ret_arr;
51604 }
51605
51606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51607         LDKu8slice ser_ref;
51608         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51609         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51610         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
51611         *ret_conv = RouteParameters_read(ser_ref);
51612         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51613         return tag_ptr(ret_conv, true);
51614 }
51615
51616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51617         LDKPaymentParameters this_obj_conv;
51618         this_obj_conv.inner = untag_ptr(this_obj);
51619         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51621         PaymentParameters_free(this_obj_conv);
51622 }
51623
51624 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
51625         LDKPaymentParameters this_ptr_conv;
51626         this_ptr_conv.inner = untag_ptr(this_ptr);
51627         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51629         this_ptr_conv.is_owned = false;
51630         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
51631         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
51632         return ret_arr;
51633 }
51634
51635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
51636         LDKPaymentParameters this_ptr_conv;
51637         this_ptr_conv.inner = untag_ptr(this_ptr);
51638         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51640         this_ptr_conv.is_owned = false;
51641         LDKPublicKey val_ref;
51642         CHECK((*env)->GetArrayLength(env, val) == 33);
51643         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
51644         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
51645 }
51646
51647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
51648         LDKPaymentParameters this_ptr_conv;
51649         this_ptr_conv.inner = untag_ptr(this_ptr);
51650         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51652         this_ptr_conv.is_owned = false;
51653         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
51654         int64_t ret_ref = 0;
51655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51656         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51657         return ret_ref;
51658 }
51659
51660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51661         LDKPaymentParameters this_ptr_conv;
51662         this_ptr_conv.inner = untag_ptr(this_ptr);
51663         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51665         this_ptr_conv.is_owned = false;
51666         LDKInvoiceFeatures val_conv;
51667         val_conv.inner = untag_ptr(val);
51668         val_conv.is_owned = ptr_is_owned(val);
51669         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51670         val_conv = InvoiceFeatures_clone(&val_conv);
51671         PaymentParameters_set_features(&this_ptr_conv, val_conv);
51672 }
51673
51674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
51675         LDKPaymentParameters this_ptr_conv;
51676         this_ptr_conv.inner = untag_ptr(this_ptr);
51677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51679         this_ptr_conv.is_owned = false;
51680         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
51681         *ret_copy = PaymentParameters_get_route_hints(&this_ptr_conv);
51682         int64_t ret_ref = tag_ptr(ret_copy, true);
51683         return ret_ref;
51684 }
51685
51686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51687         LDKPaymentParameters this_ptr_conv;
51688         this_ptr_conv.inner = untag_ptr(this_ptr);
51689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51691         this_ptr_conv.is_owned = false;
51692         void* val_ptr = untag_ptr(val);
51693         CHECK_ACCESS(val_ptr);
51694         LDKHints val_conv = *(LDKHints*)(val_ptr);
51695         val_conv = Hints_clone((LDKHints*)untag_ptr(val));
51696         PaymentParameters_set_route_hints(&this_ptr_conv, val_conv);
51697 }
51698
51699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
51700         LDKPaymentParameters this_ptr_conv;
51701         this_ptr_conv.inner = untag_ptr(this_ptr);
51702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51704         this_ptr_conv.is_owned = false;
51705         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
51706         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
51707         int64_t ret_ref = tag_ptr(ret_copy, true);
51708         return ret_ref;
51709 }
51710
51711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51712         LDKPaymentParameters this_ptr_conv;
51713         this_ptr_conv.inner = untag_ptr(this_ptr);
51714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51716         this_ptr_conv.is_owned = false;
51717         void* val_ptr = untag_ptr(val);
51718         CHECK_ACCESS(val_ptr);
51719         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
51720         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
51721         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
51722 }
51723
51724 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
51725         LDKPaymentParameters this_ptr_conv;
51726         this_ptr_conv.inner = untag_ptr(this_ptr);
51727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51729         this_ptr_conv.is_owned = false;
51730         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
51731         return ret_conv;
51732 }
51733
51734 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) {
51735         LDKPaymentParameters this_ptr_conv;
51736         this_ptr_conv.inner = untag_ptr(this_ptr);
51737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51739         this_ptr_conv.is_owned = false;
51740         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
51741 }
51742
51743 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
51744         LDKPaymentParameters this_ptr_conv;
51745         this_ptr_conv.inner = untag_ptr(this_ptr);
51746         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51748         this_ptr_conv.is_owned = false;
51749         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
51750         return ret_conv;
51751 }
51752
51753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
51754         LDKPaymentParameters this_ptr_conv;
51755         this_ptr_conv.inner = untag_ptr(this_ptr);
51756         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51758         this_ptr_conv.is_owned = false;
51759         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
51760 }
51761
51762 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) {
51763         LDKPaymentParameters this_ptr_conv;
51764         this_ptr_conv.inner = untag_ptr(this_ptr);
51765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51767         this_ptr_conv.is_owned = false;
51768         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
51769         return ret_conv;
51770 }
51771
51772 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) {
51773         LDKPaymentParameters this_ptr_conv;
51774         this_ptr_conv.inner = untag_ptr(this_ptr);
51775         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51777         this_ptr_conv.is_owned = false;
51778         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
51779 }
51780
51781 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
51782         LDKPaymentParameters this_ptr_conv;
51783         this_ptr_conv.inner = untag_ptr(this_ptr);
51784         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51786         this_ptr_conv.is_owned = false;
51787         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
51788         int64_tArray ret_arr = NULL;
51789         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
51790         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
51791         for (size_t g = 0; g < ret_var.datalen; g++) {
51792                 int64_t ret_conv_6_conv = ret_var.data[g];
51793                 ret_arr_ptr[g] = ret_conv_6_conv;
51794         }
51795         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
51796         FREE(ret_var.data);
51797         return ret_arr;
51798 }
51799
51800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
51801         LDKPaymentParameters this_ptr_conv;
51802         this_ptr_conv.inner = untag_ptr(this_ptr);
51803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51805         this_ptr_conv.is_owned = false;
51806         LDKCVec_u64Z val_constr;
51807         val_constr.datalen = (*env)->GetArrayLength(env, val);
51808         if (val_constr.datalen > 0)
51809                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
51810         else
51811                 val_constr.data = NULL;
51812         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
51813         for (size_t g = 0; g < val_constr.datalen; g++) {
51814                 int64_t val_conv_6 = val_vals[g];
51815                 val_constr.data[g] = val_conv_6;
51816         }
51817         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
51818         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
51819 }
51820
51821 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
51822         LDKPaymentParameters this_ptr_conv;
51823         this_ptr_conv.inner = untag_ptr(this_ptr);
51824         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51826         this_ptr_conv.is_owned = false;
51827         int32_t ret_conv = PaymentParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
51828         return ret_conv;
51829 }
51830
51831 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) {
51832         LDKPaymentParameters this_ptr_conv;
51833         this_ptr_conv.inner = untag_ptr(this_ptr);
51834         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51836         this_ptr_conv.is_owned = false;
51837         PaymentParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
51838 }
51839
51840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1new(JNIEnv *env, jclass clz, int8_tArray payee_pubkey_arg, int64_t features_arg, int64_t route_hints_arg, int64_t expiry_time_arg, int32_t max_total_cltv_expiry_delta_arg, int8_t max_path_count_arg, int8_t max_channel_saturation_power_of_half_arg, int64_tArray previously_failed_channels_arg, int32_t final_cltv_expiry_delta_arg) {
51841         LDKPublicKey payee_pubkey_arg_ref;
51842         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
51843         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
51844         LDKInvoiceFeatures features_arg_conv;
51845         features_arg_conv.inner = untag_ptr(features_arg);
51846         features_arg_conv.is_owned = ptr_is_owned(features_arg);
51847         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
51848         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
51849         void* route_hints_arg_ptr = untag_ptr(route_hints_arg);
51850         CHECK_ACCESS(route_hints_arg_ptr);
51851         LDKHints route_hints_arg_conv = *(LDKHints*)(route_hints_arg_ptr);
51852         route_hints_arg_conv = Hints_clone((LDKHints*)untag_ptr(route_hints_arg));
51853         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
51854         CHECK_ACCESS(expiry_time_arg_ptr);
51855         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
51856         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
51857         LDKCVec_u64Z previously_failed_channels_arg_constr;
51858         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
51859         if (previously_failed_channels_arg_constr.datalen > 0)
51860                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
51861         else
51862                 previously_failed_channels_arg_constr.data = NULL;
51863         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
51864         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
51865                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
51866                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
51867         }
51868         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
51869         LDKPaymentParameters ret_var = PaymentParameters_new(payee_pubkey_arg_ref, features_arg_conv, route_hints_arg_conv, expiry_time_arg_conv, max_total_cltv_expiry_delta_arg, max_path_count_arg, max_channel_saturation_power_of_half_arg, previously_failed_channels_arg_constr, final_cltv_expiry_delta_arg);
51870         int64_t ret_ref = 0;
51871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51872         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51873         return ret_ref;
51874 }
51875
51876 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
51877         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
51878         int64_t ret_ref = 0;
51879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51880         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51881         return ret_ref;
51882 }
51883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51884         LDKPaymentParameters arg_conv;
51885         arg_conv.inner = untag_ptr(arg);
51886         arg_conv.is_owned = ptr_is_owned(arg);
51887         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51888         arg_conv.is_owned = false;
51889         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
51890         return ret_conv;
51891 }
51892
51893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51894         LDKPaymentParameters orig_conv;
51895         orig_conv.inner = untag_ptr(orig);
51896         orig_conv.is_owned = ptr_is_owned(orig);
51897         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51898         orig_conv.is_owned = false;
51899         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
51900         int64_t ret_ref = 0;
51901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51902         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51903         return ret_ref;
51904 }
51905
51906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
51907         LDKPaymentParameters o_conv;
51908         o_conv.inner = untag_ptr(o);
51909         o_conv.is_owned = ptr_is_owned(o);
51910         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51911         o_conv.is_owned = false;
51912         int64_t ret_conv = PaymentParameters_hash(&o_conv);
51913         return ret_conv;
51914 }
51915
51916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51917         LDKPaymentParameters a_conv;
51918         a_conv.inner = untag_ptr(a);
51919         a_conv.is_owned = ptr_is_owned(a);
51920         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51921         a_conv.is_owned = false;
51922         LDKPaymentParameters b_conv;
51923         b_conv.inner = untag_ptr(b);
51924         b_conv.is_owned = ptr_is_owned(b);
51925         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51926         b_conv.is_owned = false;
51927         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
51928         return ret_conv;
51929 }
51930
51931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
51932         LDKPaymentParameters obj_conv;
51933         obj_conv.inner = untag_ptr(obj);
51934         obj_conv.is_owned = ptr_is_owned(obj);
51935         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51936         obj_conv.is_owned = false;
51937         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
51938         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51939         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51940         CVec_u8Z_free(ret_var);
51941         return ret_arr;
51942 }
51943
51944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser, int32_t arg) {
51945         LDKu8slice ser_ref;
51946         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51947         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51948         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
51949         *ret_conv = PaymentParameters_read(ser_ref, arg);
51950         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51951         return tag_ptr(ret_conv, true);
51952 }
51953
51954 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) {
51955         LDKPublicKey payee_pubkey_ref;
51956         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
51957         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
51958         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref, final_cltv_expiry_delta);
51959         int64_t ret_ref = 0;
51960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51961         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51962         return ret_ref;
51963 }
51964
51965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey, int32_t final_cltv_expiry_delta) {
51966         LDKPublicKey payee_pubkey_ref;
51967         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
51968         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
51969         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref, final_cltv_expiry_delta);
51970         int64_t ret_ref = 0;
51971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51972         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51973         return ret_ref;
51974 }
51975
51976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hints_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51977         if (!ptr_is_owned(this_ptr)) return;
51978         void* this_ptr_ptr = untag_ptr(this_ptr);
51979         CHECK_ACCESS(this_ptr_ptr);
51980         LDKHints this_ptr_conv = *(LDKHints*)(this_ptr_ptr);
51981         FREE(untag_ptr(this_ptr));
51982         Hints_free(this_ptr_conv);
51983 }
51984
51985 static inline uint64_t Hints_clone_ptr(LDKHints *NONNULL_PTR arg) {
51986         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
51987         *ret_copy = Hints_clone(arg);
51988         int64_t ret_ref = tag_ptr(ret_copy, true);
51989         return ret_ref;
51990 }
51991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51992         LDKHints* arg_conv = (LDKHints*)untag_ptr(arg);
51993         int64_t ret_conv = Hints_clone_ptr(arg_conv);
51994         return ret_conv;
51995 }
51996
51997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51998         LDKHints* orig_conv = (LDKHints*)untag_ptr(orig);
51999         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
52000         *ret_copy = Hints_clone(orig_conv);
52001         int64_t ret_ref = tag_ptr(ret_copy, true);
52002         return ret_ref;
52003 }
52004
52005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1blinded(JNIEnv *env, jclass clz, int64_tArray a) {
52006         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ a_constr;
52007         a_constr.datalen = (*env)->GetArrayLength(env, a);
52008         if (a_constr.datalen > 0)
52009                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ Elements");
52010         else
52011                 a_constr.data = NULL;
52012         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
52013         for (size_t l = 0; l < a_constr.datalen; l++) {
52014                 int64_t a_conv_37 = a_vals[l];
52015                 void* a_conv_37_ptr = untag_ptr(a_conv_37);
52016                 CHECK_ACCESS(a_conv_37_ptr);
52017                 LDKC2Tuple_BlindedPayInfoBlindedPathZ a_conv_37_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(a_conv_37_ptr);
52018                 a_conv_37_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone((LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(a_conv_37));
52019                 a_constr.data[l] = a_conv_37_conv;
52020         }
52021         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
52022         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
52023         *ret_copy = Hints_blinded(a_constr);
52024         int64_t ret_ref = tag_ptr(ret_copy, true);
52025         return ret_ref;
52026 }
52027
52028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1clear(JNIEnv *env, jclass clz, int64_tArray a) {
52029         LDKCVec_RouteHintZ a_constr;
52030         a_constr.datalen = (*env)->GetArrayLength(env, a);
52031         if (a_constr.datalen > 0)
52032                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
52033         else
52034                 a_constr.data = NULL;
52035         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
52036         for (size_t l = 0; l < a_constr.datalen; l++) {
52037                 int64_t a_conv_11 = a_vals[l];
52038                 LDKRouteHint a_conv_11_conv;
52039                 a_conv_11_conv.inner = untag_ptr(a_conv_11);
52040                 a_conv_11_conv.is_owned = ptr_is_owned(a_conv_11);
52041                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv_11_conv);
52042                 a_conv_11_conv = RouteHint_clone(&a_conv_11_conv);
52043                 a_constr.data[l] = a_conv_11_conv;
52044         }
52045         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
52046         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
52047         *ret_copy = Hints_clear(a_constr);
52048         int64_t ret_ref = tag_ptr(ret_copy, true);
52049         return ret_ref;
52050 }
52051
52052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1hash(JNIEnv *env, jclass clz, int64_t o) {
52053         LDKHints* o_conv = (LDKHints*)untag_ptr(o);
52054         int64_t ret_conv = Hints_hash(o_conv);
52055         return ret_conv;
52056 }
52057
52058 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Hints_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52059         LDKHints* a_conv = (LDKHints*)untag_ptr(a);
52060         LDKHints* b_conv = (LDKHints*)untag_ptr(b);
52061         jboolean ret_conv = Hints_eq(a_conv, b_conv);
52062         return ret_conv;
52063 }
52064
52065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52066         LDKRouteHint this_obj_conv;
52067         this_obj_conv.inner = untag_ptr(this_obj);
52068         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52070         RouteHint_free(this_obj_conv);
52071 }
52072
52073 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
52074         LDKRouteHint this_ptr_conv;
52075         this_ptr_conv.inner = untag_ptr(this_ptr);
52076         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52078         this_ptr_conv.is_owned = false;
52079         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
52080         int64_tArray ret_arr = NULL;
52081         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
52082         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
52083         for (size_t o = 0; o < ret_var.datalen; o++) {
52084                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
52085                 int64_t ret_conv_14_ref = 0;
52086                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
52087                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
52088                 ret_arr_ptr[o] = ret_conv_14_ref;
52089         }
52090         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
52091         FREE(ret_var.data);
52092         return ret_arr;
52093 }
52094
52095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
52096         LDKRouteHint this_ptr_conv;
52097         this_ptr_conv.inner = untag_ptr(this_ptr);
52098         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52100         this_ptr_conv.is_owned = false;
52101         LDKCVec_RouteHintHopZ val_constr;
52102         val_constr.datalen = (*env)->GetArrayLength(env, val);
52103         if (val_constr.datalen > 0)
52104                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
52105         else
52106                 val_constr.data = NULL;
52107         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
52108         for (size_t o = 0; o < val_constr.datalen; o++) {
52109                 int64_t val_conv_14 = val_vals[o];
52110                 LDKRouteHintHop val_conv_14_conv;
52111                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
52112                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
52113                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
52114                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
52115                 val_constr.data[o] = val_conv_14_conv;
52116         }
52117         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
52118         RouteHint_set_a(&this_ptr_conv, val_constr);
52119 }
52120
52121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
52122         LDKCVec_RouteHintHopZ a_arg_constr;
52123         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
52124         if (a_arg_constr.datalen > 0)
52125                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
52126         else
52127                 a_arg_constr.data = NULL;
52128         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
52129         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
52130                 int64_t a_arg_conv_14 = a_arg_vals[o];
52131                 LDKRouteHintHop a_arg_conv_14_conv;
52132                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
52133                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
52134                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
52135                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
52136                 a_arg_constr.data[o] = a_arg_conv_14_conv;
52137         }
52138         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
52139         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
52140         int64_t ret_ref = 0;
52141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52142         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52143         return ret_ref;
52144 }
52145
52146 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
52147         LDKRouteHint ret_var = RouteHint_clone(arg);
52148         int64_t ret_ref = 0;
52149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52150         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52151         return ret_ref;
52152 }
52153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52154         LDKRouteHint arg_conv;
52155         arg_conv.inner = untag_ptr(arg);
52156         arg_conv.is_owned = ptr_is_owned(arg);
52157         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52158         arg_conv.is_owned = false;
52159         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
52160         return ret_conv;
52161 }
52162
52163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52164         LDKRouteHint orig_conv;
52165         orig_conv.inner = untag_ptr(orig);
52166         orig_conv.is_owned = ptr_is_owned(orig);
52167         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52168         orig_conv.is_owned = false;
52169         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
52170         int64_t ret_ref = 0;
52171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52172         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52173         return ret_ref;
52174 }
52175
52176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
52177         LDKRouteHint o_conv;
52178         o_conv.inner = untag_ptr(o);
52179         o_conv.is_owned = ptr_is_owned(o);
52180         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52181         o_conv.is_owned = false;
52182         int64_t ret_conv = RouteHint_hash(&o_conv);
52183         return ret_conv;
52184 }
52185
52186 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52187         LDKRouteHint a_conv;
52188         a_conv.inner = untag_ptr(a);
52189         a_conv.is_owned = ptr_is_owned(a);
52190         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52191         a_conv.is_owned = false;
52192         LDKRouteHint b_conv;
52193         b_conv.inner = untag_ptr(b);
52194         b_conv.is_owned = ptr_is_owned(b);
52195         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52196         b_conv.is_owned = false;
52197         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
52198         return ret_conv;
52199 }
52200
52201 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
52202         LDKRouteHint obj_conv;
52203         obj_conv.inner = untag_ptr(obj);
52204         obj_conv.is_owned = ptr_is_owned(obj);
52205         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52206         obj_conv.is_owned = false;
52207         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
52208         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52209         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52210         CVec_u8Z_free(ret_var);
52211         return ret_arr;
52212 }
52213
52214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
52215         LDKu8slice ser_ref;
52216         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
52217         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
52218         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
52219         *ret_conv = RouteHint_read(ser_ref);
52220         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
52221         return tag_ptr(ret_conv, true);
52222 }
52223
52224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52225         LDKRouteHintHop this_obj_conv;
52226         this_obj_conv.inner = untag_ptr(this_obj);
52227         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52229         RouteHintHop_free(this_obj_conv);
52230 }
52231
52232 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
52233         LDKRouteHintHop this_ptr_conv;
52234         this_ptr_conv.inner = untag_ptr(this_ptr);
52235         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52237         this_ptr_conv.is_owned = false;
52238         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
52239         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
52240         return ret_arr;
52241 }
52242
52243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
52244         LDKRouteHintHop this_ptr_conv;
52245         this_ptr_conv.inner = untag_ptr(this_ptr);
52246         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52248         this_ptr_conv.is_owned = false;
52249         LDKPublicKey val_ref;
52250         CHECK((*env)->GetArrayLength(env, val) == 33);
52251         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
52252         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
52253 }
52254
52255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
52256         LDKRouteHintHop this_ptr_conv;
52257         this_ptr_conv.inner = untag_ptr(this_ptr);
52258         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52260         this_ptr_conv.is_owned = false;
52261         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
52262         return ret_conv;
52263 }
52264
52265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52266         LDKRouteHintHop this_ptr_conv;
52267         this_ptr_conv.inner = untag_ptr(this_ptr);
52268         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52270         this_ptr_conv.is_owned = false;
52271         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
52272 }
52273
52274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
52275         LDKRouteHintHop this_ptr_conv;
52276         this_ptr_conv.inner = untag_ptr(this_ptr);
52277         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52279         this_ptr_conv.is_owned = false;
52280         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
52281         int64_t ret_ref = 0;
52282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52283         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52284         return ret_ref;
52285 }
52286
52287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52288         LDKRouteHintHop this_ptr_conv;
52289         this_ptr_conv.inner = untag_ptr(this_ptr);
52290         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52292         this_ptr_conv.is_owned = false;
52293         LDKRoutingFees val_conv;
52294         val_conv.inner = untag_ptr(val);
52295         val_conv.is_owned = ptr_is_owned(val);
52296         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
52297         val_conv = RoutingFees_clone(&val_conv);
52298         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
52299 }
52300
52301 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
52302         LDKRouteHintHop this_ptr_conv;
52303         this_ptr_conv.inner = untag_ptr(this_ptr);
52304         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52306         this_ptr_conv.is_owned = false;
52307         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
52308         return ret_conv;
52309 }
52310
52311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
52312         LDKRouteHintHop this_ptr_conv;
52313         this_ptr_conv.inner = untag_ptr(this_ptr);
52314         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52316         this_ptr_conv.is_owned = false;
52317         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
52318 }
52319
52320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52321         LDKRouteHintHop this_ptr_conv;
52322         this_ptr_conv.inner = untag_ptr(this_ptr);
52323         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52325         this_ptr_conv.is_owned = false;
52326         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
52327         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
52328         int64_t ret_ref = tag_ptr(ret_copy, true);
52329         return ret_ref;
52330 }
52331
52332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52333         LDKRouteHintHop this_ptr_conv;
52334         this_ptr_conv.inner = untag_ptr(this_ptr);
52335         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52337         this_ptr_conv.is_owned = false;
52338         void* val_ptr = untag_ptr(val);
52339         CHECK_ACCESS(val_ptr);
52340         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
52341         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
52342         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
52343 }
52344
52345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52346         LDKRouteHintHop this_ptr_conv;
52347         this_ptr_conv.inner = untag_ptr(this_ptr);
52348         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52350         this_ptr_conv.is_owned = false;
52351         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
52352         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
52353         int64_t ret_ref = tag_ptr(ret_copy, true);
52354         return ret_ref;
52355 }
52356
52357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52358         LDKRouteHintHop this_ptr_conv;
52359         this_ptr_conv.inner = untag_ptr(this_ptr);
52360         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52362         this_ptr_conv.is_owned = false;
52363         void* val_ptr = untag_ptr(val);
52364         CHECK_ACCESS(val_ptr);
52365         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
52366         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
52367         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
52368 }
52369
52370 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) {
52371         LDKPublicKey src_node_id_arg_ref;
52372         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
52373         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
52374         LDKRoutingFees fees_arg_conv;
52375         fees_arg_conv.inner = untag_ptr(fees_arg);
52376         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
52377         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
52378         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
52379         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
52380         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
52381         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
52382         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
52383         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
52384         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
52385         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
52386         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
52387         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);
52388         int64_t ret_ref = 0;
52389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52390         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52391         return ret_ref;
52392 }
52393
52394 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
52395         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
52396         int64_t ret_ref = 0;
52397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52398         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52399         return ret_ref;
52400 }
52401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52402         LDKRouteHintHop arg_conv;
52403         arg_conv.inner = untag_ptr(arg);
52404         arg_conv.is_owned = ptr_is_owned(arg);
52405         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52406         arg_conv.is_owned = false;
52407         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
52408         return ret_conv;
52409 }
52410
52411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52412         LDKRouteHintHop orig_conv;
52413         orig_conv.inner = untag_ptr(orig);
52414         orig_conv.is_owned = ptr_is_owned(orig);
52415         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52416         orig_conv.is_owned = false;
52417         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
52418         int64_t ret_ref = 0;
52419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52420         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52421         return ret_ref;
52422 }
52423
52424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
52425         LDKRouteHintHop o_conv;
52426         o_conv.inner = untag_ptr(o);
52427         o_conv.is_owned = ptr_is_owned(o);
52428         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52429         o_conv.is_owned = false;
52430         int64_t ret_conv = RouteHintHop_hash(&o_conv);
52431         return ret_conv;
52432 }
52433
52434 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52435         LDKRouteHintHop a_conv;
52436         a_conv.inner = untag_ptr(a);
52437         a_conv.is_owned = ptr_is_owned(a);
52438         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52439         a_conv.is_owned = false;
52440         LDKRouteHintHop b_conv;
52441         b_conv.inner = untag_ptr(b);
52442         b_conv.is_owned = ptr_is_owned(b);
52443         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52444         b_conv.is_owned = false;
52445         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
52446         return ret_conv;
52447 }
52448
52449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
52450         LDKRouteHintHop obj_conv;
52451         obj_conv.inner = untag_ptr(obj);
52452         obj_conv.is_owned = ptr_is_owned(obj);
52453         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52454         obj_conv.is_owned = false;
52455         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
52456         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52457         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52458         CVec_u8Z_free(ret_var);
52459         return ret_arr;
52460 }
52461
52462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
52463         LDKu8slice ser_ref;
52464         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
52465         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
52466         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
52467         *ret_conv = RouteHintHop_read(ser_ref);
52468         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
52469         return tag_ptr(ret_conv, true);
52470 }
52471
52472 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) {
52473         LDKPublicKey our_node_pubkey_ref;
52474         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
52475         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
52476         LDKRouteParameters route_params_conv;
52477         route_params_conv.inner = untag_ptr(route_params);
52478         route_params_conv.is_owned = ptr_is_owned(route_params);
52479         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
52480         route_params_conv.is_owned = false;
52481         LDKNetworkGraph network_graph_conv;
52482         network_graph_conv.inner = untag_ptr(network_graph);
52483         network_graph_conv.is_owned = ptr_is_owned(network_graph);
52484         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
52485         network_graph_conv.is_owned = false;
52486         LDKCVec_ChannelDetailsZ first_hops_constr;
52487         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
52488         if (first_hops != NULL) {
52489                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
52490                 if (first_hops_constr.datalen > 0)
52491                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
52492                 else
52493                         first_hops_constr.data = NULL;
52494                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
52495                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
52496                         int64_t first_hops_conv_16 = first_hops_vals[q];
52497                         LDKChannelDetails first_hops_conv_16_conv;
52498                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
52499                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
52500                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
52501                         first_hops_conv_16_conv.is_owned = false;
52502                         first_hops_constr.data[q] = first_hops_conv_16_conv;
52503                 }
52504                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
52505                 first_hops_ptr = &first_hops_constr;
52506         }
52507         void* logger_ptr = untag_ptr(logger);
52508         CHECK_ACCESS(logger_ptr);
52509         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
52510         if (logger_conv.free == LDKLogger_JCalls_free) {
52511                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52512                 LDKLogger_JCalls_cloned(&logger_conv);
52513         }
52514         void* scorer_ptr = untag_ptr(scorer);
52515         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
52516         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
52517         uint8_t random_seed_bytes_arr[32];
52518         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
52519         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
52520         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
52521         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
52522         *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);
52523         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
52524         return tag_ptr(ret_conv, true);
52525 }
52526
52527 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) {
52528         LDKPublicKey our_node_pubkey_ref;
52529         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
52530         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
52531         LDKCVec_PublicKeyZ hops_constr;
52532         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
52533         if (hops_constr.datalen > 0)
52534                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
52535         else
52536                 hops_constr.data = NULL;
52537         for (size_t i = 0; i < hops_constr.datalen; i++) {
52538                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
52539                 LDKPublicKey hops_conv_8_ref;
52540                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
52541                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
52542                 hops_constr.data[i] = hops_conv_8_ref;
52543         }
52544         LDKRouteParameters route_params_conv;
52545         route_params_conv.inner = untag_ptr(route_params);
52546         route_params_conv.is_owned = ptr_is_owned(route_params);
52547         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
52548         route_params_conv.is_owned = false;
52549         LDKNetworkGraph network_graph_conv;
52550         network_graph_conv.inner = untag_ptr(network_graph);
52551         network_graph_conv.is_owned = ptr_is_owned(network_graph);
52552         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
52553         network_graph_conv.is_owned = false;
52554         void* logger_ptr = untag_ptr(logger);
52555         CHECK_ACCESS(logger_ptr);
52556         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
52557         if (logger_conv.free == LDKLogger_JCalls_free) {
52558                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52559                 LDKLogger_JCalls_cloned(&logger_conv);
52560         }
52561         uint8_t random_seed_bytes_arr[32];
52562         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
52563         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
52564         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
52565         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
52566         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
52567         return tag_ptr(ret_conv, true);
52568 }
52569
52570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52571         if (!ptr_is_owned(this_ptr)) return;
52572         void* this_ptr_ptr = untag_ptr(this_ptr);
52573         CHECK_ACCESS(this_ptr_ptr);
52574         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
52575         FREE(untag_ptr(this_ptr));
52576         Score_free(this_ptr_conv);
52577 }
52578
52579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52580         if (!ptr_is_owned(this_ptr)) return;
52581         void* this_ptr_ptr = untag_ptr(this_ptr);
52582         CHECK_ACCESS(this_ptr_ptr);
52583         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
52584         FREE(untag_ptr(this_ptr));
52585         LockableScore_free(this_ptr_conv);
52586 }
52587
52588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52589         if (!ptr_is_owned(this_ptr)) return;
52590         void* this_ptr_ptr = untag_ptr(this_ptr);
52591         CHECK_ACCESS(this_ptr_ptr);
52592         LDKWriteableScore this_ptr_conv = *(LDKWriteableScore*)(this_ptr_ptr);
52593         FREE(untag_ptr(this_ptr));
52594         WriteableScore_free(this_ptr_conv);
52595 }
52596
52597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52598         LDKMultiThreadedLockableScore this_obj_conv;
52599         this_obj_conv.inner = untag_ptr(this_obj);
52600         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52602         MultiThreadedLockableScore_free(this_obj_conv);
52603 }
52604
52605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52606         LDKMultiThreadedScoreLock this_obj_conv;
52607         this_obj_conv.inner = untag_ptr(this_obj);
52608         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52610         MultiThreadedScoreLock_free(this_obj_conv);
52611 }
52612
52613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
52614         LDKMultiThreadedScoreLock this_arg_conv;
52615         this_arg_conv.inner = untag_ptr(this_arg);
52616         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52618         this_arg_conv.is_owned = false;
52619         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
52620         *ret_ret = MultiThreadedScoreLock_as_Score(&this_arg_conv);
52621         return tag_ptr(ret_ret, true);
52622 }
52623
52624 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1write(JNIEnv *env, jclass clz, int64_t obj) {
52625         LDKMultiThreadedScoreLock obj_conv;
52626         obj_conv.inner = untag_ptr(obj);
52627         obj_conv.is_owned = ptr_is_owned(obj);
52628         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52629         obj_conv.is_owned = false;
52630         LDKCVec_u8Z ret_var = MultiThreadedScoreLock_write(&obj_conv);
52631         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52632         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52633         CVec_u8Z_free(ret_var);
52634         return ret_arr;
52635 }
52636
52637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1LockableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
52638         LDKMultiThreadedLockableScore this_arg_conv;
52639         this_arg_conv.inner = untag_ptr(this_arg);
52640         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52642         this_arg_conv.is_owned = false;
52643         LDKLockableScore* ret_ret = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
52644         *ret_ret = MultiThreadedLockableScore_as_LockableScore(&this_arg_conv);
52645         return tag_ptr(ret_ret, true);
52646 }
52647
52648 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
52649         LDKMultiThreadedLockableScore obj_conv;
52650         obj_conv.inner = untag_ptr(obj);
52651         obj_conv.is_owned = ptr_is_owned(obj);
52652         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52653         obj_conv.is_owned = false;
52654         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
52655         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52656         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52657         CVec_u8Z_free(ret_var);
52658         return ret_arr;
52659 }
52660
52661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1WriteableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
52662         LDKMultiThreadedLockableScore this_arg_conv;
52663         this_arg_conv.inner = untag_ptr(this_arg);
52664         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52666         this_arg_conv.is_owned = false;
52667         LDKWriteableScore* ret_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
52668         *ret_ret = MultiThreadedLockableScore_as_WriteableScore(&this_arg_conv);
52669         return tag_ptr(ret_ret, true);
52670 }
52671
52672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
52673         void* score_ptr = untag_ptr(score);
52674         CHECK_ACCESS(score_ptr);
52675         LDKScore score_conv = *(LDKScore*)(score_ptr);
52676         if (score_conv.free == LDKScore_JCalls_free) {
52677                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52678                 LDKScore_JCalls_cloned(&score_conv);
52679         }
52680         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
52681         int64_t ret_ref = 0;
52682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52683         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52684         return ret_ref;
52685 }
52686
52687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52688         LDKChannelUsage this_obj_conv;
52689         this_obj_conv.inner = untag_ptr(this_obj);
52690         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52692         ChannelUsage_free(this_obj_conv);
52693 }
52694
52695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52696         LDKChannelUsage this_ptr_conv;
52697         this_ptr_conv.inner = untag_ptr(this_ptr);
52698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52700         this_ptr_conv.is_owned = false;
52701         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
52702         return ret_conv;
52703 }
52704
52705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52706         LDKChannelUsage this_ptr_conv;
52707         this_ptr_conv.inner = untag_ptr(this_ptr);
52708         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52710         this_ptr_conv.is_owned = false;
52711         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
52712 }
52713
52714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52715         LDKChannelUsage this_ptr_conv;
52716         this_ptr_conv.inner = untag_ptr(this_ptr);
52717         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52719         this_ptr_conv.is_owned = false;
52720         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
52721         return ret_conv;
52722 }
52723
52724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52725         LDKChannelUsage this_ptr_conv;
52726         this_ptr_conv.inner = untag_ptr(this_ptr);
52727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52729         this_ptr_conv.is_owned = false;
52730         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
52731 }
52732
52733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
52734         LDKChannelUsage this_ptr_conv;
52735         this_ptr_conv.inner = untag_ptr(this_ptr);
52736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52738         this_ptr_conv.is_owned = false;
52739         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
52740         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
52741         int64_t ret_ref = tag_ptr(ret_copy, true);
52742         return ret_ref;
52743 }
52744
52745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52746         LDKChannelUsage this_ptr_conv;
52747         this_ptr_conv.inner = untag_ptr(this_ptr);
52748         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52750         this_ptr_conv.is_owned = false;
52751         void* val_ptr = untag_ptr(val);
52752         CHECK_ACCESS(val_ptr);
52753         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
52754         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
52755         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
52756 }
52757
52758 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) {
52759         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
52760         CHECK_ACCESS(effective_capacity_arg_ptr);
52761         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
52762         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
52763         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
52764         int64_t ret_ref = 0;
52765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52766         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52767         return ret_ref;
52768 }
52769
52770 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
52771         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
52772         int64_t ret_ref = 0;
52773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52774         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52775         return ret_ref;
52776 }
52777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52778         LDKChannelUsage arg_conv;
52779         arg_conv.inner = untag_ptr(arg);
52780         arg_conv.is_owned = ptr_is_owned(arg);
52781         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52782         arg_conv.is_owned = false;
52783         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
52784         return ret_conv;
52785 }
52786
52787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52788         LDKChannelUsage orig_conv;
52789         orig_conv.inner = untag_ptr(orig);
52790         orig_conv.is_owned = ptr_is_owned(orig);
52791         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52792         orig_conv.is_owned = false;
52793         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
52794         int64_t ret_ref = 0;
52795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52796         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52797         return ret_ref;
52798 }
52799
52800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52801         LDKFixedPenaltyScorer this_obj_conv;
52802         this_obj_conv.inner = untag_ptr(this_obj);
52803         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52805         FixedPenaltyScorer_free(this_obj_conv);
52806 }
52807
52808 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
52809         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
52810         int64_t ret_ref = 0;
52811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52812         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52813         return ret_ref;
52814 }
52815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52816         LDKFixedPenaltyScorer arg_conv;
52817         arg_conv.inner = untag_ptr(arg);
52818         arg_conv.is_owned = ptr_is_owned(arg);
52819         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52820         arg_conv.is_owned = false;
52821         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
52822         return ret_conv;
52823 }
52824
52825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52826         LDKFixedPenaltyScorer orig_conv;
52827         orig_conv.inner = untag_ptr(orig);
52828         orig_conv.is_owned = ptr_is_owned(orig);
52829         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52830         orig_conv.is_owned = false;
52831         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
52832         int64_t ret_ref = 0;
52833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52834         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52835         return ret_ref;
52836 }
52837
52838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
52839         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
52840         int64_t ret_ref = 0;
52841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52842         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52843         return ret_ref;
52844 }
52845
52846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
52847         LDKFixedPenaltyScorer this_arg_conv;
52848         this_arg_conv.inner = untag_ptr(this_arg);
52849         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52851         this_arg_conv.is_owned = false;
52852         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
52853         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
52854         return tag_ptr(ret_ret, true);
52855 }
52856
52857 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
52858         LDKFixedPenaltyScorer obj_conv;
52859         obj_conv.inner = untag_ptr(obj);
52860         obj_conv.is_owned = ptr_is_owned(obj);
52861         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52862         obj_conv.is_owned = false;
52863         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
52864         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52865         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52866         CVec_u8Z_free(ret_var);
52867         return ret_arr;
52868 }
52869
52870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
52871         LDKu8slice ser_ref;
52872         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
52873         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
52874         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
52875         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
52876         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
52877         return tag_ptr(ret_conv, true);
52878 }
52879
52880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52881         LDKProbabilisticScorer this_obj_conv;
52882         this_obj_conv.inner = untag_ptr(this_obj);
52883         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52885         ProbabilisticScorer_free(this_obj_conv);
52886 }
52887
52888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52889         LDKProbabilisticScoringParameters this_obj_conv;
52890         this_obj_conv.inner = untag_ptr(this_obj);
52891         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52893         ProbabilisticScoringParameters_free(this_obj_conv);
52894 }
52895
52896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52897         LDKProbabilisticScoringParameters this_ptr_conv;
52898         this_ptr_conv.inner = untag_ptr(this_ptr);
52899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52901         this_ptr_conv.is_owned = false;
52902         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
52903         return ret_conv;
52904 }
52905
52906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52907         LDKProbabilisticScoringParameters this_ptr_conv;
52908         this_ptr_conv.inner = untag_ptr(this_ptr);
52909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52911         this_ptr_conv.is_owned = false;
52912         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
52913 }
52914
52915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52916         LDKProbabilisticScoringParameters this_ptr_conv;
52917         this_ptr_conv.inner = untag_ptr(this_ptr);
52918         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52920         this_ptr_conv.is_owned = false;
52921         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
52922         return ret_conv;
52923 }
52924
52925 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) {
52926         LDKProbabilisticScoringParameters this_ptr_conv;
52927         this_ptr_conv.inner = untag_ptr(this_ptr);
52928         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52930         this_ptr_conv.is_owned = false;
52931         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
52932 }
52933
52934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52935         LDKProbabilisticScoringParameters this_ptr_conv;
52936         this_ptr_conv.inner = untag_ptr(this_ptr);
52937         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52939         this_ptr_conv.is_owned = false;
52940         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
52941         return ret_conv;
52942 }
52943
52944 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) {
52945         LDKProbabilisticScoringParameters this_ptr_conv;
52946         this_ptr_conv.inner = untag_ptr(this_ptr);
52947         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52949         this_ptr_conv.is_owned = false;
52950         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
52951 }
52952
52953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
52954         LDKProbabilisticScoringParameters this_ptr_conv;
52955         this_ptr_conv.inner = untag_ptr(this_ptr);
52956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52958         this_ptr_conv.is_owned = false;
52959         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
52960         return ret_conv;
52961 }
52962
52963 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) {
52964         LDKProbabilisticScoringParameters this_ptr_conv;
52965         this_ptr_conv.inner = untag_ptr(this_ptr);
52966         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52968         this_ptr_conv.is_owned = false;
52969         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
52970 }
52971
52972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52973         LDKProbabilisticScoringParameters this_ptr_conv;
52974         this_ptr_conv.inner = untag_ptr(this_ptr);
52975         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52977         this_ptr_conv.is_owned = false;
52978         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
52979         return ret_conv;
52980 }
52981
52982 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) {
52983         LDKProbabilisticScoringParameters this_ptr_conv;
52984         this_ptr_conv.inner = untag_ptr(this_ptr);
52985         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52987         this_ptr_conv.is_owned = false;
52988         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
52989 }
52990
52991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52992         LDKProbabilisticScoringParameters this_ptr_conv;
52993         this_ptr_conv.inner = untag_ptr(this_ptr);
52994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52996         this_ptr_conv.is_owned = false;
52997         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv);
52998         return ret_conv;
52999 }
53000
53001 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) {
53002         LDKProbabilisticScoringParameters this_ptr_conv;
53003         this_ptr_conv.inner = untag_ptr(this_ptr);
53004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53006         this_ptr_conv.is_owned = false;
53007         ProbabilisticScoringParameters_set_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
53008 }
53009
53010 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) {
53011         LDKProbabilisticScoringParameters this_ptr_conv;
53012         this_ptr_conv.inner = untag_ptr(this_ptr);
53013         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53015         this_ptr_conv.is_owned = false;
53016         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
53017         return ret_conv;
53018 }
53019
53020 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) {
53021         LDKProbabilisticScoringParameters this_ptr_conv;
53022         this_ptr_conv.inner = untag_ptr(this_ptr);
53023         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53025         this_ptr_conv.is_owned = false;
53026         ProbabilisticScoringParameters_set_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
53027 }
53028
53029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1no_1updates_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
53030         LDKProbabilisticScoringParameters this_ptr_conv;
53031         this_ptr_conv.inner = untag_ptr(this_ptr);
53032         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53034         this_ptr_conv.is_owned = false;
53035         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_no_updates_half_life(&this_ptr_conv);
53036         return ret_conv;
53037 }
53038
53039 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) {
53040         LDKProbabilisticScoringParameters this_ptr_conv;
53041         this_ptr_conv.inner = untag_ptr(this_ptr);
53042         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53044         this_ptr_conv.is_owned = false;
53045         ProbabilisticScoringParameters_set_historical_no_updates_half_life(&this_ptr_conv, val);
53046 }
53047
53048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
53049         LDKProbabilisticScoringParameters this_ptr_conv;
53050         this_ptr_conv.inner = untag_ptr(this_ptr);
53051         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53053         this_ptr_conv.is_owned = false;
53054         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
53055         return ret_conv;
53056 }
53057
53058 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) {
53059         LDKProbabilisticScoringParameters this_ptr_conv;
53060         this_ptr_conv.inner = untag_ptr(this_ptr);
53061         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53063         this_ptr_conv.is_owned = false;
53064         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
53065 }
53066
53067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
53068         LDKProbabilisticScoringParameters this_ptr_conv;
53069         this_ptr_conv.inner = untag_ptr(this_ptr);
53070         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53072         this_ptr_conv.is_owned = false;
53073         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
53074         return ret_conv;
53075 }
53076
53077 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) {
53078         LDKProbabilisticScoringParameters this_ptr_conv;
53079         this_ptr_conv.inner = untag_ptr(this_ptr);
53080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53082         this_ptr_conv.is_owned = false;
53083         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
53084 }
53085
53086 static inline uint64_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
53087         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
53088         int64_t ret_ref = 0;
53089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53090         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53091         return ret_ref;
53092 }
53093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53094         LDKProbabilisticScoringParameters arg_conv;
53095         arg_conv.inner = untag_ptr(arg);
53096         arg_conv.is_owned = ptr_is_owned(arg);
53097         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53098         arg_conv.is_owned = false;
53099         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
53100         return ret_conv;
53101 }
53102
53103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53104         LDKProbabilisticScoringParameters orig_conv;
53105         orig_conv.inner = untag_ptr(orig);
53106         orig_conv.is_owned = ptr_is_owned(orig);
53107         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53108         orig_conv.is_owned = false;
53109         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
53110         int64_t ret_ref = 0;
53111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53112         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53113         return ret_ref;
53114 }
53115
53116 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) {
53117         LDKProbabilisticScoringParameters params_conv;
53118         params_conv.inner = untag_ptr(params);
53119         params_conv.is_owned = ptr_is_owned(params);
53120         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
53121         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
53122         LDKNetworkGraph network_graph_conv;
53123         network_graph_conv.inner = untag_ptr(network_graph);
53124         network_graph_conv.is_owned = ptr_is_owned(network_graph);
53125         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
53126         network_graph_conv.is_owned = false;
53127         void* logger_ptr = untag_ptr(logger);
53128         CHECK_ACCESS(logger_ptr);
53129         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53130         if (logger_conv.free == LDKLogger_JCalls_free) {
53131                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53132                 LDKLogger_JCalls_cloned(&logger_conv);
53133         }
53134         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
53135         int64_t ret_ref = 0;
53136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53137         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53138         return ret_ref;
53139 }
53140
53141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
53142         LDKProbabilisticScorer this_arg_conv;
53143         this_arg_conv.inner = untag_ptr(this_arg);
53144         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53146         this_arg_conv.is_owned = false;
53147         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
53148 }
53149
53150 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) {
53151         LDKProbabilisticScorer this_arg_conv;
53152         this_arg_conv.inner = untag_ptr(this_arg);
53153         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53155         this_arg_conv.is_owned = false;
53156         LDKNodeId target_conv;
53157         target_conv.inner = untag_ptr(target);
53158         target_conv.is_owned = ptr_is_owned(target);
53159         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
53160         target_conv.is_owned = false;
53161         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
53162         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
53163         int64_t ret_ref = tag_ptr(ret_copy, true);
53164         return ret_ref;
53165 }
53166
53167 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) {
53168         LDKProbabilisticScorer this_arg_conv;
53169         this_arg_conv.inner = untag_ptr(this_arg);
53170         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53172         this_arg_conv.is_owned = false;
53173         LDKNodeId target_conv;
53174         target_conv.inner = untag_ptr(target);
53175         target_conv.is_owned = ptr_is_owned(target);
53176         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
53177         target_conv.is_owned = false;
53178         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
53179         *ret_copy = ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(&this_arg_conv, scid, &target_conv);
53180         int64_t ret_ref = tag_ptr(ret_copy, true);
53181         return ret_ref;
53182 }
53183
53184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
53185         LDKProbabilisticScorer this_arg_conv;
53186         this_arg_conv.inner = untag_ptr(this_arg);
53187         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53189         this_arg_conv.is_owned = false;
53190         LDKNodeId node_id_conv;
53191         node_id_conv.inner = untag_ptr(node_id);
53192         node_id_conv.is_owned = ptr_is_owned(node_id);
53193         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53194         node_id_conv.is_owned = false;
53195         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
53196 }
53197
53198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
53199         LDKProbabilisticScorer this_arg_conv;
53200         this_arg_conv.inner = untag_ptr(this_arg);
53201         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53203         this_arg_conv.is_owned = false;
53204         LDKNodeId node_id_conv;
53205         node_id_conv.inner = untag_ptr(node_id);
53206         node_id_conv.is_owned = ptr_is_owned(node_id);
53207         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53208         node_id_conv.is_owned = false;
53209         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
53210 }
53211
53212 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) {
53213         LDKProbabilisticScorer this_arg_conv;
53214         this_arg_conv.inner = untag_ptr(this_arg);
53215         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53217         this_arg_conv.is_owned = false;
53218         LDKNodeId node_id_conv;
53219         node_id_conv.inner = untag_ptr(node_id);
53220         node_id_conv.is_owned = ptr_is_owned(node_id);
53221         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53222         node_id_conv.is_owned = false;
53223         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
53224 }
53225
53226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
53227         LDKProbabilisticScorer this_arg_conv;
53228         this_arg_conv.inner = untag_ptr(this_arg);
53229         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53231         this_arg_conv.is_owned = false;
53232         LDKNodeId node_id_conv;
53233         node_id_conv.inner = untag_ptr(node_id);
53234         node_id_conv.is_owned = ptr_is_owned(node_id);
53235         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53236         node_id_conv.is_owned = false;
53237         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
53238 }
53239
53240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
53241         LDKProbabilisticScorer this_arg_conv;
53242         this_arg_conv.inner = untag_ptr(this_arg);
53243         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53245         this_arg_conv.is_owned = false;
53246         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
53247 }
53248
53249 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) {
53250         LDKProbabilisticScoringParameters this_arg_conv;
53251         this_arg_conv.inner = untag_ptr(this_arg);
53252         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53254         this_arg_conv.is_owned = false;
53255         LDKCVec_NodeIdZ node_ids_constr;
53256         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
53257         if (node_ids_constr.datalen > 0)
53258                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
53259         else
53260                 node_ids_constr.data = NULL;
53261         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
53262         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
53263                 int64_t node_ids_conv_8 = node_ids_vals[i];
53264                 LDKNodeId node_ids_conv_8_conv;
53265                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
53266                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
53267                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
53268                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
53269                 node_ids_constr.data[i] = node_ids_conv_8_conv;
53270         }
53271         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
53272         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
53273 }
53274
53275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
53276         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
53277         int64_t ret_ref = 0;
53278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53279         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53280         return ret_ref;
53281 }
53282
53283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
53284         LDKProbabilisticScorer this_arg_conv;
53285         this_arg_conv.inner = untag_ptr(this_arg);
53286         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53288         this_arg_conv.is_owned = false;
53289         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
53290         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
53291         return tag_ptr(ret_ret, true);
53292 }
53293
53294 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
53295         LDKProbabilisticScorer obj_conv;
53296         obj_conv.inner = untag_ptr(obj);
53297         obj_conv.is_owned = ptr_is_owned(obj);
53298         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53299         obj_conv.is_owned = false;
53300         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
53301         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53302         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53303         CVec_u8Z_free(ret_var);
53304         return ret_arr;
53305 }
53306
53307 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) {
53308         LDKu8slice ser_ref;
53309         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53310         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53311         LDKProbabilisticScoringParameters arg_a_conv;
53312         arg_a_conv.inner = untag_ptr(arg_a);
53313         arg_a_conv.is_owned = ptr_is_owned(arg_a);
53314         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
53315         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
53316         LDKNetworkGraph arg_b_conv;
53317         arg_b_conv.inner = untag_ptr(arg_b);
53318         arg_b_conv.is_owned = ptr_is_owned(arg_b);
53319         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
53320         arg_b_conv.is_owned = false;
53321         void* arg_c_ptr = untag_ptr(arg_c);
53322         CHECK_ACCESS(arg_c_ptr);
53323         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
53324         if (arg_c_conv.free == LDKLogger_JCalls_free) {
53325                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53326                 LDKLogger_JCalls_cloned(&arg_c_conv);
53327         }
53328         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
53329         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
53330         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53331         return tag_ptr(ret_conv, true);
53332 }
53333
53334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53335         LDKOnionMessenger this_obj_conv;
53336         this_obj_conv.inner = untag_ptr(this_obj);
53337         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53339         OnionMessenger_free(this_obj_conv);
53340 }
53341
53342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Destination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53343         if (!ptr_is_owned(this_ptr)) return;
53344         void* this_ptr_ptr = untag_ptr(this_ptr);
53345         CHECK_ACCESS(this_ptr_ptr);
53346         LDKDestination this_ptr_conv = *(LDKDestination*)(this_ptr_ptr);
53347         FREE(untag_ptr(this_ptr));
53348         Destination_free(this_ptr_conv);
53349 }
53350
53351 static inline uint64_t Destination_clone_ptr(LDKDestination *NONNULL_PTR arg) {
53352         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53353         *ret_copy = Destination_clone(arg);
53354         int64_t ret_ref = tag_ptr(ret_copy, true);
53355         return ret_ref;
53356 }
53357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53358         LDKDestination* arg_conv = (LDKDestination*)untag_ptr(arg);
53359         int64_t ret_conv = Destination_clone_ptr(arg_conv);
53360         return ret_conv;
53361 }
53362
53363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53364         LDKDestination* orig_conv = (LDKDestination*)untag_ptr(orig);
53365         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53366         *ret_copy = Destination_clone(orig_conv);
53367         int64_t ret_ref = tag_ptr(ret_copy, true);
53368         return ret_ref;
53369 }
53370
53371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1node(JNIEnv *env, jclass clz, int8_tArray a) {
53372         LDKPublicKey a_ref;
53373         CHECK((*env)->GetArrayLength(env, a) == 33);
53374         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
53375         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53376         *ret_copy = Destination_node(a_ref);
53377         int64_t ret_ref = tag_ptr(ret_copy, true);
53378         return ret_ref;
53379 }
53380
53381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1blinded_1path(JNIEnv *env, jclass clz, int64_t a) {
53382         LDKBlindedPath a_conv;
53383         a_conv.inner = untag_ptr(a);
53384         a_conv.is_owned = ptr_is_owned(a);
53385         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53386         a_conv = BlindedPath_clone(&a_conv);
53387         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53388         *ret_copy = Destination_blinded_path(a_conv);
53389         int64_t ret_ref = tag_ptr(ret_copy, true);
53390         return ret_ref;
53391 }
53392
53393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SendError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53394         if (!ptr_is_owned(this_ptr)) return;
53395         void* this_ptr_ptr = untag_ptr(this_ptr);
53396         CHECK_ACCESS(this_ptr_ptr);
53397         LDKSendError this_ptr_conv = *(LDKSendError*)(this_ptr_ptr);
53398         FREE(untag_ptr(this_ptr));
53399         SendError_free(this_ptr_conv);
53400 }
53401
53402 static inline uint64_t SendError_clone_ptr(LDKSendError *NONNULL_PTR arg) {
53403         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53404         *ret_copy = SendError_clone(arg);
53405         int64_t ret_ref = tag_ptr(ret_copy, true);
53406         return ret_ref;
53407 }
53408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53409         LDKSendError* arg_conv = (LDKSendError*)untag_ptr(arg);
53410         int64_t ret_conv = SendError_clone_ptr(arg_conv);
53411         return ret_conv;
53412 }
53413
53414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53415         LDKSendError* orig_conv = (LDKSendError*)untag_ptr(orig);
53416         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53417         *ret_copy = SendError_clone(orig_conv);
53418         int64_t ret_ref = tag_ptr(ret_copy, true);
53419         return ret_ref;
53420 }
53421
53422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1secp256k1(JNIEnv *env, jclass clz, jclass a) {
53423         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
53424         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53425         *ret_copy = SendError_secp256k1(a_conv);
53426         int64_t ret_ref = tag_ptr(ret_copy, true);
53427         return ret_ref;
53428 }
53429
53430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1big_1packet(JNIEnv *env, jclass clz) {
53431         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53432         *ret_copy = SendError_too_big_packet();
53433         int64_t ret_ref = tag_ptr(ret_copy, true);
53434         return ret_ref;
53435 }
53436
53437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1few_1blinded_1hops(JNIEnv *env, jclass clz) {
53438         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53439         *ret_copy = SendError_too_few_blinded_hops();
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_SendError_1invalid_1first_1hop(JNIEnv *env, jclass clz) {
53445         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53446         *ret_copy = SendError_invalid_first_hop();
53447         int64_t ret_ref = tag_ptr(ret_copy, true);
53448         return ret_ref;
53449 }
53450
53451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1message(JNIEnv *env, jclass clz) {
53452         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53453         *ret_copy = SendError_invalid_message();
53454         int64_t ret_ref = tag_ptr(ret_copy, true);
53455         return ret_ref;
53456 }
53457
53458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1buffer_1full(JNIEnv *env, jclass clz) {
53459         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53460         *ret_copy = SendError_buffer_full();
53461         int64_t ret_ref = tag_ptr(ret_copy, true);
53462         return ret_ref;
53463 }
53464
53465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1get_1node_1id_1failed(JNIEnv *env, jclass clz) {
53466         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53467         *ret_copy = SendError_get_node_id_failed();
53468         int64_t ret_ref = tag_ptr(ret_copy, true);
53469         return ret_ref;
53470 }
53471
53472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1blinded_1path_1advance_1failed(JNIEnv *env, jclass clz) {
53473         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53474         *ret_copy = SendError_blinded_path_advance_failed();
53475         int64_t ret_ref = tag_ptr(ret_copy, true);
53476         return ret_ref;
53477 }
53478
53479 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SendError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53480         LDKSendError* a_conv = (LDKSendError*)untag_ptr(a);
53481         LDKSendError* b_conv = (LDKSendError*)untag_ptr(b);
53482         jboolean ret_conv = SendError_eq(a_conv, b_conv);
53483         return ret_conv;
53484 }
53485
53486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53487         if (!ptr_is_owned(this_ptr)) return;
53488         void* this_ptr_ptr = untag_ptr(this_ptr);
53489         CHECK_ACCESS(this_ptr_ptr);
53490         LDKCustomOnionMessageHandler this_ptr_conv = *(LDKCustomOnionMessageHandler*)(this_ptr_ptr);
53491         FREE(untag_ptr(this_ptr));
53492         CustomOnionMessageHandler_free(this_ptr_conv);
53493 }
53494
53495 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) {
53496         void* entropy_source_ptr = untag_ptr(entropy_source);
53497         CHECK_ACCESS(entropy_source_ptr);
53498         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
53499         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
53500                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53501                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
53502         }
53503         void* node_signer_ptr = untag_ptr(node_signer);
53504         CHECK_ACCESS(node_signer_ptr);
53505         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
53506         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
53507                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53508                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
53509         }
53510         void* logger_ptr = untag_ptr(logger);
53511         CHECK_ACCESS(logger_ptr);
53512         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53513         if (logger_conv.free == LDKLogger_JCalls_free) {
53514                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53515                 LDKLogger_JCalls_cloned(&logger_conv);
53516         }
53517         void* custom_handler_ptr = untag_ptr(custom_handler);
53518         CHECK_ACCESS(custom_handler_ptr);
53519         LDKCustomOnionMessageHandler custom_handler_conv = *(LDKCustomOnionMessageHandler*)(custom_handler_ptr);
53520         if (custom_handler_conv.free == LDKCustomOnionMessageHandler_JCalls_free) {
53521                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53522                 LDKCustomOnionMessageHandler_JCalls_cloned(&custom_handler_conv);
53523         }
53524         LDKOnionMessenger ret_var = OnionMessenger_new(entropy_source_conv, node_signer_conv, logger_conv, custom_handler_conv);
53525         int64_t ret_ref = 0;
53526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53527         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53528         return ret_ref;
53529 }
53530
53531 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) {
53532         LDKOnionMessenger this_arg_conv;
53533         this_arg_conv.inner = untag_ptr(this_arg);
53534         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53536         this_arg_conv.is_owned = false;
53537         LDKCVec_PublicKeyZ intermediate_nodes_constr;
53538         intermediate_nodes_constr.datalen = (*env)->GetArrayLength(env, intermediate_nodes);
53539         if (intermediate_nodes_constr.datalen > 0)
53540                 intermediate_nodes_constr.data = MALLOC(intermediate_nodes_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
53541         else
53542                 intermediate_nodes_constr.data = NULL;
53543         for (size_t i = 0; i < intermediate_nodes_constr.datalen; i++) {
53544                 int8_tArray intermediate_nodes_conv_8 = (*env)->GetObjectArrayElement(env, intermediate_nodes, i);
53545                 LDKPublicKey intermediate_nodes_conv_8_ref;
53546                 CHECK((*env)->GetArrayLength(env, intermediate_nodes_conv_8) == 33);
53547                 (*env)->GetByteArrayRegion(env, intermediate_nodes_conv_8, 0, 33, intermediate_nodes_conv_8_ref.compressed_form);
53548                 intermediate_nodes_constr.data[i] = intermediate_nodes_conv_8_ref;
53549         }
53550         void* destination_ptr = untag_ptr(destination);
53551         CHECK_ACCESS(destination_ptr);
53552         LDKDestination destination_conv = *(LDKDestination*)(destination_ptr);
53553         destination_conv = Destination_clone((LDKDestination*)untag_ptr(destination));
53554         void* message_ptr = untag_ptr(message);
53555         CHECK_ACCESS(message_ptr);
53556         LDKOnionMessageContents message_conv = *(LDKOnionMessageContents*)(message_ptr);
53557         message_conv = OnionMessageContents_clone((LDKOnionMessageContents*)untag_ptr(message));
53558         LDKBlindedPath reply_path_conv;
53559         reply_path_conv.inner = untag_ptr(reply_path);
53560         reply_path_conv.is_owned = ptr_is_owned(reply_path);
53561         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
53562         reply_path_conv = BlindedPath_clone(&reply_path_conv);
53563         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
53564         *ret_conv = OnionMessenger_send_onion_message(&this_arg_conv, intermediate_nodes_constr, destination_conv, message_conv, reply_path_conv);
53565         return tag_ptr(ret_conv, true);
53566 }
53567
53568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
53569         LDKOnionMessenger this_arg_conv;
53570         this_arg_conv.inner = untag_ptr(this_arg);
53571         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53573         this_arg_conv.is_owned = false;
53574         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
53575         *ret_ret = OnionMessenger_as_OnionMessageHandler(&this_arg_conv);
53576         return tag_ptr(ret_ret, true);
53577 }
53578
53579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
53580         LDKOnionMessenger this_arg_conv;
53581         this_arg_conv.inner = untag_ptr(this_arg);
53582         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53584         this_arg_conv.is_owned = false;
53585         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
53586         *ret_ret = OnionMessenger_as_OnionMessageProvider(&this_arg_conv);
53587         return tag_ptr(ret_ret, true);
53588 }
53589
53590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53591         if (!ptr_is_owned(this_ptr)) return;
53592         void* this_ptr_ptr = untag_ptr(this_ptr);
53593         CHECK_ACCESS(this_ptr_ptr);
53594         LDKOnionMessageContents this_ptr_conv = *(LDKOnionMessageContents*)(this_ptr_ptr);
53595         FREE(untag_ptr(this_ptr));
53596         OnionMessageContents_free(this_ptr_conv);
53597 }
53598
53599 static inline uint64_t OnionMessageContents_clone_ptr(LDKOnionMessageContents *NONNULL_PTR arg) {
53600         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
53601         *ret_copy = OnionMessageContents_clone(arg);
53602         int64_t ret_ref = tag_ptr(ret_copy, true);
53603         return ret_ref;
53604 }
53605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53606         LDKOnionMessageContents* arg_conv = (LDKOnionMessageContents*)untag_ptr(arg);
53607         int64_t ret_conv = OnionMessageContents_clone_ptr(arg_conv);
53608         return ret_conv;
53609 }
53610
53611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53612         LDKOnionMessageContents* orig_conv = (LDKOnionMessageContents*)untag_ptr(orig);
53613         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
53614         *ret_copy = OnionMessageContents_clone(orig_conv);
53615         int64_t ret_ref = tag_ptr(ret_copy, true);
53616         return ret_ref;
53617 }
53618
53619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1custom(JNIEnv *env, jclass clz, int64_t a) {
53620         void* a_ptr = untag_ptr(a);
53621         CHECK_ACCESS(a_ptr);
53622         LDKCustomOnionMessageContents a_conv = *(LDKCustomOnionMessageContents*)(a_ptr);
53623         if (a_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
53624                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53625                 LDKCustomOnionMessageContents_JCalls_cloned(&a_conv);
53626         }
53627         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
53628         *ret_copy = OnionMessageContents_custom(a_conv);
53629         int64_t ret_ref = tag_ptr(ret_copy, true);
53630         return ret_ref;
53631 }
53632
53633 static inline uint64_t CustomOnionMessageContents_clone_ptr(LDKCustomOnionMessageContents *NONNULL_PTR arg) {
53634         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
53635         *ret_ret = CustomOnionMessageContents_clone(arg);
53636         return tag_ptr(ret_ret, true);
53637 }
53638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53639         void* arg_ptr = untag_ptr(arg);
53640         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
53641         LDKCustomOnionMessageContents* arg_conv = (LDKCustomOnionMessageContents*)arg_ptr;
53642         int64_t ret_conv = CustomOnionMessageContents_clone_ptr(arg_conv);
53643         return ret_conv;
53644 }
53645
53646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53647         void* orig_ptr = untag_ptr(orig);
53648         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
53649         LDKCustomOnionMessageContents* orig_conv = (LDKCustomOnionMessageContents*)orig_ptr;
53650         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
53651         *ret_ret = CustomOnionMessageContents_clone(orig_conv);
53652         return tag_ptr(ret_ret, true);
53653 }
53654
53655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53656         if (!ptr_is_owned(this_ptr)) return;
53657         void* this_ptr_ptr = untag_ptr(this_ptr);
53658         CHECK_ACCESS(this_ptr_ptr);
53659         LDKCustomOnionMessageContents this_ptr_conv = *(LDKCustomOnionMessageContents*)(this_ptr_ptr);
53660         FREE(untag_ptr(this_ptr));
53661         CustomOnionMessageContents_free(this_ptr_conv);
53662 }
53663
53664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPath_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53665         LDKBlindedPath this_obj_conv;
53666         this_obj_conv.inner = untag_ptr(this_obj);
53667         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53669         BlindedPath_free(this_obj_conv);
53670 }
53671
53672 static inline uint64_t BlindedPath_clone_ptr(LDKBlindedPath *NONNULL_PTR arg) {
53673         LDKBlindedPath ret_var = BlindedPath_clone(arg);
53674         int64_t ret_ref = 0;
53675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53676         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53677         return ret_ref;
53678 }
53679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53680         LDKBlindedPath arg_conv;
53681         arg_conv.inner = untag_ptr(arg);
53682         arg_conv.is_owned = ptr_is_owned(arg);
53683         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53684         arg_conv.is_owned = false;
53685         int64_t ret_conv = BlindedPath_clone_ptr(&arg_conv);
53686         return ret_conv;
53687 }
53688
53689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53690         LDKBlindedPath orig_conv;
53691         orig_conv.inner = untag_ptr(orig);
53692         orig_conv.is_owned = ptr_is_owned(orig);
53693         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53694         orig_conv.is_owned = false;
53695         LDKBlindedPath ret_var = BlindedPath_clone(&orig_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_BlindedPath_1hash(JNIEnv *env, jclass clz, int64_t o) {
53703         LDKBlindedPath o_conv;
53704         o_conv.inner = untag_ptr(o);
53705         o_conv.is_owned = ptr_is_owned(o);
53706         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53707         o_conv.is_owned = false;
53708         int64_t ret_conv = BlindedPath_hash(&o_conv);
53709         return ret_conv;
53710 }
53711
53712 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedPath_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53713         LDKBlindedPath a_conv;
53714         a_conv.inner = untag_ptr(a);
53715         a_conv.is_owned = ptr_is_owned(a);
53716         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53717         a_conv.is_owned = false;
53718         LDKBlindedPath b_conv;
53719         b_conv.inner = untag_ptr(b);
53720         b_conv.is_owned = ptr_is_owned(b);
53721         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53722         b_conv.is_owned = false;
53723         jboolean ret_conv = BlindedPath_eq(&a_conv, &b_conv);
53724         return ret_conv;
53725 }
53726
53727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53728         LDKBlindedHop this_obj_conv;
53729         this_obj_conv.inner = untag_ptr(this_obj);
53730         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53732         BlindedHop_free(this_obj_conv);
53733 }
53734
53735 static inline uint64_t BlindedHop_clone_ptr(LDKBlindedHop *NONNULL_PTR arg) {
53736         LDKBlindedHop ret_var = BlindedHop_clone(arg);
53737         int64_t ret_ref = 0;
53738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53740         return ret_ref;
53741 }
53742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53743         LDKBlindedHop arg_conv;
53744         arg_conv.inner = untag_ptr(arg);
53745         arg_conv.is_owned = ptr_is_owned(arg);
53746         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53747         arg_conv.is_owned = false;
53748         int64_t ret_conv = BlindedHop_clone_ptr(&arg_conv);
53749         return ret_conv;
53750 }
53751
53752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53753         LDKBlindedHop orig_conv;
53754         orig_conv.inner = untag_ptr(orig);
53755         orig_conv.is_owned = ptr_is_owned(orig);
53756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53757         orig_conv.is_owned = false;
53758         LDKBlindedHop ret_var = BlindedHop_clone(&orig_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_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
53766         LDKBlindedHop o_conv;
53767         o_conv.inner = untag_ptr(o);
53768         o_conv.is_owned = ptr_is_owned(o);
53769         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53770         o_conv.is_owned = false;
53771         int64_t ret_conv = BlindedHop_hash(&o_conv);
53772         return ret_conv;
53773 }
53774
53775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53776         LDKBlindedHop a_conv;
53777         a_conv.inner = untag_ptr(a);
53778         a_conv.is_owned = ptr_is_owned(a);
53779         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53780         a_conv.is_owned = false;
53781         LDKBlindedHop b_conv;
53782         b_conv.inner = untag_ptr(b);
53783         b_conv.is_owned = ptr_is_owned(b);
53784         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53785         b_conv.is_owned = false;
53786         jboolean ret_conv = BlindedHop_eq(&a_conv, &b_conv);
53787         return ret_conv;
53788 }
53789
53790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1new_1for_1message(JNIEnv *env, jclass clz, jobjectArray node_pks, int64_t entropy_source) {
53791         LDKCVec_PublicKeyZ node_pks_constr;
53792         node_pks_constr.datalen = (*env)->GetArrayLength(env, node_pks);
53793         if (node_pks_constr.datalen > 0)
53794                 node_pks_constr.data = MALLOC(node_pks_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
53795         else
53796                 node_pks_constr.data = NULL;
53797         for (size_t i = 0; i < node_pks_constr.datalen; i++) {
53798                 int8_tArray node_pks_conv_8 = (*env)->GetObjectArrayElement(env, node_pks, i);
53799                 LDKPublicKey node_pks_conv_8_ref;
53800                 CHECK((*env)->GetArrayLength(env, node_pks_conv_8) == 33);
53801                 (*env)->GetByteArrayRegion(env, node_pks_conv_8, 0, 33, node_pks_conv_8_ref.compressed_form);
53802                 node_pks_constr.data[i] = node_pks_conv_8_ref;
53803         }
53804         void* entropy_source_ptr = untag_ptr(entropy_source);
53805         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
53806         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
53807         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
53808         *ret_conv = BlindedPath_new_for_message(node_pks_constr, entropy_source_conv);
53809         return tag_ptr(ret_conv, true);
53810 }
53811
53812 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedPath_1write(JNIEnv *env, jclass clz, int64_t obj) {
53813         LDKBlindedPath obj_conv;
53814         obj_conv.inner = untag_ptr(obj);
53815         obj_conv.is_owned = ptr_is_owned(obj);
53816         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53817         obj_conv.is_owned = false;
53818         LDKCVec_u8Z ret_var = BlindedPath_write(&obj_conv);
53819         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53820         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53821         CVec_u8Z_free(ret_var);
53822         return ret_arr;
53823 }
53824
53825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53826         LDKu8slice ser_ref;
53827         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53828         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53829         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
53830         *ret_conv = BlindedPath_read(ser_ref);
53831         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53832         return tag_ptr(ret_conv, true);
53833 }
53834
53835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
53836         LDKBlindedHop obj_conv;
53837         obj_conv.inner = untag_ptr(obj);
53838         obj_conv.is_owned = ptr_is_owned(obj);
53839         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53840         obj_conv.is_owned = false;
53841         LDKCVec_u8Z ret_var = BlindedHop_write(&obj_conv);
53842         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53843         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53844         CVec_u8Z_free(ret_var);
53845         return ret_arr;
53846 }
53847
53848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53849         LDKu8slice ser_ref;
53850         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53851         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53852         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
53853         *ret_conv = BlindedHop_read(ser_ref);
53854         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53855         return tag_ptr(ret_conv, true);
53856 }
53857
53858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53859         if (!ptr_is_owned(this_ptr)) return;
53860         void* this_ptr_ptr = untag_ptr(this_ptr);
53861         CHECK_ACCESS(this_ptr_ptr);
53862         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
53863         FREE(untag_ptr(this_ptr));
53864         PaymentPurpose_free(this_ptr_conv);
53865 }
53866
53867 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
53868         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53869         *ret_copy = PaymentPurpose_clone(arg);
53870         int64_t ret_ref = tag_ptr(ret_copy, true);
53871         return ret_ref;
53872 }
53873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53874         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
53875         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
53876         return ret_conv;
53877 }
53878
53879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53880         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
53881         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53882         *ret_copy = PaymentPurpose_clone(orig_conv);
53883         int64_t ret_ref = tag_ptr(ret_copy, true);
53884         return ret_ref;
53885 }
53886
53887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
53888         LDKThirtyTwoBytes payment_preimage_ref;
53889         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
53890         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
53891         LDKThirtyTwoBytes payment_secret_ref;
53892         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
53893         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
53894         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53895         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
53896         int64_t ret_ref = tag_ptr(ret_copy, true);
53897         return ret_ref;
53898 }
53899
53900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
53901         LDKThirtyTwoBytes a_ref;
53902         CHECK((*env)->GetArrayLength(env, a) == 32);
53903         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
53904         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53905         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
53906         int64_t ret_ref = tag_ptr(ret_copy, true);
53907         return ret_ref;
53908 }
53909
53910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53911         LDKPaymentPurpose* a_conv = (LDKPaymentPurpose*)untag_ptr(a);
53912         LDKPaymentPurpose* b_conv = (LDKPaymentPurpose*)untag_ptr(b);
53913         jboolean ret_conv = PaymentPurpose_eq(a_conv, b_conv);
53914         return ret_conv;
53915 }
53916
53917 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
53918         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
53919         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
53920         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53921         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53922         CVec_u8Z_free(ret_var);
53923         return ret_arr;
53924 }
53925
53926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53927         LDKu8slice ser_ref;
53928         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53929         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53930         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
53931         *ret_conv = PaymentPurpose_read(ser_ref);
53932         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53933         return tag_ptr(ret_conv, true);
53934 }
53935
53936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PathFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53937         if (!ptr_is_owned(this_ptr)) return;
53938         void* this_ptr_ptr = untag_ptr(this_ptr);
53939         CHECK_ACCESS(this_ptr_ptr);
53940         LDKPathFailure this_ptr_conv = *(LDKPathFailure*)(this_ptr_ptr);
53941         FREE(untag_ptr(this_ptr));
53942         PathFailure_free(this_ptr_conv);
53943 }
53944
53945 static inline uint64_t PathFailure_clone_ptr(LDKPathFailure *NONNULL_PTR arg) {
53946         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53947         *ret_copy = PathFailure_clone(arg);
53948         int64_t ret_ref = tag_ptr(ret_copy, true);
53949         return ret_ref;
53950 }
53951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53952         LDKPathFailure* arg_conv = (LDKPathFailure*)untag_ptr(arg);
53953         int64_t ret_conv = PathFailure_clone_ptr(arg_conv);
53954         return ret_conv;
53955 }
53956
53957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53958         LDKPathFailure* orig_conv = (LDKPathFailure*)untag_ptr(orig);
53959         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53960         *ret_copy = PathFailure_clone(orig_conv);
53961         int64_t ret_ref = tag_ptr(ret_copy, true);
53962         return ret_ref;
53963 }
53964
53965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1initial_1send(JNIEnv *env, jclass clz, int64_t err) {
53966         void* err_ptr = untag_ptr(err);
53967         CHECK_ACCESS(err_ptr);
53968         LDKAPIError err_conv = *(LDKAPIError*)(err_ptr);
53969         err_conv = APIError_clone((LDKAPIError*)untag_ptr(err));
53970         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53971         *ret_copy = PathFailure_initial_send(err_conv);
53972         int64_t ret_ref = tag_ptr(ret_copy, true);
53973         return ret_ref;
53974 }
53975
53976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1on_1path(JNIEnv *env, jclass clz, int64_t network_update) {
53977         void* network_update_ptr = untag_ptr(network_update);
53978         CHECK_ACCESS(network_update_ptr);
53979         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
53980         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
53981         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53982         *ret_copy = PathFailure_on_path(network_update_conv);
53983         int64_t ret_ref = tag_ptr(ret_copy, true);
53984         return ret_ref;
53985 }
53986
53987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PathFailure_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53988         LDKPathFailure* a_conv = (LDKPathFailure*)untag_ptr(a);
53989         LDKPathFailure* b_conv = (LDKPathFailure*)untag_ptr(b);
53990         jboolean ret_conv = PathFailure_eq(a_conv, b_conv);
53991         return ret_conv;
53992 }
53993
53994 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PathFailure_1write(JNIEnv *env, jclass clz, int64_t obj) {
53995         LDKPathFailure* obj_conv = (LDKPathFailure*)untag_ptr(obj);
53996         LDKCVec_u8Z ret_var = PathFailure_write(obj_conv);
53997         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53998         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53999         CVec_u8Z_free(ret_var);
54000         return ret_arr;
54001 }
54002
54003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54004         LDKu8slice ser_ref;
54005         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54006         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54007         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
54008         *ret_conv = PathFailure_read(ser_ref);
54009         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54010         return tag_ptr(ret_conv, true);
54011 }
54012
54013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54014         if (!ptr_is_owned(this_ptr)) return;
54015         void* this_ptr_ptr = untag_ptr(this_ptr);
54016         CHECK_ACCESS(this_ptr_ptr);
54017         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
54018         FREE(untag_ptr(this_ptr));
54019         ClosureReason_free(this_ptr_conv);
54020 }
54021
54022 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
54023         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54024         *ret_copy = ClosureReason_clone(arg);
54025         int64_t ret_ref = tag_ptr(ret_copy, true);
54026         return ret_ref;
54027 }
54028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54029         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
54030         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
54031         return ret_conv;
54032 }
54033
54034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54035         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
54036         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54037         *ret_copy = ClosureReason_clone(orig_conv);
54038         int64_t ret_ref = tag_ptr(ret_copy, true);
54039         return ret_ref;
54040 }
54041
54042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, int64_t peer_msg) {
54043         LDKUntrustedString peer_msg_conv;
54044         peer_msg_conv.inner = untag_ptr(peer_msg);
54045         peer_msg_conv.is_owned = ptr_is_owned(peer_msg);
54046         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_msg_conv);
54047         peer_msg_conv = UntrustedString_clone(&peer_msg_conv);
54048         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54049         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
54050         int64_t ret_ref = tag_ptr(ret_copy, true);
54051         return ret_ref;
54052 }
54053
54054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
54055         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54056         *ret_copy = ClosureReason_holder_force_closed();
54057         int64_t ret_ref = tag_ptr(ret_copy, true);
54058         return ret_ref;
54059 }
54060
54061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
54062         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54063         *ret_copy = ClosureReason_cooperative_closure();
54064         int64_t ret_ref = tag_ptr(ret_copy, true);
54065         return ret_ref;
54066 }
54067
54068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
54069         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54070         *ret_copy = ClosureReason_commitment_tx_confirmed();
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_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
54076         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54077         *ret_copy = ClosureReason_funding_timed_out();
54078         int64_t ret_ref = tag_ptr(ret_copy, true);
54079         return ret_ref;
54080 }
54081
54082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
54083         LDKStr err_conv = java_to_owned_str(env, err);
54084         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54085         *ret_copy = ClosureReason_processing_error(err_conv);
54086         int64_t ret_ref = tag_ptr(ret_copy, true);
54087         return ret_ref;
54088 }
54089
54090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
54091         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54092         *ret_copy = ClosureReason_disconnected_peer();
54093         int64_t ret_ref = tag_ptr(ret_copy, true);
54094         return ret_ref;
54095 }
54096
54097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
54098         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54099         *ret_copy = ClosureReason_outdated_channel_manager();
54100         int64_t ret_ref = tag_ptr(ret_copy, true);
54101         return ret_ref;
54102 }
54103
54104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosureReason_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54105         LDKClosureReason* a_conv = (LDKClosureReason*)untag_ptr(a);
54106         LDKClosureReason* b_conv = (LDKClosureReason*)untag_ptr(b);
54107         jboolean ret_conv = ClosureReason_eq(a_conv, b_conv);
54108         return ret_conv;
54109 }
54110
54111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
54112         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
54113         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
54114         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54115         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54116         CVec_u8Z_free(ret_var);
54117         return ret_arr;
54118 }
54119
54120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54121         LDKu8slice ser_ref;
54122         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54123         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54124         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
54125         *ret_conv = ClosureReason_read(ser_ref);
54126         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54127         return tag_ptr(ret_conv, true);
54128 }
54129
54130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54131         if (!ptr_is_owned(this_ptr)) return;
54132         void* this_ptr_ptr = untag_ptr(this_ptr);
54133         CHECK_ACCESS(this_ptr_ptr);
54134         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
54135         FREE(untag_ptr(this_ptr));
54136         HTLCDestination_free(this_ptr_conv);
54137 }
54138
54139 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
54140         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54141         *ret_copy = HTLCDestination_clone(arg);
54142         int64_t ret_ref = tag_ptr(ret_copy, true);
54143         return ret_ref;
54144 }
54145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54146         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
54147         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
54148         return ret_conv;
54149 }
54150
54151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54152         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
54153         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54154         *ret_copy = HTLCDestination_clone(orig_conv);
54155         int64_t ret_ref = tag_ptr(ret_copy, true);
54156         return ret_ref;
54157 }
54158
54159 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) {
54160         LDKPublicKey node_id_ref;
54161         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54162         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54163         LDKThirtyTwoBytes channel_id_ref;
54164         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54165         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54166         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54167         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
54168         int64_t ret_ref = tag_ptr(ret_copy, true);
54169         return ret_ref;
54170 }
54171
54172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
54173         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54174         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
54175         int64_t ret_ref = tag_ptr(ret_copy, true);
54176         return ret_ref;
54177 }
54178
54179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1invalid_1forward(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
54180         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54181         *ret_copy = HTLCDestination_invalid_forward(requested_forward_scid);
54182         int64_t ret_ref = tag_ptr(ret_copy, true);
54183         return ret_ref;
54184 }
54185
54186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
54187         LDKThirtyTwoBytes payment_hash_ref;
54188         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54189         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54190         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54191         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
54192         int64_t ret_ref = tag_ptr(ret_copy, true);
54193         return ret_ref;
54194 }
54195
54196 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54197         LDKHTLCDestination* a_conv = (LDKHTLCDestination*)untag_ptr(a);
54198         LDKHTLCDestination* b_conv = (LDKHTLCDestination*)untag_ptr(b);
54199         jboolean ret_conv = HTLCDestination_eq(a_conv, b_conv);
54200         return ret_conv;
54201 }
54202
54203 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
54204         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
54205         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
54206         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54207         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54208         CVec_u8Z_free(ret_var);
54209         return ret_arr;
54210 }
54211
54212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54213         LDKu8slice ser_ref;
54214         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54215         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54216         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
54217         *ret_conv = HTLCDestination_read(ser_ref);
54218         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54219         return tag_ptr(ret_conv, true);
54220 }
54221
54222 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54223         LDKPaymentFailureReason* orig_conv = (LDKPaymentFailureReason*)untag_ptr(orig);
54224         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_clone(orig_conv));
54225         return ret_conv;
54226 }
54227
54228 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1recipient_1rejected(JNIEnv *env, jclass clz) {
54229         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_recipient_rejected());
54230         return ret_conv;
54231 }
54232
54233 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1user_1abandoned(JNIEnv *env, jclass clz) {
54234         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_user_abandoned());
54235         return ret_conv;
54236 }
54237
54238 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1retries_1exhausted(JNIEnv *env, jclass clz) {
54239         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_retries_exhausted());
54240         return ret_conv;
54241 }
54242
54243 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1payment_1expired(JNIEnv *env, jclass clz) {
54244         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_payment_expired());
54245         return ret_conv;
54246 }
54247
54248 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1route_1not_1found(JNIEnv *env, jclass clz) {
54249         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_route_not_found());
54250         return ret_conv;
54251 }
54252
54253 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1unexpected_1error(JNIEnv *env, jclass clz) {
54254         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_unexpected_error());
54255         return ret_conv;
54256 }
54257
54258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54259         LDKPaymentFailureReason* a_conv = (LDKPaymentFailureReason*)untag_ptr(a);
54260         LDKPaymentFailureReason* b_conv = (LDKPaymentFailureReason*)untag_ptr(b);
54261         jboolean ret_conv = PaymentFailureReason_eq(a_conv, b_conv);
54262         return ret_conv;
54263 }
54264
54265 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
54266         LDKPaymentFailureReason* obj_conv = (LDKPaymentFailureReason*)untag_ptr(obj);
54267         LDKCVec_u8Z ret_var = PaymentFailureReason_write(obj_conv);
54268         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54269         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54270         CVec_u8Z_free(ret_var);
54271         return ret_arr;
54272 }
54273
54274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54275         LDKu8slice ser_ref;
54276         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54277         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54278         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
54279         *ret_conv = PaymentFailureReason_read(ser_ref);
54280         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54281         return tag_ptr(ret_conv, true);
54282 }
54283
54284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54285         if (!ptr_is_owned(this_ptr)) return;
54286         void* this_ptr_ptr = untag_ptr(this_ptr);
54287         CHECK_ACCESS(this_ptr_ptr);
54288         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
54289         FREE(untag_ptr(this_ptr));
54290         Event_free(this_ptr_conv);
54291 }
54292
54293 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
54294         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54295         *ret_copy = Event_clone(arg);
54296         int64_t ret_ref = tag_ptr(ret_copy, true);
54297         return ret_ref;
54298 }
54299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54300         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
54301         int64_t ret_conv = Event_clone_ptr(arg_conv);
54302         return ret_conv;
54303 }
54304
54305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54306         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
54307         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54308         *ret_copy = Event_clone(orig_conv);
54309         int64_t ret_ref = tag_ptr(ret_copy, true);
54310         return ret_ref;
54311 }
54312
54313 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) {
54314         LDKThirtyTwoBytes temporary_channel_id_ref;
54315         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
54316         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
54317         LDKPublicKey counterparty_node_id_ref;
54318         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54319         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54320         LDKCVec_u8Z output_script_ref;
54321         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
54322         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
54323         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
54324         LDKU128 user_channel_id_ref;
54325         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54326         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54327         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54328         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id_ref);
54329         int64_t ret_ref = tag_ptr(ret_copy, true);
54330         return ret_ref;
54331 }
54332
54333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1claimable(JNIEnv *env, jclass clz, int8_tArray receiver_node_id, int8_tArray payment_hash, int64_t onion_fields, int64_t amount_msat, int64_t purpose, int8_tArray via_channel_id, int64_t via_user_channel_id, int64_t claim_deadline) {
54334         LDKPublicKey receiver_node_id_ref;
54335         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
54336         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
54337         LDKThirtyTwoBytes payment_hash_ref;
54338         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54339         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54340         LDKRecipientOnionFields onion_fields_conv;
54341         onion_fields_conv.inner = untag_ptr(onion_fields);
54342         onion_fields_conv.is_owned = ptr_is_owned(onion_fields);
54343         CHECK_INNER_FIELD_ACCESS_OR_NULL(onion_fields_conv);
54344         onion_fields_conv = RecipientOnionFields_clone(&onion_fields_conv);
54345         void* purpose_ptr = untag_ptr(purpose);
54346         CHECK_ACCESS(purpose_ptr);
54347         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
54348         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
54349         LDKThirtyTwoBytes via_channel_id_ref;
54350         CHECK((*env)->GetArrayLength(env, via_channel_id) == 32);
54351         (*env)->GetByteArrayRegion(env, via_channel_id, 0, 32, via_channel_id_ref.data);
54352         void* via_user_channel_id_ptr = untag_ptr(via_user_channel_id);
54353         CHECK_ACCESS(via_user_channel_id_ptr);
54354         LDKCOption_u128Z via_user_channel_id_conv = *(LDKCOption_u128Z*)(via_user_channel_id_ptr);
54355         via_user_channel_id_conv = COption_u128Z_clone((LDKCOption_u128Z*)untag_ptr(via_user_channel_id));
54356         void* claim_deadline_ptr = untag_ptr(claim_deadline);
54357         CHECK_ACCESS(claim_deadline_ptr);
54358         LDKCOption_u32Z claim_deadline_conv = *(LDKCOption_u32Z*)(claim_deadline_ptr);
54359         claim_deadline_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(claim_deadline));
54360         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54361         *ret_copy = Event_payment_claimable(receiver_node_id_ref, payment_hash_ref, onion_fields_conv, amount_msat, purpose_conv, via_channel_id_ref, via_user_channel_id_conv, claim_deadline_conv);
54362         int64_t ret_ref = tag_ptr(ret_copy, true);
54363         return ret_ref;
54364 }
54365
54366 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) {
54367         LDKPublicKey receiver_node_id_ref;
54368         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
54369         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
54370         LDKThirtyTwoBytes payment_hash_ref;
54371         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54372         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54373         void* purpose_ptr = untag_ptr(purpose);
54374         CHECK_ACCESS(purpose_ptr);
54375         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
54376         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
54377         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54378         *ret_copy = Event_payment_claimed(receiver_node_id_ref, payment_hash_ref, amount_msat, purpose_conv);
54379         int64_t ret_ref = tag_ptr(ret_copy, true);
54380         return ret_ref;
54381 }
54382
54383 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) {
54384         LDKThirtyTwoBytes payment_id_ref;
54385         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54386         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54387         LDKThirtyTwoBytes payment_preimage_ref;
54388         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
54389         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
54390         LDKThirtyTwoBytes payment_hash_ref;
54391         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54392         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54393         void* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
54394         CHECK_ACCESS(fee_paid_msat_ptr);
54395         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
54396         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
54397         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54398         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
54399         int64_t ret_ref = tag_ptr(ret_copy, true);
54400         return ret_ref;
54401 }
54402
54403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_t reason) {
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         LDKThirtyTwoBytes payment_hash_ref;
54408         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54409         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54410         void* reason_ptr = untag_ptr(reason);
54411         CHECK_ACCESS(reason_ptr);
54412         LDKCOption_PaymentFailureReasonZ reason_conv = *(LDKCOption_PaymentFailureReasonZ*)(reason_ptr);
54413         reason_conv = COption_PaymentFailureReasonZ_clone((LDKCOption_PaymentFailureReasonZ*)untag_ptr(reason));
54414         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54415         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref, reason_conv);
54416         int64_t ret_ref = tag_ptr(ret_copy, true);
54417         return ret_ref;
54418 }
54419
54420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1successful(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_t path) {
54421         LDKThirtyTwoBytes payment_id_ref;
54422         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54423         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54424         LDKThirtyTwoBytes payment_hash_ref;
54425         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54426         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54427         LDKPath path_conv;
54428         path_conv.inner = untag_ptr(path);
54429         path_conv.is_owned = ptr_is_owned(path);
54430         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54431         path_conv = Path_clone(&path_conv);
54432         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54433         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_conv);
54434         int64_t ret_ref = tag_ptr(ret_copy, true);
54435         return ret_ref;
54436 }
54437
54438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, jboolean payment_failed_permanently, int64_t failure, int64_t path, int64_t short_channel_id) {
54439         LDKThirtyTwoBytes payment_id_ref;
54440         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54441         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54442         LDKThirtyTwoBytes payment_hash_ref;
54443         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54444         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54445         void* failure_ptr = untag_ptr(failure);
54446         CHECK_ACCESS(failure_ptr);
54447         LDKPathFailure failure_conv = *(LDKPathFailure*)(failure_ptr);
54448         failure_conv = PathFailure_clone((LDKPathFailure*)untag_ptr(failure));
54449         LDKPath path_conv;
54450         path_conv.inner = untag_ptr(path);
54451         path_conv.is_owned = ptr_is_owned(path);
54452         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54453         path_conv = Path_clone(&path_conv);
54454         void* short_channel_id_ptr = untag_ptr(short_channel_id);
54455         CHECK_ACCESS(short_channel_id_ptr);
54456         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
54457         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
54458         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54459         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, payment_failed_permanently, failure_conv, path_conv, short_channel_id_conv);
54460         int64_t ret_ref = tag_ptr(ret_copy, true);
54461         return ret_ref;
54462 }
54463
54464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1successful(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_t path) {
54465         LDKThirtyTwoBytes payment_id_ref;
54466         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54467         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54468         LDKThirtyTwoBytes payment_hash_ref;
54469         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54470         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54471         LDKPath path_conv;
54472         path_conv.inner = untag_ptr(path);
54473         path_conv.is_owned = ptr_is_owned(path);
54474         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54475         path_conv = Path_clone(&path_conv);
54476         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54477         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_conv);
54478         int64_t ret_ref = tag_ptr(ret_copy, true);
54479         return ret_ref;
54480 }
54481
54482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_t path, int64_t short_channel_id) {
54483         LDKThirtyTwoBytes payment_id_ref;
54484         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54485         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54486         LDKThirtyTwoBytes payment_hash_ref;
54487         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54488         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54489         LDKPath path_conv;
54490         path_conv.inner = untag_ptr(path);
54491         path_conv.is_owned = ptr_is_owned(path);
54492         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54493         path_conv = Path_clone(&path_conv);
54494         void* short_channel_id_ptr = untag_ptr(short_channel_id);
54495         CHECK_ACCESS(short_channel_id_ptr);
54496         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
54497         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
54498         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54499         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_conv, short_channel_id_conv);
54500         int64_t ret_ref = tag_ptr(ret_copy, true);
54501         return ret_ref;
54502 }
54503
54504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
54505         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54506         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
54507         int64_t ret_ref = tag_ptr(ret_copy, true);
54508         return ret_ref;
54509 }
54510
54511 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) {
54512         LDKThirtyTwoBytes intercept_id_ref;
54513         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
54514         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
54515         LDKThirtyTwoBytes payment_hash_ref;
54516         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54517         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54518         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54519         *ret_copy = Event_htlcintercepted(intercept_id_ref, requested_next_hop_scid, payment_hash_ref, inbound_amount_msat, expected_outbound_amount_msat);
54520         int64_t ret_ref = tag_ptr(ret_copy, true);
54521         return ret_ref;
54522 }
54523
54524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
54525         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
54526         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
54527         if (outputs_constr.datalen > 0)
54528                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
54529         else
54530                 outputs_constr.data = NULL;
54531         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
54532         for (size_t b = 0; b < outputs_constr.datalen; b++) {
54533                 int64_t outputs_conv_27 = outputs_vals[b];
54534                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
54535                 CHECK_ACCESS(outputs_conv_27_ptr);
54536                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
54537                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
54538                 outputs_constr.data[b] = outputs_conv_27_conv;
54539         }
54540         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
54541         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54542         *ret_copy = Event_spendable_outputs(outputs_constr);
54543         int64_t ret_ref = tag_ptr(ret_copy, true);
54544         return ret_ref;
54545 }
54546
54547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int8_tArray prev_channel_id, int8_tArray next_channel_id, int64_t fee_earned_msat, jboolean claim_from_onchain_tx, int64_t outbound_amount_forwarded_msat) {
54548         LDKThirtyTwoBytes prev_channel_id_ref;
54549         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
54550         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
54551         LDKThirtyTwoBytes next_channel_id_ref;
54552         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
54553         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
54554         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
54555         CHECK_ACCESS(fee_earned_msat_ptr);
54556         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
54557         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
54558         void* outbound_amount_forwarded_msat_ptr = untag_ptr(outbound_amount_forwarded_msat);
54559         CHECK_ACCESS(outbound_amount_forwarded_msat_ptr);
54560         LDKCOption_u64Z outbound_amount_forwarded_msat_conv = *(LDKCOption_u64Z*)(outbound_amount_forwarded_msat_ptr);
54561         outbound_amount_forwarded_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_amount_forwarded_msat));
54562         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54563         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx, outbound_amount_forwarded_msat_conv);
54564         int64_t ret_ref = tag_ptr(ret_copy, true);
54565         return ret_ref;
54566 }
54567
54568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1pending(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray user_channel_id, int8_tArray former_temporary_channel_id, int8_tArray counterparty_node_id, int64_t funding_txo) {
54569         LDKThirtyTwoBytes channel_id_ref;
54570         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54571         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54572         LDKU128 user_channel_id_ref;
54573         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54574         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54575         LDKThirtyTwoBytes former_temporary_channel_id_ref;
54576         CHECK((*env)->GetArrayLength(env, former_temporary_channel_id) == 32);
54577         (*env)->GetByteArrayRegion(env, former_temporary_channel_id, 0, 32, former_temporary_channel_id_ref.data);
54578         LDKPublicKey counterparty_node_id_ref;
54579         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54580         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54581         LDKOutPoint funding_txo_conv;
54582         funding_txo_conv.inner = untag_ptr(funding_txo);
54583         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
54584         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
54585         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
54586         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54587         *ret_copy = Event_channel_pending(channel_id_ref, user_channel_id_ref, former_temporary_channel_id_ref, counterparty_node_id_ref, funding_txo_conv);
54588         int64_t ret_ref = tag_ptr(ret_copy, true);
54589         return ret_ref;
54590 }
54591
54592 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) {
54593         LDKThirtyTwoBytes channel_id_ref;
54594         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54595         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54596         LDKU128 user_channel_id_ref;
54597         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54598         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54599         LDKPublicKey counterparty_node_id_ref;
54600         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54601         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54602         LDKChannelTypeFeatures channel_type_conv;
54603         channel_type_conv.inner = untag_ptr(channel_type);
54604         channel_type_conv.is_owned = ptr_is_owned(channel_type);
54605         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
54606         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
54607         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54608         *ret_copy = Event_channel_ready(channel_id_ref, user_channel_id_ref, counterparty_node_id_ref, channel_type_conv);
54609         int64_t ret_ref = tag_ptr(ret_copy, true);
54610         return ret_ref;
54611 }
54612
54613 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) {
54614         LDKThirtyTwoBytes channel_id_ref;
54615         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54616         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54617         LDKU128 user_channel_id_ref;
54618         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54619         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54620         void* reason_ptr = untag_ptr(reason);
54621         CHECK_ACCESS(reason_ptr);
54622         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
54623         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
54624         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54625         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id_ref, reason_conv);
54626         int64_t ret_ref = tag_ptr(ret_copy, true);
54627         return ret_ref;
54628 }
54629
54630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
54631         LDKThirtyTwoBytes channel_id_ref;
54632         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54633         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54634         LDKTransaction transaction_ref;
54635         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
54636         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
54637         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
54638         transaction_ref.data_is_owned = true;
54639         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54640         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
54641         int64_t ret_ref = tag_ptr(ret_copy, true);
54642         return ret_ref;
54643 }
54644
54645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_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) {
54646         LDKThirtyTwoBytes temporary_channel_id_ref;
54647         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
54648         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
54649         LDKPublicKey counterparty_node_id_ref;
54650         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54651         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54652         LDKChannelTypeFeatures channel_type_conv;
54653         channel_type_conv.inner = untag_ptr(channel_type);
54654         channel_type_conv.is_owned = ptr_is_owned(channel_type);
54655         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
54656         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
54657         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54658         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
54659         int64_t ret_ref = tag_ptr(ret_copy, true);
54660         return ret_ref;
54661 }
54662
54663 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) {
54664         LDKThirtyTwoBytes prev_channel_id_ref;
54665         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
54666         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
54667         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
54668         CHECK_ACCESS(failed_next_destination_ptr);
54669         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
54670         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
54671         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54672         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
54673         int64_t ret_ref = tag_ptr(ret_copy, true);
54674         return ret_ref;
54675 }
54676
54677 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Event_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54678         LDKEvent* a_conv = (LDKEvent*)untag_ptr(a);
54679         LDKEvent* b_conv = (LDKEvent*)untag_ptr(b);
54680         jboolean ret_conv = Event_eq(a_conv, b_conv);
54681         return ret_conv;
54682 }
54683
54684 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
54685         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
54686         LDKCVec_u8Z ret_var = Event_write(obj_conv);
54687         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54688         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54689         CVec_u8Z_free(ret_var);
54690         return ret_arr;
54691 }
54692
54693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54694         LDKu8slice ser_ref;
54695         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54696         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54697         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
54698         *ret_conv = Event_read(ser_ref);
54699         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54700         return tag_ptr(ret_conv, true);
54701 }
54702
54703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54704         if (!ptr_is_owned(this_ptr)) return;
54705         void* this_ptr_ptr = untag_ptr(this_ptr);
54706         CHECK_ACCESS(this_ptr_ptr);
54707         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
54708         FREE(untag_ptr(this_ptr));
54709         MessageSendEvent_free(this_ptr_conv);
54710 }
54711
54712 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
54713         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54714         *ret_copy = MessageSendEvent_clone(arg);
54715         int64_t ret_ref = tag_ptr(ret_copy, true);
54716         return ret_ref;
54717 }
54718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54719         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
54720         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
54721         return ret_conv;
54722 }
54723
54724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54725         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
54726         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54727         *ret_copy = MessageSendEvent_clone(orig_conv);
54728         int64_t ret_ref = tag_ptr(ret_copy, true);
54729         return ret_ref;
54730 }
54731
54732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54733         LDKPublicKey node_id_ref;
54734         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54735         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54736         LDKAcceptChannel msg_conv;
54737         msg_conv.inner = untag_ptr(msg);
54738         msg_conv.is_owned = ptr_is_owned(msg);
54739         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54740         msg_conv = AcceptChannel_clone(&msg_conv);
54741         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54742         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
54743         int64_t ret_ref = tag_ptr(ret_copy, true);
54744         return ret_ref;
54745 }
54746
54747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54748         LDKPublicKey node_id_ref;
54749         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54750         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54751         LDKOpenChannel msg_conv;
54752         msg_conv.inner = untag_ptr(msg);
54753         msg_conv.is_owned = ptr_is_owned(msg);
54754         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54755         msg_conv = OpenChannel_clone(&msg_conv);
54756         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54757         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
54758         int64_t ret_ref = tag_ptr(ret_copy, true);
54759         return ret_ref;
54760 }
54761
54762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54763         LDKPublicKey node_id_ref;
54764         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54765         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54766         LDKFundingCreated msg_conv;
54767         msg_conv.inner = untag_ptr(msg);
54768         msg_conv.is_owned = ptr_is_owned(msg);
54769         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54770         msg_conv = FundingCreated_clone(&msg_conv);
54771         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54772         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
54773         int64_t ret_ref = tag_ptr(ret_copy, true);
54774         return ret_ref;
54775 }
54776
54777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54778         LDKPublicKey node_id_ref;
54779         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54780         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54781         LDKFundingSigned msg_conv;
54782         msg_conv.inner = untag_ptr(msg);
54783         msg_conv.is_owned = ptr_is_owned(msg);
54784         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54785         msg_conv = FundingSigned_clone(&msg_conv);
54786         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54787         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
54788         int64_t ret_ref = tag_ptr(ret_copy, true);
54789         return ret_ref;
54790 }
54791
54792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54793         LDKPublicKey node_id_ref;
54794         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54795         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54796         LDKChannelReady msg_conv;
54797         msg_conv.inner = untag_ptr(msg);
54798         msg_conv.is_owned = ptr_is_owned(msg);
54799         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54800         msg_conv = ChannelReady_clone(&msg_conv);
54801         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54802         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
54803         int64_t ret_ref = tag_ptr(ret_copy, true);
54804         return ret_ref;
54805 }
54806
54807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54808         LDKPublicKey node_id_ref;
54809         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54810         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54811         LDKAnnouncementSignatures msg_conv;
54812         msg_conv.inner = untag_ptr(msg);
54813         msg_conv.is_owned = ptr_is_owned(msg);
54814         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54815         msg_conv = AnnouncementSignatures_clone(&msg_conv);
54816         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54817         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
54818         int64_t ret_ref = tag_ptr(ret_copy, true);
54819         return ret_ref;
54820 }
54821
54822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
54823         LDKPublicKey node_id_ref;
54824         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54825         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54826         LDKCommitmentUpdate updates_conv;
54827         updates_conv.inner = untag_ptr(updates);
54828         updates_conv.is_owned = ptr_is_owned(updates);
54829         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
54830         updates_conv = CommitmentUpdate_clone(&updates_conv);
54831         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54832         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
54833         int64_t ret_ref = tag_ptr(ret_copy, true);
54834         return ret_ref;
54835 }
54836
54837 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) {
54838         LDKPublicKey node_id_ref;
54839         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54840         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54841         LDKRevokeAndACK msg_conv;
54842         msg_conv.inner = untag_ptr(msg);
54843         msg_conv.is_owned = ptr_is_owned(msg);
54844         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54845         msg_conv = RevokeAndACK_clone(&msg_conv);
54846         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54847         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
54848         int64_t ret_ref = tag_ptr(ret_copy, true);
54849         return ret_ref;
54850 }
54851
54852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54853         LDKPublicKey node_id_ref;
54854         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54855         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54856         LDKClosingSigned msg_conv;
54857         msg_conv.inner = untag_ptr(msg);
54858         msg_conv.is_owned = ptr_is_owned(msg);
54859         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54860         msg_conv = ClosingSigned_clone(&msg_conv);
54861         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54862         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
54863         int64_t ret_ref = tag_ptr(ret_copy, true);
54864         return ret_ref;
54865 }
54866
54867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54868         LDKPublicKey node_id_ref;
54869         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54870         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54871         LDKShutdown msg_conv;
54872         msg_conv.inner = untag_ptr(msg);
54873         msg_conv.is_owned = ptr_is_owned(msg);
54874         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54875         msg_conv = Shutdown_clone(&msg_conv);
54876         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54877         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
54878         int64_t ret_ref = tag_ptr(ret_copy, true);
54879         return ret_ref;
54880 }
54881
54882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54883         LDKPublicKey node_id_ref;
54884         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54885         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54886         LDKChannelReestablish msg_conv;
54887         msg_conv.inner = untag_ptr(msg);
54888         msg_conv.is_owned = ptr_is_owned(msg);
54889         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54890         msg_conv = ChannelReestablish_clone(&msg_conv);
54891         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54892         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
54893         int64_t ret_ref = tag_ptr(ret_copy, true);
54894         return ret_ref;
54895 }
54896
54897 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) {
54898         LDKPublicKey node_id_ref;
54899         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54900         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54901         LDKChannelAnnouncement msg_conv;
54902         msg_conv.inner = untag_ptr(msg);
54903         msg_conv.is_owned = ptr_is_owned(msg);
54904         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54905         msg_conv = ChannelAnnouncement_clone(&msg_conv);
54906         LDKChannelUpdate update_msg_conv;
54907         update_msg_conv.inner = untag_ptr(update_msg);
54908         update_msg_conv.is_owned = ptr_is_owned(update_msg);
54909         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
54910         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
54911         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54912         *ret_copy = MessageSendEvent_send_channel_announcement(node_id_ref, msg_conv, update_msg_conv);
54913         int64_t ret_ref = tag_ptr(ret_copy, true);
54914         return ret_ref;
54915 }
54916
54917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
54918         LDKChannelAnnouncement msg_conv;
54919         msg_conv.inner = untag_ptr(msg);
54920         msg_conv.is_owned = ptr_is_owned(msg);
54921         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54922         msg_conv = ChannelAnnouncement_clone(&msg_conv);
54923         LDKChannelUpdate update_msg_conv;
54924         update_msg_conv.inner = untag_ptr(update_msg);
54925         update_msg_conv.is_owned = ptr_is_owned(update_msg);
54926         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
54927         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
54928         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54929         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
54930         int64_t ret_ref = tag_ptr(ret_copy, true);
54931         return ret_ref;
54932 }
54933
54934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
54935         LDKChannelUpdate msg_conv;
54936         msg_conv.inner = untag_ptr(msg);
54937         msg_conv.is_owned = ptr_is_owned(msg);
54938         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54939         msg_conv = ChannelUpdate_clone(&msg_conv);
54940         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54941         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
54942         int64_t ret_ref = tag_ptr(ret_copy, true);
54943         return ret_ref;
54944 }
54945
54946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
54947         LDKNodeAnnouncement msg_conv;
54948         msg_conv.inner = untag_ptr(msg);
54949         msg_conv.is_owned = ptr_is_owned(msg);
54950         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54951         msg_conv = NodeAnnouncement_clone(&msg_conv);
54952         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54953         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
54954         int64_t ret_ref = tag_ptr(ret_copy, true);
54955         return ret_ref;
54956 }
54957
54958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54959         LDKPublicKey node_id_ref;
54960         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54961         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54962         LDKChannelUpdate msg_conv;
54963         msg_conv.inner = untag_ptr(msg);
54964         msg_conv.is_owned = ptr_is_owned(msg);
54965         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54966         msg_conv = ChannelUpdate_clone(&msg_conv);
54967         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54968         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
54969         int64_t ret_ref = tag_ptr(ret_copy, true);
54970         return ret_ref;
54971 }
54972
54973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
54974         LDKPublicKey node_id_ref;
54975         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54976         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54977         void* action_ptr = untag_ptr(action);
54978         CHECK_ACCESS(action_ptr);
54979         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
54980         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
54981         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54982         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
54983         int64_t ret_ref = tag_ptr(ret_copy, true);
54984         return ret_ref;
54985 }
54986
54987 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) {
54988         LDKPublicKey node_id_ref;
54989         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54990         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54991         LDKQueryChannelRange msg_conv;
54992         msg_conv.inner = untag_ptr(msg);
54993         msg_conv.is_owned = ptr_is_owned(msg);
54994         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54995         msg_conv = QueryChannelRange_clone(&msg_conv);
54996         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54997         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
54998         int64_t ret_ref = tag_ptr(ret_copy, true);
54999         return ret_ref;
55000 }
55001
55002 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) {
55003         LDKPublicKey node_id_ref;
55004         CHECK((*env)->GetArrayLength(env, node_id) == 33);
55005         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
55006         LDKQueryShortChannelIds msg_conv;
55007         msg_conv.inner = untag_ptr(msg);
55008         msg_conv.is_owned = ptr_is_owned(msg);
55009         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
55010         msg_conv = QueryShortChannelIds_clone(&msg_conv);
55011         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
55012         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
55013         int64_t ret_ref = tag_ptr(ret_copy, true);
55014         return ret_ref;
55015 }
55016
55017 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) {
55018         LDKPublicKey node_id_ref;
55019         CHECK((*env)->GetArrayLength(env, node_id) == 33);
55020         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
55021         LDKReplyChannelRange msg_conv;
55022         msg_conv.inner = untag_ptr(msg);
55023         msg_conv.is_owned = ptr_is_owned(msg);
55024         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
55025         msg_conv = ReplyChannelRange_clone(&msg_conv);
55026         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
55027         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
55028         int64_t ret_ref = tag_ptr(ret_copy, true);
55029         return ret_ref;
55030 }
55031
55032 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) {
55033         LDKPublicKey node_id_ref;
55034         CHECK((*env)->GetArrayLength(env, node_id) == 33);
55035         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
55036         LDKGossipTimestampFilter msg_conv;
55037         msg_conv.inner = untag_ptr(msg);
55038         msg_conv.is_owned = ptr_is_owned(msg);
55039         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
55040         msg_conv = GossipTimestampFilter_clone(&msg_conv);
55041         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
55042         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
55043         int64_t ret_ref = tag_ptr(ret_copy, true);
55044         return ret_ref;
55045 }
55046
55047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55048         if (!ptr_is_owned(this_ptr)) return;
55049         void* this_ptr_ptr = untag_ptr(this_ptr);
55050         CHECK_ACCESS(this_ptr_ptr);
55051         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
55052         FREE(untag_ptr(this_ptr));
55053         MessageSendEventsProvider_free(this_ptr_conv);
55054 }
55055
55056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55057         if (!ptr_is_owned(this_ptr)) return;
55058         void* this_ptr_ptr = untag_ptr(this_ptr);
55059         CHECK_ACCESS(this_ptr_ptr);
55060         LDKOnionMessageProvider this_ptr_conv = *(LDKOnionMessageProvider*)(this_ptr_ptr);
55061         FREE(untag_ptr(this_ptr));
55062         OnionMessageProvider_free(this_ptr_conv);
55063 }
55064
55065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55066         if (!ptr_is_owned(this_ptr)) return;
55067         void* this_ptr_ptr = untag_ptr(this_ptr);
55068         CHECK_ACCESS(this_ptr_ptr);
55069         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
55070         FREE(untag_ptr(this_ptr));
55071         EventsProvider_free(this_ptr_conv);
55072 }
55073
55074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55075         if (!ptr_is_owned(this_ptr)) return;
55076         void* this_ptr_ptr = untag_ptr(this_ptr);
55077         CHECK_ACCESS(this_ptr_ptr);
55078         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
55079         FREE(untag_ptr(this_ptr));
55080         EventHandler_free(this_ptr_conv);
55081 }
55082
55083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55084         LDKFilesystemPersister this_obj_conv;
55085         this_obj_conv.inner = untag_ptr(this_obj);
55086         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55088         FilesystemPersister_free(this_obj_conv);
55089 }
55090
55091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
55092         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
55093         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
55094         int64_t ret_ref = 0;
55095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55096         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55097         return ret_ref;
55098 }
55099
55100 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
55101         LDKFilesystemPersister this_arg_conv;
55102         this_arg_conv.inner = untag_ptr(this_arg);
55103         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55105         this_arg_conv.is_owned = false;
55106         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
55107         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
55108         Str_free(ret_str);
55109         return ret_conv;
55110 }
55111
55112 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) {
55113         LDKFilesystemPersister this_arg_conv;
55114         this_arg_conv.inner = untag_ptr(this_arg);
55115         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55117         this_arg_conv.is_owned = false;
55118         void* entropy_source_ptr = untag_ptr(entropy_source);
55119         CHECK_ACCESS(entropy_source_ptr);
55120         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
55121         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
55122                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55123                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
55124         }
55125         void* signer_provider_ptr = untag_ptr(signer_provider);
55126         if (ptr_is_owned(signer_provider)) { CHECK_ACCESS(signer_provider_ptr); }
55127         LDKSignerProvider* signer_provider_conv = (LDKSignerProvider*)signer_provider_ptr;
55128         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
55129         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, entropy_source_conv, signer_provider_conv);
55130         return tag_ptr(ret_conv, true);
55131 }
55132
55133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55134         LDKBackgroundProcessor this_obj_conv;
55135         this_obj_conv.inner = untag_ptr(this_obj);
55136         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55138         BackgroundProcessor_free(this_obj_conv);
55139 }
55140
55141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55142         if (!ptr_is_owned(this_ptr)) return;
55143         void* this_ptr_ptr = untag_ptr(this_ptr);
55144         CHECK_ACCESS(this_ptr_ptr);
55145         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
55146         FREE(untag_ptr(this_ptr));
55147         GossipSync_free(this_ptr_conv);
55148 }
55149
55150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
55151         LDKP2PGossipSync a_conv;
55152         a_conv.inner = untag_ptr(a);
55153         a_conv.is_owned = ptr_is_owned(a);
55154         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55155         a_conv.is_owned = false;
55156         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
55157         *ret_copy = GossipSync_p2_p(&a_conv);
55158         int64_t ret_ref = tag_ptr(ret_copy, true);
55159         return ret_ref;
55160 }
55161
55162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
55163         LDKRapidGossipSync a_conv;
55164         a_conv.inner = untag_ptr(a);
55165         a_conv.is_owned = ptr_is_owned(a);
55166         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55167         a_conv.is_owned = false;
55168         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
55169         *ret_copy = GossipSync_rapid(&a_conv);
55170         int64_t ret_ref = tag_ptr(ret_copy, true);
55171         return ret_ref;
55172 }
55173
55174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
55175         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
55176         *ret_copy = GossipSync_none();
55177         int64_t ret_ref = tag_ptr(ret_copy, true);
55178         return ret_ref;
55179 }
55180
55181 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) {
55182         void* persister_ptr = untag_ptr(persister);
55183         CHECK_ACCESS(persister_ptr);
55184         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
55185         if (persister_conv.free == LDKPersister_JCalls_free) {
55186                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55187                 LDKPersister_JCalls_cloned(&persister_conv);
55188         }
55189         void* event_handler_ptr = untag_ptr(event_handler);
55190         CHECK_ACCESS(event_handler_ptr);
55191         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
55192         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
55193                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55194                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
55195         }
55196         LDKChainMonitor chain_monitor_conv;
55197         chain_monitor_conv.inner = untag_ptr(chain_monitor);
55198         chain_monitor_conv.is_owned = ptr_is_owned(chain_monitor);
55199         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
55200         chain_monitor_conv.is_owned = false;
55201         LDKChannelManager channel_manager_conv;
55202         channel_manager_conv.inner = untag_ptr(channel_manager);
55203         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
55204         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
55205         channel_manager_conv.is_owned = false;
55206         void* gossip_sync_ptr = untag_ptr(gossip_sync);
55207         CHECK_ACCESS(gossip_sync_ptr);
55208         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
55209         // WARNING: we may need a move here but no clone is available for LDKGossipSync
55210         LDKPeerManager peer_manager_conv;
55211         peer_manager_conv.inner = untag_ptr(peer_manager);
55212         peer_manager_conv.is_owned = ptr_is_owned(peer_manager);
55213         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
55214         peer_manager_conv.is_owned = false;
55215         void* logger_ptr = untag_ptr(logger);
55216         CHECK_ACCESS(logger_ptr);
55217         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
55218         if (logger_conv.free == LDKLogger_JCalls_free) {
55219                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55220                 LDKLogger_JCalls_cloned(&logger_conv);
55221         }
55222         void* scorer_ptr = untag_ptr(scorer);
55223         CHECK_ACCESS(scorer_ptr);
55224         LDKCOption_WriteableScoreZ scorer_conv = *(LDKCOption_WriteableScoreZ*)(scorer_ptr);
55225         // WARNING: we may need a move here but no clone is available for LDKCOption_WriteableScoreZ
55226         if (scorer_conv.tag == LDKCOption_WriteableScoreZ_Some) {
55227                 // Manually implement clone for Java trait instances
55228                 if (scorer_conv.some.free == LDKWriteableScore_JCalls_free) {
55229                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55230                         LDKWriteableScore_JCalls_cloned(&scorer_conv.some);
55231                 }
55232         }
55233         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);
55234         int64_t ret_ref = 0;
55235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55236         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55237         return ret_ref;
55238 }
55239
55240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
55241         LDKBackgroundProcessor this_arg_conv;
55242         this_arg_conv.inner = untag_ptr(this_arg);
55243         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55245         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
55246         
55247         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
55248         *ret_conv = BackgroundProcessor_join(this_arg_conv);
55249         return tag_ptr(ret_conv, true);
55250 }
55251
55252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
55253         LDKBackgroundProcessor this_arg_conv;
55254         this_arg_conv.inner = untag_ptr(this_arg);
55255         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55257         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
55258         
55259         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
55260         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
55261         return tag_ptr(ret_conv, true);
55262 }
55263
55264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55265         if (!ptr_is_owned(this_ptr)) return;
55266         void* this_ptr_ptr = untag_ptr(this_ptr);
55267         CHECK_ACCESS(this_ptr_ptr);
55268         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
55269         FREE(untag_ptr(this_ptr));
55270         ParseError_free(this_ptr_conv);
55271 }
55272
55273 static inline uint64_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
55274         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55275         *ret_copy = ParseError_clone(arg);
55276         int64_t ret_ref = tag_ptr(ret_copy, true);
55277         return ret_ref;
55278 }
55279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55280         LDKParseError* arg_conv = (LDKParseError*)untag_ptr(arg);
55281         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
55282         return ret_conv;
55283 }
55284
55285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55286         LDKParseError* orig_conv = (LDKParseError*)untag_ptr(orig);
55287         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55288         *ret_copy = ParseError_clone(orig_conv);
55289         int64_t ret_ref = tag_ptr(ret_copy, true);
55290         return ret_ref;
55291 }
55292
55293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
55294         void* a_ptr = untag_ptr(a);
55295         CHECK_ACCESS(a_ptr);
55296         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
55297         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
55298         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55299         *ret_copy = ParseError_bech32_error(a_conv);
55300         int64_t ret_ref = tag_ptr(ret_copy, true);
55301         return ret_ref;
55302 }
55303
55304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
55305         
55306         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55307         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
55308         int64_t ret_ref = tag_ptr(ret_copy, true);
55309         return ret_ref;
55310 }
55311
55312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
55313         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
55314         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55315         *ret_copy = ParseError_malformed_signature(a_conv);
55316         int64_t ret_ref = tag_ptr(ret_copy, true);
55317         return ret_ref;
55318 }
55319
55320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
55321         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55322         *ret_copy = ParseError_bad_prefix();
55323         int64_t ret_ref = tag_ptr(ret_copy, true);
55324         return ret_ref;
55325 }
55326
55327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
55328         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55329         *ret_copy = ParseError_unknown_currency();
55330         int64_t ret_ref = tag_ptr(ret_copy, true);
55331         return ret_ref;
55332 }
55333
55334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
55335         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55336         *ret_copy = ParseError_unknown_si_prefix();
55337         int64_t ret_ref = tag_ptr(ret_copy, true);
55338         return ret_ref;
55339 }
55340
55341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
55342         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55343         *ret_copy = ParseError_malformed_hrp();
55344         int64_t ret_ref = tag_ptr(ret_copy, true);
55345         return ret_ref;
55346 }
55347
55348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
55349         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55350         *ret_copy = ParseError_too_short_data_part();
55351         int64_t ret_ref = tag_ptr(ret_copy, true);
55352         return ret_ref;
55353 }
55354
55355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
55356         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55357         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
55358         int64_t ret_ref = tag_ptr(ret_copy, true);
55359         return ret_ref;
55360 }
55361
55362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
55363         
55364         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55365         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
55366         int64_t ret_ref = tag_ptr(ret_copy, true);
55367         return ret_ref;
55368 }
55369
55370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
55371         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55372         *ret_copy = ParseError_padding_error();
55373         int64_t ret_ref = tag_ptr(ret_copy, true);
55374         return ret_ref;
55375 }
55376
55377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
55378         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55379         *ret_copy = ParseError_integer_overflow_error();
55380         int64_t ret_ref = tag_ptr(ret_copy, true);
55381         return ret_ref;
55382 }
55383
55384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
55385         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55386         *ret_copy = ParseError_invalid_seg_wit_program_length();
55387         int64_t ret_ref = tag_ptr(ret_copy, true);
55388         return ret_ref;
55389 }
55390
55391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
55392         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55393         *ret_copy = ParseError_invalid_pub_key_hash_length();
55394         int64_t ret_ref = tag_ptr(ret_copy, true);
55395         return ret_ref;
55396 }
55397
55398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
55399         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55400         *ret_copy = ParseError_invalid_script_hash_length();
55401         int64_t ret_ref = tag_ptr(ret_copy, true);
55402         return ret_ref;
55403 }
55404
55405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
55406         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55407         *ret_copy = ParseError_invalid_recovery_id();
55408         int64_t ret_ref = tag_ptr(ret_copy, true);
55409         return ret_ref;
55410 }
55411
55412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
55413         LDKStr a_conv = java_to_owned_str(env, a);
55414         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55415         *ret_copy = ParseError_invalid_slice_length(a_conv);
55416         int64_t ret_ref = tag_ptr(ret_copy, true);
55417         return ret_ref;
55418 }
55419
55420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
55421         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55422         *ret_copy = ParseError_skip();
55423         int64_t ret_ref = tag_ptr(ret_copy, true);
55424         return ret_ref;
55425 }
55426
55427 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55428         LDKParseError* a_conv = (LDKParseError*)untag_ptr(a);
55429         LDKParseError* b_conv = (LDKParseError*)untag_ptr(b);
55430         jboolean ret_conv = ParseError_eq(a_conv, b_conv);
55431         return ret_conv;
55432 }
55433
55434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55435         if (!ptr_is_owned(this_ptr)) return;
55436         void* this_ptr_ptr = untag_ptr(this_ptr);
55437         CHECK_ACCESS(this_ptr_ptr);
55438         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
55439         FREE(untag_ptr(this_ptr));
55440         ParseOrSemanticError_free(this_ptr_conv);
55441 }
55442
55443 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
55444         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55445         *ret_copy = ParseOrSemanticError_clone(arg);
55446         int64_t ret_ref = tag_ptr(ret_copy, true);
55447         return ret_ref;
55448 }
55449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55450         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
55451         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
55452         return ret_conv;
55453 }
55454
55455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55456         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
55457         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55458         *ret_copy = ParseOrSemanticError_clone(orig_conv);
55459         int64_t ret_ref = tag_ptr(ret_copy, true);
55460         return ret_ref;
55461 }
55462
55463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
55464         void* a_ptr = untag_ptr(a);
55465         CHECK_ACCESS(a_ptr);
55466         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
55467         a_conv = ParseError_clone((LDKParseError*)untag_ptr(a));
55468         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55469         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
55470         int64_t ret_ref = tag_ptr(ret_copy, true);
55471         return ret_ref;
55472 }
55473
55474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
55475         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
55476         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55477         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
55478         int64_t ret_ref = tag_ptr(ret_copy, true);
55479         return ret_ref;
55480 }
55481
55482 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55483         LDKParseOrSemanticError* a_conv = (LDKParseOrSemanticError*)untag_ptr(a);
55484         LDKParseOrSemanticError* b_conv = (LDKParseOrSemanticError*)untag_ptr(b);
55485         jboolean ret_conv = ParseOrSemanticError_eq(a_conv, b_conv);
55486         return ret_conv;
55487 }
55488
55489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55490         LDKInvoice this_obj_conv;
55491         this_obj_conv.inner = untag_ptr(this_obj);
55492         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55494         Invoice_free(this_obj_conv);
55495 }
55496
55497 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55498         LDKInvoice a_conv;
55499         a_conv.inner = untag_ptr(a);
55500         a_conv.is_owned = ptr_is_owned(a);
55501         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55502         a_conv.is_owned = false;
55503         LDKInvoice b_conv;
55504         b_conv.inner = untag_ptr(b);
55505         b_conv.is_owned = ptr_is_owned(b);
55506         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55507         b_conv.is_owned = false;
55508         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
55509         return ret_conv;
55510 }
55511
55512 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
55513         LDKInvoice ret_var = Invoice_clone(arg);
55514         int64_t ret_ref = 0;
55515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55516         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55517         return ret_ref;
55518 }
55519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55520         LDKInvoice arg_conv;
55521         arg_conv.inner = untag_ptr(arg);
55522         arg_conv.is_owned = ptr_is_owned(arg);
55523         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55524         arg_conv.is_owned = false;
55525         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
55526         return ret_conv;
55527 }
55528
55529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55530         LDKInvoice orig_conv;
55531         orig_conv.inner = untag_ptr(orig);
55532         orig_conv.is_owned = ptr_is_owned(orig);
55533         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55534         orig_conv.is_owned = false;
55535         LDKInvoice ret_var = Invoice_clone(&orig_conv);
55536         int64_t ret_ref = 0;
55537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55538         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55539         return ret_ref;
55540 }
55541
55542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
55543         LDKInvoice o_conv;
55544         o_conv.inner = untag_ptr(o);
55545         o_conv.is_owned = ptr_is_owned(o);
55546         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55547         o_conv.is_owned = false;
55548         int64_t ret_conv = Invoice_hash(&o_conv);
55549         return ret_conv;
55550 }
55551
55552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55553         LDKSignedRawInvoice this_obj_conv;
55554         this_obj_conv.inner = untag_ptr(this_obj);
55555         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55557         SignedRawInvoice_free(this_obj_conv);
55558 }
55559
55560 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55561         LDKSignedRawInvoice a_conv;
55562         a_conv.inner = untag_ptr(a);
55563         a_conv.is_owned = ptr_is_owned(a);
55564         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55565         a_conv.is_owned = false;
55566         LDKSignedRawInvoice b_conv;
55567         b_conv.inner = untag_ptr(b);
55568         b_conv.is_owned = ptr_is_owned(b);
55569         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55570         b_conv.is_owned = false;
55571         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
55572         return ret_conv;
55573 }
55574
55575 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
55576         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
55577         int64_t ret_ref = 0;
55578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55579         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55580         return ret_ref;
55581 }
55582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55583         LDKSignedRawInvoice arg_conv;
55584         arg_conv.inner = untag_ptr(arg);
55585         arg_conv.is_owned = ptr_is_owned(arg);
55586         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55587         arg_conv.is_owned = false;
55588         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
55589         return ret_conv;
55590 }
55591
55592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55593         LDKSignedRawInvoice orig_conv;
55594         orig_conv.inner = untag_ptr(orig);
55595         orig_conv.is_owned = ptr_is_owned(orig);
55596         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55597         orig_conv.is_owned = false;
55598         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
55599         int64_t ret_ref = 0;
55600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55601         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55602         return ret_ref;
55603 }
55604
55605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
55606         LDKSignedRawInvoice o_conv;
55607         o_conv.inner = untag_ptr(o);
55608         o_conv.is_owned = ptr_is_owned(o);
55609         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55610         o_conv.is_owned = false;
55611         int64_t ret_conv = SignedRawInvoice_hash(&o_conv);
55612         return ret_conv;
55613 }
55614
55615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55616         LDKRawInvoice this_obj_conv;
55617         this_obj_conv.inner = untag_ptr(this_obj);
55618         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55620         RawInvoice_free(this_obj_conv);
55621 }
55622
55623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
55624         LDKRawInvoice this_ptr_conv;
55625         this_ptr_conv.inner = untag_ptr(this_ptr);
55626         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55628         this_ptr_conv.is_owned = false;
55629         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
55630         int64_t ret_ref = 0;
55631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55632         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55633         return ret_ref;
55634 }
55635
55636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
55637         LDKRawInvoice this_ptr_conv;
55638         this_ptr_conv.inner = untag_ptr(this_ptr);
55639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55641         this_ptr_conv.is_owned = false;
55642         LDKRawDataPart val_conv;
55643         val_conv.inner = untag_ptr(val);
55644         val_conv.is_owned = ptr_is_owned(val);
55645         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
55646         val_conv = RawDataPart_clone(&val_conv);
55647         RawInvoice_set_data(&this_ptr_conv, val_conv);
55648 }
55649
55650 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55651         LDKRawInvoice a_conv;
55652         a_conv.inner = untag_ptr(a);
55653         a_conv.is_owned = ptr_is_owned(a);
55654         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55655         a_conv.is_owned = false;
55656         LDKRawInvoice b_conv;
55657         b_conv.inner = untag_ptr(b);
55658         b_conv.is_owned = ptr_is_owned(b);
55659         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55660         b_conv.is_owned = false;
55661         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
55662         return ret_conv;
55663 }
55664
55665 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
55666         LDKRawInvoice ret_var = RawInvoice_clone(arg);
55667         int64_t ret_ref = 0;
55668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55669         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55670         return ret_ref;
55671 }
55672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55673         LDKRawInvoice arg_conv;
55674         arg_conv.inner = untag_ptr(arg);
55675         arg_conv.is_owned = ptr_is_owned(arg);
55676         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55677         arg_conv.is_owned = false;
55678         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
55679         return ret_conv;
55680 }
55681
55682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55683         LDKRawInvoice orig_conv;
55684         orig_conv.inner = untag_ptr(orig);
55685         orig_conv.is_owned = ptr_is_owned(orig);
55686         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55687         orig_conv.is_owned = false;
55688         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
55689         int64_t ret_ref = 0;
55690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55692         return ret_ref;
55693 }
55694
55695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
55696         LDKRawInvoice o_conv;
55697         o_conv.inner = untag_ptr(o);
55698         o_conv.is_owned = ptr_is_owned(o);
55699         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55700         o_conv.is_owned = false;
55701         int64_t ret_conv = RawInvoice_hash(&o_conv);
55702         return ret_conv;
55703 }
55704
55705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55706         LDKRawDataPart this_obj_conv;
55707         this_obj_conv.inner = untag_ptr(this_obj);
55708         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55710         RawDataPart_free(this_obj_conv);
55711 }
55712
55713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
55714         LDKRawDataPart this_ptr_conv;
55715         this_ptr_conv.inner = untag_ptr(this_ptr);
55716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55718         this_ptr_conv.is_owned = false;
55719         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
55720         int64_t ret_ref = 0;
55721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55722         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55723         return ret_ref;
55724 }
55725
55726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
55727         LDKRawDataPart this_ptr_conv;
55728         this_ptr_conv.inner = untag_ptr(this_ptr);
55729         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55731         this_ptr_conv.is_owned = false;
55732         LDKPositiveTimestamp val_conv;
55733         val_conv.inner = untag_ptr(val);
55734         val_conv.is_owned = ptr_is_owned(val);
55735         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
55736         val_conv = PositiveTimestamp_clone(&val_conv);
55737         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
55738 }
55739
55740 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55741         LDKRawDataPart a_conv;
55742         a_conv.inner = untag_ptr(a);
55743         a_conv.is_owned = ptr_is_owned(a);
55744         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55745         a_conv.is_owned = false;
55746         LDKRawDataPart b_conv;
55747         b_conv.inner = untag_ptr(b);
55748         b_conv.is_owned = ptr_is_owned(b);
55749         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55750         b_conv.is_owned = false;
55751         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
55752         return ret_conv;
55753 }
55754
55755 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
55756         LDKRawDataPart ret_var = RawDataPart_clone(arg);
55757         int64_t ret_ref = 0;
55758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55759         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55760         return ret_ref;
55761 }
55762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55763         LDKRawDataPart arg_conv;
55764         arg_conv.inner = untag_ptr(arg);
55765         arg_conv.is_owned = ptr_is_owned(arg);
55766         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55767         arg_conv.is_owned = false;
55768         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
55769         return ret_conv;
55770 }
55771
55772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55773         LDKRawDataPart orig_conv;
55774         orig_conv.inner = untag_ptr(orig);
55775         orig_conv.is_owned = ptr_is_owned(orig);
55776         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55777         orig_conv.is_owned = false;
55778         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
55779         int64_t ret_ref = 0;
55780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55781         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55782         return ret_ref;
55783 }
55784
55785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1hash(JNIEnv *env, jclass clz, int64_t o) {
55786         LDKRawDataPart o_conv;
55787         o_conv.inner = untag_ptr(o);
55788         o_conv.is_owned = ptr_is_owned(o);
55789         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55790         o_conv.is_owned = false;
55791         int64_t ret_conv = RawDataPart_hash(&o_conv);
55792         return ret_conv;
55793 }
55794
55795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55796         LDKPositiveTimestamp this_obj_conv;
55797         this_obj_conv.inner = untag_ptr(this_obj);
55798         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55800         PositiveTimestamp_free(this_obj_conv);
55801 }
55802
55803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55804         LDKPositiveTimestamp a_conv;
55805         a_conv.inner = untag_ptr(a);
55806         a_conv.is_owned = ptr_is_owned(a);
55807         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55808         a_conv.is_owned = false;
55809         LDKPositiveTimestamp b_conv;
55810         b_conv.inner = untag_ptr(b);
55811         b_conv.is_owned = ptr_is_owned(b);
55812         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55813         b_conv.is_owned = false;
55814         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
55815         return ret_conv;
55816 }
55817
55818 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
55819         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
55820         int64_t ret_ref = 0;
55821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55822         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55823         return ret_ref;
55824 }
55825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55826         LDKPositiveTimestamp arg_conv;
55827         arg_conv.inner = untag_ptr(arg);
55828         arg_conv.is_owned = ptr_is_owned(arg);
55829         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55830         arg_conv.is_owned = false;
55831         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
55832         return ret_conv;
55833 }
55834
55835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55836         LDKPositiveTimestamp orig_conv;
55837         orig_conv.inner = untag_ptr(orig);
55838         orig_conv.is_owned = ptr_is_owned(orig);
55839         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55840         orig_conv.is_owned = false;
55841         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
55842         int64_t ret_ref = 0;
55843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55844         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55845         return ret_ref;
55846 }
55847
55848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1hash(JNIEnv *env, jclass clz, int64_t o) {
55849         LDKPositiveTimestamp o_conv;
55850         o_conv.inner = untag_ptr(o);
55851         o_conv.is_owned = ptr_is_owned(o);
55852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55853         o_conv.is_owned = false;
55854         int64_t ret_conv = PositiveTimestamp_hash(&o_conv);
55855         return ret_conv;
55856 }
55857
55858 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55859         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
55860         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
55861         return ret_conv;
55862 }
55863
55864 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
55865         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
55866         return ret_conv;
55867 }
55868
55869 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
55870         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
55871         return ret_conv;
55872 }
55873
55874 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
55875         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
55876         return ret_conv;
55877 }
55878
55879 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
55880         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
55881         return ret_conv;
55882 }
55883
55884 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55885         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
55886         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
55887         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
55888         return ret_conv;
55889 }
55890
55891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1hash(JNIEnv *env, jclass clz, int64_t o) {
55892         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
55893         int64_t ret_conv = SiPrefix_hash(o_conv);
55894         return ret_conv;
55895 }
55896
55897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
55898         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
55899         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
55900         return ret_conv;
55901 }
55902
55903 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55904         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
55905         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
55906         return ret_conv;
55907 }
55908
55909 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
55910         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
55911         return ret_conv;
55912 }
55913
55914 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
55915         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
55916         return ret_conv;
55917 }
55918
55919 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
55920         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
55921         return ret_conv;
55922 }
55923
55924 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
55925         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
55926         return ret_conv;
55927 }
55928
55929 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
55930         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
55931         return ret_conv;
55932 }
55933
55934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
55935         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
55936         int64_t ret_conv = Currency_hash(o_conv);
55937         return ret_conv;
55938 }
55939
55940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55941         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
55942         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
55943         jboolean ret_conv = Currency_eq(a_conv, b_conv);
55944         return ret_conv;
55945 }
55946
55947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55948         LDKSha256 this_obj_conv;
55949         this_obj_conv.inner = untag_ptr(this_obj);
55950         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55952         Sha256_free(this_obj_conv);
55953 }
55954
55955 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
55956         LDKSha256 ret_var = Sha256_clone(arg);
55957         int64_t ret_ref = 0;
55958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55959         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55960         return ret_ref;
55961 }
55962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55963         LDKSha256 arg_conv;
55964         arg_conv.inner = untag_ptr(arg);
55965         arg_conv.is_owned = ptr_is_owned(arg);
55966         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55967         arg_conv.is_owned = false;
55968         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
55969         return ret_conv;
55970 }
55971
55972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55973         LDKSha256 orig_conv;
55974         orig_conv.inner = untag_ptr(orig);
55975         orig_conv.is_owned = ptr_is_owned(orig);
55976         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55977         orig_conv.is_owned = false;
55978         LDKSha256 ret_var = Sha256_clone(&orig_conv);
55979         int64_t ret_ref = 0;
55980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55981         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55982         return ret_ref;
55983 }
55984
55985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
55986         LDKSha256 o_conv;
55987         o_conv.inner = untag_ptr(o);
55988         o_conv.is_owned = ptr_is_owned(o);
55989         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55990         o_conv.is_owned = false;
55991         int64_t ret_conv = Sha256_hash(&o_conv);
55992         return ret_conv;
55993 }
55994
55995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55996         LDKSha256 a_conv;
55997         a_conv.inner = untag_ptr(a);
55998         a_conv.is_owned = ptr_is_owned(a);
55999         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56000         a_conv.is_owned = false;
56001         LDKSha256 b_conv;
56002         b_conv.inner = untag_ptr(b);
56003         b_conv.is_owned = ptr_is_owned(b);
56004         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56005         b_conv.is_owned = false;
56006         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
56007         return ret_conv;
56008 }
56009
56010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1from_1bytes(JNIEnv *env, jclass clz, int8_tArray bytes) {
56011         uint8_t bytes_arr[32];
56012         CHECK((*env)->GetArrayLength(env, bytes) == 32);
56013         (*env)->GetByteArrayRegion(env, bytes, 0, 32, bytes_arr);
56014         uint8_t (*bytes_ref)[32] = &bytes_arr;
56015         LDKSha256 ret_var = Sha256_from_bytes(bytes_ref);
56016         int64_t ret_ref = 0;
56017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56019         return ret_ref;
56020 }
56021
56022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56023         LDKDescription this_obj_conv;
56024         this_obj_conv.inner = untag_ptr(this_obj);
56025         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56027         Description_free(this_obj_conv);
56028 }
56029
56030 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
56031         LDKDescription ret_var = Description_clone(arg);
56032         int64_t ret_ref = 0;
56033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56034         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56035         return ret_ref;
56036 }
56037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56038         LDKDescription arg_conv;
56039         arg_conv.inner = untag_ptr(arg);
56040         arg_conv.is_owned = ptr_is_owned(arg);
56041         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56042         arg_conv.is_owned = false;
56043         int64_t ret_conv = Description_clone_ptr(&arg_conv);
56044         return ret_conv;
56045 }
56046
56047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56048         LDKDescription orig_conv;
56049         orig_conv.inner = untag_ptr(orig);
56050         orig_conv.is_owned = ptr_is_owned(orig);
56051         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56052         orig_conv.is_owned = false;
56053         LDKDescription ret_var = Description_clone(&orig_conv);
56054         int64_t ret_ref = 0;
56055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56056         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56057         return ret_ref;
56058 }
56059
56060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
56061         LDKDescription o_conv;
56062         o_conv.inner = untag_ptr(o);
56063         o_conv.is_owned = ptr_is_owned(o);
56064         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56065         o_conv.is_owned = false;
56066         int64_t ret_conv = Description_hash(&o_conv);
56067         return ret_conv;
56068 }
56069
56070 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56071         LDKDescription a_conv;
56072         a_conv.inner = untag_ptr(a);
56073         a_conv.is_owned = ptr_is_owned(a);
56074         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56075         a_conv.is_owned = false;
56076         LDKDescription b_conv;
56077         b_conv.inner = untag_ptr(b);
56078         b_conv.is_owned = ptr_is_owned(b);
56079         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56080         b_conv.is_owned = false;
56081         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
56082         return ret_conv;
56083 }
56084
56085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56086         LDKPayeePubKey this_obj_conv;
56087         this_obj_conv.inner = untag_ptr(this_obj);
56088         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56090         PayeePubKey_free(this_obj_conv);
56091 }
56092
56093 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
56094         LDKPayeePubKey this_ptr_conv;
56095         this_ptr_conv.inner = untag_ptr(this_ptr);
56096         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56098         this_ptr_conv.is_owned = false;
56099         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
56100         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
56101         return ret_arr;
56102 }
56103
56104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
56105         LDKPayeePubKey this_ptr_conv;
56106         this_ptr_conv.inner = untag_ptr(this_ptr);
56107         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56109         this_ptr_conv.is_owned = false;
56110         LDKPublicKey val_ref;
56111         CHECK((*env)->GetArrayLength(env, val) == 33);
56112         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
56113         PayeePubKey_set_a(&this_ptr_conv, val_ref);
56114 }
56115
56116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
56117         LDKPublicKey a_arg_ref;
56118         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
56119         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
56120         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
56121         int64_t ret_ref = 0;
56122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56123         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56124         return ret_ref;
56125 }
56126
56127 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
56128         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
56129         int64_t ret_ref = 0;
56130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56131         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56132         return ret_ref;
56133 }
56134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56135         LDKPayeePubKey arg_conv;
56136         arg_conv.inner = untag_ptr(arg);
56137         arg_conv.is_owned = ptr_is_owned(arg);
56138         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56139         arg_conv.is_owned = false;
56140         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
56141         return ret_conv;
56142 }
56143
56144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56145         LDKPayeePubKey orig_conv;
56146         orig_conv.inner = untag_ptr(orig);
56147         orig_conv.is_owned = ptr_is_owned(orig);
56148         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56149         orig_conv.is_owned = false;
56150         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
56151         int64_t ret_ref = 0;
56152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56153         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56154         return ret_ref;
56155 }
56156
56157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
56158         LDKPayeePubKey o_conv;
56159         o_conv.inner = untag_ptr(o);
56160         o_conv.is_owned = ptr_is_owned(o);
56161         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56162         o_conv.is_owned = false;
56163         int64_t ret_conv = PayeePubKey_hash(&o_conv);
56164         return ret_conv;
56165 }
56166
56167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56168         LDKPayeePubKey a_conv;
56169         a_conv.inner = untag_ptr(a);
56170         a_conv.is_owned = ptr_is_owned(a);
56171         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56172         a_conv.is_owned = false;
56173         LDKPayeePubKey b_conv;
56174         b_conv.inner = untag_ptr(b);
56175         b_conv.is_owned = ptr_is_owned(b);
56176         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56177         b_conv.is_owned = false;
56178         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
56179         return ret_conv;
56180 }
56181
56182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56183         LDKExpiryTime this_obj_conv;
56184         this_obj_conv.inner = untag_ptr(this_obj);
56185         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56187         ExpiryTime_free(this_obj_conv);
56188 }
56189
56190 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
56191         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
56192         int64_t ret_ref = 0;
56193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56194         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56195         return ret_ref;
56196 }
56197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56198         LDKExpiryTime arg_conv;
56199         arg_conv.inner = untag_ptr(arg);
56200         arg_conv.is_owned = ptr_is_owned(arg);
56201         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56202         arg_conv.is_owned = false;
56203         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
56204         return ret_conv;
56205 }
56206
56207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56208         LDKExpiryTime orig_conv;
56209         orig_conv.inner = untag_ptr(orig);
56210         orig_conv.is_owned = ptr_is_owned(orig);
56211         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56212         orig_conv.is_owned = false;
56213         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
56214         int64_t ret_ref = 0;
56215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56216         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56217         return ret_ref;
56218 }
56219
56220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
56221         LDKExpiryTime o_conv;
56222         o_conv.inner = untag_ptr(o);
56223         o_conv.is_owned = ptr_is_owned(o);
56224         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56225         o_conv.is_owned = false;
56226         int64_t ret_conv = ExpiryTime_hash(&o_conv);
56227         return ret_conv;
56228 }
56229
56230 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56231         LDKExpiryTime a_conv;
56232         a_conv.inner = untag_ptr(a);
56233         a_conv.is_owned = ptr_is_owned(a);
56234         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56235         a_conv.is_owned = false;
56236         LDKExpiryTime b_conv;
56237         b_conv.inner = untag_ptr(b);
56238         b_conv.is_owned = ptr_is_owned(b);
56239         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56240         b_conv.is_owned = false;
56241         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
56242         return ret_conv;
56243 }
56244
56245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56246         LDKMinFinalCltvExpiryDelta this_obj_conv;
56247         this_obj_conv.inner = untag_ptr(this_obj);
56248         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56250         MinFinalCltvExpiryDelta_free(this_obj_conv);
56251 }
56252
56253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
56254         LDKMinFinalCltvExpiryDelta this_ptr_conv;
56255         this_ptr_conv.inner = untag_ptr(this_ptr);
56256         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56258         this_ptr_conv.is_owned = false;
56259         int64_t ret_conv = MinFinalCltvExpiryDelta_get_a(&this_ptr_conv);
56260         return ret_conv;
56261 }
56262
56263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
56264         LDKMinFinalCltvExpiryDelta this_ptr_conv;
56265         this_ptr_conv.inner = untag_ptr(this_ptr);
56266         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56268         this_ptr_conv.is_owned = false;
56269         MinFinalCltvExpiryDelta_set_a(&this_ptr_conv, val);
56270 }
56271
56272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
56273         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_new(a_arg);
56274         int64_t ret_ref = 0;
56275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56276         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56277         return ret_ref;
56278 }
56279
56280 static inline uint64_t MinFinalCltvExpiryDelta_clone_ptr(LDKMinFinalCltvExpiryDelta *NONNULL_PTR arg) {
56281         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(arg);
56282         int64_t ret_ref = 0;
56283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56284         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56285         return ret_ref;
56286 }
56287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56288         LDKMinFinalCltvExpiryDelta arg_conv;
56289         arg_conv.inner = untag_ptr(arg);
56290         arg_conv.is_owned = ptr_is_owned(arg);
56291         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56292         arg_conv.is_owned = false;
56293         int64_t ret_conv = MinFinalCltvExpiryDelta_clone_ptr(&arg_conv);
56294         return ret_conv;
56295 }
56296
56297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56298         LDKMinFinalCltvExpiryDelta orig_conv;
56299         orig_conv.inner = untag_ptr(orig);
56300         orig_conv.is_owned = ptr_is_owned(orig);
56301         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56302         orig_conv.is_owned = false;
56303         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(&orig_conv);
56304         int64_t ret_ref = 0;
56305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56306         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56307         return ret_ref;
56308 }
56309
56310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1hash(JNIEnv *env, jclass clz, int64_t o) {
56311         LDKMinFinalCltvExpiryDelta o_conv;
56312         o_conv.inner = untag_ptr(o);
56313         o_conv.is_owned = ptr_is_owned(o);
56314         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56315         o_conv.is_owned = false;
56316         int64_t ret_conv = MinFinalCltvExpiryDelta_hash(&o_conv);
56317         return ret_conv;
56318 }
56319
56320 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56321         LDKMinFinalCltvExpiryDelta a_conv;
56322         a_conv.inner = untag_ptr(a);
56323         a_conv.is_owned = ptr_is_owned(a);
56324         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56325         a_conv.is_owned = false;
56326         LDKMinFinalCltvExpiryDelta b_conv;
56327         b_conv.inner = untag_ptr(b);
56328         b_conv.is_owned = ptr_is_owned(b);
56329         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56330         b_conv.is_owned = false;
56331         jboolean ret_conv = MinFinalCltvExpiryDelta_eq(&a_conv, &b_conv);
56332         return ret_conv;
56333 }
56334
56335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
56336         if (!ptr_is_owned(this_ptr)) return;
56337         void* this_ptr_ptr = untag_ptr(this_ptr);
56338         CHECK_ACCESS(this_ptr_ptr);
56339         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
56340         FREE(untag_ptr(this_ptr));
56341         Fallback_free(this_ptr_conv);
56342 }
56343
56344 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
56345         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56346         *ret_copy = Fallback_clone(arg);
56347         int64_t ret_ref = tag_ptr(ret_copy, true);
56348         return ret_ref;
56349 }
56350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56351         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
56352         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
56353         return ret_conv;
56354 }
56355
56356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56357         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
56358         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56359         *ret_copy = Fallback_clone(orig_conv);
56360         int64_t ret_ref = tag_ptr(ret_copy, true);
56361         return ret_ref;
56362 }
56363
56364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
56365         
56366         LDKCVec_u8Z program_ref;
56367         program_ref.datalen = (*env)->GetArrayLength(env, program);
56368         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
56369         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
56370         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56371         *ret_copy = Fallback_seg_wit_program((LDKWitnessVersion){ ._0 = version }, program_ref);
56372         int64_t ret_ref = tag_ptr(ret_copy, true);
56373         return ret_ref;
56374 }
56375
56376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
56377         LDKTwentyBytes a_ref;
56378         CHECK((*env)->GetArrayLength(env, a) == 20);
56379         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
56380         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56381         *ret_copy = Fallback_pub_key_hash(a_ref);
56382         int64_t ret_ref = tag_ptr(ret_copy, true);
56383         return ret_ref;
56384 }
56385
56386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
56387         LDKTwentyBytes a_ref;
56388         CHECK((*env)->GetArrayLength(env, a) == 20);
56389         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
56390         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56391         *ret_copy = Fallback_script_hash(a_ref);
56392         int64_t ret_ref = tag_ptr(ret_copy, true);
56393         return ret_ref;
56394 }
56395
56396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
56397         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
56398         int64_t ret_conv = Fallback_hash(o_conv);
56399         return ret_conv;
56400 }
56401
56402 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56403         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
56404         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
56405         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
56406         return ret_conv;
56407 }
56408
56409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56410         LDKInvoiceSignature this_obj_conv;
56411         this_obj_conv.inner = untag_ptr(this_obj);
56412         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56414         InvoiceSignature_free(this_obj_conv);
56415 }
56416
56417 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
56418         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
56419         int64_t ret_ref = 0;
56420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56421         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56422         return ret_ref;
56423 }
56424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56425         LDKInvoiceSignature arg_conv;
56426         arg_conv.inner = untag_ptr(arg);
56427         arg_conv.is_owned = ptr_is_owned(arg);
56428         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56429         arg_conv.is_owned = false;
56430         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
56431         return ret_conv;
56432 }
56433
56434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56435         LDKInvoiceSignature orig_conv;
56436         orig_conv.inner = untag_ptr(orig);
56437         orig_conv.is_owned = ptr_is_owned(orig);
56438         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56439         orig_conv.is_owned = false;
56440         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
56441         int64_t ret_ref = 0;
56442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56443         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56444         return ret_ref;
56445 }
56446
56447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1hash(JNIEnv *env, jclass clz, int64_t o) {
56448         LDKInvoiceSignature o_conv;
56449         o_conv.inner = untag_ptr(o);
56450         o_conv.is_owned = ptr_is_owned(o);
56451         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56452         o_conv.is_owned = false;
56453         int64_t ret_conv = InvoiceSignature_hash(&o_conv);
56454         return ret_conv;
56455 }
56456
56457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56458         LDKInvoiceSignature a_conv;
56459         a_conv.inner = untag_ptr(a);
56460         a_conv.is_owned = ptr_is_owned(a);
56461         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56462         a_conv.is_owned = false;
56463         LDKInvoiceSignature b_conv;
56464         b_conv.inner = untag_ptr(b);
56465         b_conv.is_owned = ptr_is_owned(b);
56466         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56467         b_conv.is_owned = false;
56468         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
56469         return ret_conv;
56470 }
56471
56472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56473         LDKPrivateRoute this_obj_conv;
56474         this_obj_conv.inner = untag_ptr(this_obj);
56475         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56477         PrivateRoute_free(this_obj_conv);
56478 }
56479
56480 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
56481         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
56482         int64_t ret_ref = 0;
56483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56484         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56485         return ret_ref;
56486 }
56487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56488         LDKPrivateRoute arg_conv;
56489         arg_conv.inner = untag_ptr(arg);
56490         arg_conv.is_owned = ptr_is_owned(arg);
56491         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56492         arg_conv.is_owned = false;
56493         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
56494         return ret_conv;
56495 }
56496
56497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56498         LDKPrivateRoute orig_conv;
56499         orig_conv.inner = untag_ptr(orig);
56500         orig_conv.is_owned = ptr_is_owned(orig);
56501         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56502         orig_conv.is_owned = false;
56503         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
56504         int64_t ret_ref = 0;
56505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56506         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56507         return ret_ref;
56508 }
56509
56510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
56511         LDKPrivateRoute o_conv;
56512         o_conv.inner = untag_ptr(o);
56513         o_conv.is_owned = ptr_is_owned(o);
56514         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56515         o_conv.is_owned = false;
56516         int64_t ret_conv = PrivateRoute_hash(&o_conv);
56517         return ret_conv;
56518 }
56519
56520 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56521         LDKPrivateRoute a_conv;
56522         a_conv.inner = untag_ptr(a);
56523         a_conv.is_owned = ptr_is_owned(a);
56524         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56525         a_conv.is_owned = false;
56526         LDKPrivateRoute b_conv;
56527         b_conv.inner = untag_ptr(b);
56528         b_conv.is_owned = ptr_is_owned(b);
56529         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56530         b_conv.is_owned = false;
56531         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
56532         return ret_conv;
56533 }
56534
56535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
56536         LDKSignedRawInvoice this_arg_conv;
56537         this_arg_conv.inner = untag_ptr(this_arg);
56538         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56540         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
56541         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
56542         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
56543         return tag_ptr(ret_conv, true);
56544 }
56545
56546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
56547         LDKSignedRawInvoice this_arg_conv;
56548         this_arg_conv.inner = untag_ptr(this_arg);
56549         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56551         this_arg_conv.is_owned = false;
56552         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
56553         int64_t ret_ref = 0;
56554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56555         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56556         return ret_ref;
56557 }
56558
56559 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56560         LDKSignedRawInvoice this_arg_conv;
56561         this_arg_conv.inner = untag_ptr(this_arg);
56562         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56564         this_arg_conv.is_owned = false;
56565         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56566         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_signable_hash(&this_arg_conv));
56567         return ret_arr;
56568 }
56569
56570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
56571         LDKSignedRawInvoice this_arg_conv;
56572         this_arg_conv.inner = untag_ptr(this_arg);
56573         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56575         this_arg_conv.is_owned = false;
56576         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
56577         int64_t ret_ref = 0;
56578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56579         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56580         return ret_ref;
56581 }
56582
56583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56584         LDKSignedRawInvoice this_arg_conv;
56585         this_arg_conv.inner = untag_ptr(this_arg);
56586         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56588         this_arg_conv.is_owned = false;
56589         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
56590         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
56591         return tag_ptr(ret_conv, true);
56592 }
56593
56594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
56595         LDKSignedRawInvoice this_arg_conv;
56596         this_arg_conv.inner = untag_ptr(this_arg);
56597         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56599         this_arg_conv.is_owned = false;
56600         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
56601         return ret_conv;
56602 }
56603
56604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56605         LDKRawInvoice this_arg_conv;
56606         this_arg_conv.inner = untag_ptr(this_arg);
56607         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56609         this_arg_conv.is_owned = false;
56610         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56611         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_signable_hash(&this_arg_conv).data);
56612         return ret_arr;
56613 }
56614
56615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56616         LDKRawInvoice this_arg_conv;
56617         this_arg_conv.inner = untag_ptr(this_arg);
56618         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56620         this_arg_conv.is_owned = false;
56621         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
56622         int64_t ret_ref = 0;
56623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56624         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56625         return ret_ref;
56626 }
56627
56628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
56629         LDKRawInvoice this_arg_conv;
56630         this_arg_conv.inner = untag_ptr(this_arg);
56631         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56633         this_arg_conv.is_owned = false;
56634         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
56635         int64_t ret_ref = 0;
56636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56637         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56638         return ret_ref;
56639 }
56640
56641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56642         LDKRawInvoice this_arg_conv;
56643         this_arg_conv.inner = untag_ptr(this_arg);
56644         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56646         this_arg_conv.is_owned = false;
56647         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
56648         int64_t ret_ref = 0;
56649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56650         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56651         return ret_ref;
56652 }
56653
56654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56655         LDKRawInvoice this_arg_conv;
56656         this_arg_conv.inner = untag_ptr(this_arg);
56657         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56659         this_arg_conv.is_owned = false;
56660         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
56661         int64_t ret_ref = 0;
56662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56663         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56664         return ret_ref;
56665 }
56666
56667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
56668         LDKRawInvoice this_arg_conv;
56669         this_arg_conv.inner = untag_ptr(this_arg);
56670         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56672         this_arg_conv.is_owned = false;
56673         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
56674         int64_t ret_ref = 0;
56675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56676         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56677         return ret_ref;
56678 }
56679
56680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_arg) {
56681         LDKRawInvoice this_arg_conv;
56682         this_arg_conv.inner = untag_ptr(this_arg);
56683         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56685         this_arg_conv.is_owned = false;
56686         LDKMinFinalCltvExpiryDelta ret_var = RawInvoice_min_final_cltv_expiry_delta(&this_arg_conv);
56687         int64_t ret_ref = 0;
56688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56690         return ret_ref;
56691 }
56692
56693 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
56694         LDKRawInvoice this_arg_conv;
56695         this_arg_conv.inner = untag_ptr(this_arg);
56696         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56698         this_arg_conv.is_owned = false;
56699         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56700         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
56701         return ret_arr;
56702 }
56703
56704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
56705         LDKRawInvoice this_arg_conv;
56706         this_arg_conv.inner = untag_ptr(this_arg);
56707         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56709         this_arg_conv.is_owned = false;
56710         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
56711         *ret_copy = RawInvoice_payment_metadata(&this_arg_conv);
56712         int64_t ret_ref = tag_ptr(ret_copy, true);
56713         return ret_ref;
56714 }
56715
56716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
56717         LDKRawInvoice this_arg_conv;
56718         this_arg_conv.inner = untag_ptr(this_arg);
56719         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56721         this_arg_conv.is_owned = false;
56722         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
56723         int64_t ret_ref = 0;
56724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56725         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56726         return ret_ref;
56727 }
56728
56729 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
56730         LDKRawInvoice this_arg_conv;
56731         this_arg_conv.inner = untag_ptr(this_arg);
56732         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56734         this_arg_conv.is_owned = false;
56735         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
56736         int64_tArray ret_arr = NULL;
56737         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
56738         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
56739         for (size_t o = 0; o < ret_var.datalen; o++) {
56740                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
56741                 int64_t ret_conv_14_ref = 0;
56742                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
56743                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
56744                 ret_arr_ptr[o] = ret_conv_14_ref;
56745         }
56746         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
56747         FREE(ret_var.data);
56748         return ret_arr;
56749 }
56750
56751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
56752         LDKRawInvoice this_arg_conv;
56753         this_arg_conv.inner = untag_ptr(this_arg);
56754         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56756         this_arg_conv.is_owned = false;
56757         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
56758         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
56759         int64_t ret_ref = tag_ptr(ret_copy, true);
56760         return ret_ref;
56761 }
56762
56763 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
56764         LDKRawInvoice this_arg_conv;
56765         this_arg_conv.inner = untag_ptr(this_arg);
56766         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56768         this_arg_conv.is_owned = false;
56769         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
56770         return ret_conv;
56771 }
56772
56773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
56774         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
56775         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
56776         return tag_ptr(ret_conv, true);
56777 }
56778
56779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
56780         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
56781         *ret_conv = PositiveTimestamp_from_system_time(time);
56782         return tag_ptr(ret_conv, true);
56783 }
56784
56785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
56786         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
56787         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
56788         return tag_ptr(ret_conv, true);
56789 }
56790
56791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
56792         LDKPositiveTimestamp this_arg_conv;
56793         this_arg_conv.inner = untag_ptr(this_arg);
56794         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56796         this_arg_conv.is_owned = false;
56797         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
56798         return ret_conv;
56799 }
56800
56801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
56802         LDKPositiveTimestamp this_arg_conv;
56803         this_arg_conv.inner = untag_ptr(this_arg);
56804         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56806         this_arg_conv.is_owned = false;
56807         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
56808         return ret_conv;
56809 }
56810
56811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
56812         LDKPositiveTimestamp this_arg_conv;
56813         this_arg_conv.inner = untag_ptr(this_arg);
56814         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56816         this_arg_conv.is_owned = false;
56817         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
56818         return ret_conv;
56819 }
56820
56821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56822         LDKInvoice this_arg_conv;
56823         this_arg_conv.inner = untag_ptr(this_arg);
56824         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56826         this_arg_conv.is_owned = false;
56827         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56828         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_signable_hash(&this_arg_conv).data);
56829         return ret_arr;
56830 }
56831
56832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
56833         LDKInvoice this_arg_conv;
56834         this_arg_conv.inner = untag_ptr(this_arg);
56835         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56837         this_arg_conv = Invoice_clone(&this_arg_conv);
56838         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
56839         int64_t ret_ref = 0;
56840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56841         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56842         return ret_ref;
56843 }
56844
56845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
56846         LDKInvoice this_arg_conv;
56847         this_arg_conv.inner = untag_ptr(this_arg);
56848         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56850         this_arg_conv.is_owned = false;
56851         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
56852         *ret_conv = Invoice_check_signature(&this_arg_conv);
56853         return tag_ptr(ret_conv, true);
56854 }
56855
56856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
56857         LDKSignedRawInvoice signed_invoice_conv;
56858         signed_invoice_conv.inner = untag_ptr(signed_invoice);
56859         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
56860         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
56861         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
56862         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
56863         *ret_conv = Invoice_from_signed(signed_invoice_conv);
56864         return tag_ptr(ret_conv, true);
56865 }
56866
56867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
56868         LDKInvoice this_arg_conv;
56869         this_arg_conv.inner = untag_ptr(this_arg);
56870         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56872         this_arg_conv.is_owned = false;
56873         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
56874         return ret_conv;
56875 }
56876
56877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
56878         LDKInvoice this_arg_conv;
56879         this_arg_conv.inner = untag_ptr(this_arg);
56880         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56882         this_arg_conv.is_owned = false;
56883         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
56884         return ret_conv;
56885 }
56886
56887 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56888         LDKInvoice this_arg_conv;
56889         this_arg_conv.inner = untag_ptr(this_arg);
56890         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56892         this_arg_conv.is_owned = false;
56893         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56894         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
56895         return ret_arr;
56896 }
56897
56898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56899         LDKInvoice this_arg_conv;
56900         this_arg_conv.inner = untag_ptr(this_arg);
56901         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56903         this_arg_conv.is_owned = false;
56904         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
56905         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
56906         return ret_arr;
56907 }
56908
56909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
56910         LDKInvoice this_arg_conv;
56911         this_arg_conv.inner = untag_ptr(this_arg);
56912         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56914         this_arg_conv.is_owned = false;
56915         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56916         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
56917         return ret_arr;
56918 }
56919
56920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
56921         LDKInvoice this_arg_conv;
56922         this_arg_conv.inner = untag_ptr(this_arg);
56923         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56925         this_arg_conv.is_owned = false;
56926         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
56927         *ret_copy = Invoice_payment_metadata(&this_arg_conv);
56928         int64_t ret_ref = tag_ptr(ret_copy, true);
56929         return ret_ref;
56930 }
56931
56932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
56933         LDKInvoice this_arg_conv;
56934         this_arg_conv.inner = untag_ptr(this_arg);
56935         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56937         this_arg_conv.is_owned = false;
56938         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
56939         int64_t ret_ref = 0;
56940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56941         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56942         return ret_ref;
56943 }
56944
56945 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56946         LDKInvoice this_arg_conv;
56947         this_arg_conv.inner = untag_ptr(this_arg);
56948         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56950         this_arg_conv.is_owned = false;
56951         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
56952         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
56953         return ret_arr;
56954 }
56955
56956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expires_1at(JNIEnv *env, jclass clz, int64_t this_arg) {
56957         LDKInvoice this_arg_conv;
56958         this_arg_conv.inner = untag_ptr(this_arg);
56959         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56961         this_arg_conv.is_owned = false;
56962         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
56963         *ret_copy = Invoice_expires_at(&this_arg_conv);
56964         int64_t ret_ref = tag_ptr(ret_copy, true);
56965         return ret_ref;
56966 }
56967
56968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
56969         LDKInvoice this_arg_conv;
56970         this_arg_conv.inner = untag_ptr(this_arg);
56971         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56973         this_arg_conv.is_owned = false;
56974         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
56975         return ret_conv;
56976 }
56977
56978 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
56979         LDKInvoice this_arg_conv;
56980         this_arg_conv.inner = untag_ptr(this_arg);
56981         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56983         this_arg_conv.is_owned = false;
56984         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
56985         return ret_conv;
56986 }
56987
56988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1until_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
56989         LDKInvoice this_arg_conv;
56990         this_arg_conv.inner = untag_ptr(this_arg);
56991         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56993         this_arg_conv.is_owned = false;
56994         int64_t ret_conv = Invoice_duration_until_expiry(&this_arg_conv);
56995         return ret_conv;
56996 }
56997
56998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiration_1remaining_1from_1epoch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t time) {
56999         LDKInvoice this_arg_conv;
57000         this_arg_conv.inner = untag_ptr(this_arg);
57001         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57003         this_arg_conv.is_owned = false;
57004         int64_t ret_conv = Invoice_expiration_remaining_from_epoch(&this_arg_conv, time);
57005         return ret_conv;
57006 }
57007
57008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
57009         LDKInvoice this_arg_conv;
57010         this_arg_conv.inner = untag_ptr(this_arg);
57011         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57013         this_arg_conv.is_owned = false;
57014         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
57015         return ret_conv;
57016 }
57017
57018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_arg) {
57019         LDKInvoice this_arg_conv;
57020         this_arg_conv.inner = untag_ptr(this_arg);
57021         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57023         this_arg_conv.is_owned = false;
57024         int64_t ret_conv = Invoice_min_final_cltv_expiry_delta(&this_arg_conv);
57025         return ret_conv;
57026 }
57027
57028 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Invoice_1fallback_1addresses(JNIEnv *env, jclass clz, int64_t this_arg) {
57029         LDKInvoice this_arg_conv;
57030         this_arg_conv.inner = untag_ptr(this_arg);
57031         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57033         this_arg_conv.is_owned = false;
57034         LDKCVec_AddressZ ret_var = Invoice_fallback_addresses(&this_arg_conv);
57035         jobjectArray ret_arr = NULL;
57036         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, String_clz, NULL);
57037         ;
57038         jstring *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
57039         for (size_t i = 0; i < ret_var.datalen; i++) {
57040                 LDKStr ret_conv_8_str = ret_var.data[i];
57041                 jstring ret_conv_8_conv = str_ref_to_java(env, ret_conv_8_str.chars, ret_conv_8_str.len);
57042                 Str_free(ret_conv_8_str);
57043                 ret_arr_ptr[i] = ret_conv_8_conv;
57044         }
57045         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
57046         FREE(ret_var.data);
57047         return ret_arr;
57048 }
57049
57050 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
57051         LDKInvoice this_arg_conv;
57052         this_arg_conv.inner = untag_ptr(this_arg);
57053         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57055         this_arg_conv.is_owned = false;
57056         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
57057         int64_tArray ret_arr = NULL;
57058         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
57059         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
57060         for (size_t o = 0; o < ret_var.datalen; o++) {
57061                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
57062                 int64_t ret_conv_14_ref = 0;
57063                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
57064                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
57065                 ret_arr_ptr[o] = ret_conv_14_ref;
57066         }
57067         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
57068         FREE(ret_var.data);
57069         return ret_arr;
57070 }
57071
57072 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
57073         LDKInvoice this_arg_conv;
57074         this_arg_conv.inner = untag_ptr(this_arg);
57075         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57077         this_arg_conv.is_owned = false;
57078         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
57079         int64_tArray ret_arr = NULL;
57080         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
57081         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
57082         for (size_t l = 0; l < ret_var.datalen; l++) {
57083                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
57084                 int64_t ret_conv_11_ref = 0;
57085                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
57086                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
57087                 ret_arr_ptr[l] = ret_conv_11_ref;
57088         }
57089         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
57090         FREE(ret_var.data);
57091         return ret_arr;
57092 }
57093
57094 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
57095         LDKInvoice this_arg_conv;
57096         this_arg_conv.inner = untag_ptr(this_arg);
57097         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57099         this_arg_conv.is_owned = false;
57100         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
57101         return ret_conv;
57102 }
57103
57104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
57105         LDKInvoice this_arg_conv;
57106         this_arg_conv.inner = untag_ptr(this_arg);
57107         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57109         this_arg_conv.is_owned = false;
57110         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
57111         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
57112         int64_t ret_ref = tag_ptr(ret_copy, true);
57113         return ret_ref;
57114 }
57115
57116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
57117         LDKStr description_conv = java_to_owned_str(env, description);
57118         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
57119         *ret_conv = Description_new(description_conv);
57120         return tag_ptr(ret_conv, true);
57121 }
57122
57123 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
57124         LDKDescription this_arg_conv;
57125         this_arg_conv.inner = untag_ptr(this_arg);
57126         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57128         this_arg_conv = Description_clone(&this_arg_conv);
57129         LDKStr ret_str = Description_into_inner(this_arg_conv);
57130         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57131         Str_free(ret_str);
57132         return ret_conv;
57133 }
57134
57135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
57136         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
57137         int64_t ret_ref = 0;
57138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57139         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57140         return ret_ref;
57141 }
57142
57143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
57144         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
57145         int64_t ret_ref = 0;
57146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57147         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57148         return ret_ref;
57149 }
57150
57151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
57152         LDKExpiryTime this_arg_conv;
57153         this_arg_conv.inner = untag_ptr(this_arg);
57154         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57156         this_arg_conv.is_owned = false;
57157         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
57158         return ret_conv;
57159 }
57160
57161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
57162         LDKExpiryTime this_arg_conv;
57163         this_arg_conv.inner = untag_ptr(this_arg);
57164         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57166         this_arg_conv.is_owned = false;
57167         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
57168         return ret_conv;
57169 }
57170
57171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
57172         LDKRouteHint hops_conv;
57173         hops_conv.inner = untag_ptr(hops);
57174         hops_conv.is_owned = ptr_is_owned(hops);
57175         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
57176         hops_conv = RouteHint_clone(&hops_conv);
57177         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
57178         *ret_conv = PrivateRoute_new(hops_conv);
57179         return tag_ptr(ret_conv, true);
57180 }
57181
57182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
57183         LDKPrivateRoute this_arg_conv;
57184         this_arg_conv.inner = untag_ptr(this_arg);
57185         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57187         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
57188         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
57189         int64_t ret_ref = 0;
57190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57191         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57192         return ret_ref;
57193 }
57194
57195 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57196         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
57197         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
57198         return ret_conv;
57199 }
57200
57201 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
57202         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
57203         return ret_conv;
57204 }
57205
57206 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
57207         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
57208         return ret_conv;
57209 }
57210
57211 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
57212         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
57213         return ret_conv;
57214 }
57215
57216 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
57217         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
57218         return ret_conv;
57219 }
57220
57221 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
57222         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
57223         return ret_conv;
57224 }
57225
57226 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1min_1final_1cltv_1expiry_1delta_1too_1short(JNIEnv *env, jclass clz) {
57227         jclass ret_conv = LDKCreationError_to_java(env, CreationError_min_final_cltv_expiry_delta_too_short());
57228         return ret_conv;
57229 }
57230
57231 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
57232         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
57233         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
57234         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
57235         return ret_conv;
57236 }
57237
57238 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57239         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
57240         LDKStr ret_str = CreationError_to_str(o_conv);
57241         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57242         Str_free(ret_str);
57243         return ret_conv;
57244 }
57245
57246 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57247         LDKSemanticError* orig_conv = (LDKSemanticError*)untag_ptr(orig);
57248         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
57249         return ret_conv;
57250 }
57251
57252 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
57253         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
57254         return ret_conv;
57255 }
57256
57257 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
57258         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
57259         return ret_conv;
57260 }
57261
57262 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
57263         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
57264         return ret_conv;
57265 }
57266
57267 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
57268         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
57269         return ret_conv;
57270 }
57271
57272 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
57273         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
57274         return ret_conv;
57275 }
57276
57277 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
57278         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
57279         return ret_conv;
57280 }
57281
57282 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
57283         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
57284         return ret_conv;
57285 }
57286
57287 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
57288         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
57289         return ret_conv;
57290 }
57291
57292 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
57293         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
57294         return ret_conv;
57295 }
57296
57297 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
57298         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
57299         return ret_conv;
57300 }
57301
57302 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
57303         LDKSemanticError* a_conv = (LDKSemanticError*)untag_ptr(a);
57304         LDKSemanticError* b_conv = (LDKSemanticError*)untag_ptr(b);
57305         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
57306         return ret_conv;
57307 }
57308
57309 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57310         LDKSemanticError* o_conv = (LDKSemanticError*)untag_ptr(o);
57311         LDKStr ret_str = SemanticError_to_str(o_conv);
57312         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57313         Str_free(ret_str);
57314         return ret_conv;
57315 }
57316
57317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
57318         if (!ptr_is_owned(this_ptr)) return;
57319         void* this_ptr_ptr = untag_ptr(this_ptr);
57320         CHECK_ACCESS(this_ptr_ptr);
57321         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
57322         FREE(untag_ptr(this_ptr));
57323         SignOrCreationError_free(this_ptr_conv);
57324 }
57325
57326 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
57327         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57328         *ret_copy = SignOrCreationError_clone(arg);
57329         int64_t ret_ref = tag_ptr(ret_copy, true);
57330         return ret_ref;
57331 }
57332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
57333         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
57334         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
57335         return ret_conv;
57336 }
57337
57338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57339         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
57340         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57341         *ret_copy = SignOrCreationError_clone(orig_conv);
57342         int64_t ret_ref = tag_ptr(ret_copy, true);
57343         return ret_ref;
57344 }
57345
57346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
57347         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57348         *ret_copy = SignOrCreationError_sign_error();
57349         int64_t ret_ref = tag_ptr(ret_copy, true);
57350         return ret_ref;
57351 }
57352
57353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
57354         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
57355         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57356         *ret_copy = SignOrCreationError_creation_error(a_conv);
57357         int64_t ret_ref = tag_ptr(ret_copy, true);
57358         return ret_ref;
57359 }
57360
57361 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
57362         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
57363         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
57364         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
57365         return ret_conv;
57366 }
57367
57368 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57369         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
57370         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
57371         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57372         Str_free(ret_str);
57373         return ret_conv;
57374 }
57375
57376 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) {
57377         LDKInvoice invoice_conv;
57378         invoice_conv.inner = untag_ptr(invoice);
57379         invoice_conv.is_owned = ptr_is_owned(invoice);
57380         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
57381         invoice_conv.is_owned = false;
57382         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57383         CHECK_ACCESS(retry_strategy_ptr);
57384         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57385         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57386         LDKChannelManager channelmanager_conv;
57387         channelmanager_conv.inner = untag_ptr(channelmanager);
57388         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57389         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57390         channelmanager_conv.is_owned = false;
57391         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
57392         *ret_conv = pay_invoice(&invoice_conv, retry_strategy_conv, &channelmanager_conv);
57393         return tag_ptr(ret_conv, true);
57394 }
57395
57396 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) {
57397         LDKInvoice invoice_conv;
57398         invoice_conv.inner = untag_ptr(invoice);
57399         invoice_conv.is_owned = ptr_is_owned(invoice);
57400         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
57401         invoice_conv.is_owned = false;
57402         LDKThirtyTwoBytes payment_id_ref;
57403         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
57404         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
57405         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57406         CHECK_ACCESS(retry_strategy_ptr);
57407         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57408         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57409         LDKChannelManager channelmanager_conv;
57410         channelmanager_conv.inner = untag_ptr(channelmanager);
57411         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57412         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57413         channelmanager_conv.is_owned = false;
57414         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
57415         *ret_conv = pay_invoice_with_id(&invoice_conv, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
57416         return tag_ptr(ret_conv, true);
57417 }
57418
57419 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) {
57420         LDKInvoice invoice_conv;
57421         invoice_conv.inner = untag_ptr(invoice);
57422         invoice_conv.is_owned = ptr_is_owned(invoice);
57423         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
57424         invoice_conv.is_owned = false;
57425         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57426         CHECK_ACCESS(retry_strategy_ptr);
57427         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57428         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57429         LDKChannelManager channelmanager_conv;
57430         channelmanager_conv.inner = untag_ptr(channelmanager);
57431         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57432         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57433         channelmanager_conv.is_owned = false;
57434         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
57435         *ret_conv = pay_zero_value_invoice(&invoice_conv, amount_msats, retry_strategy_conv, &channelmanager_conv);
57436         return tag_ptr(ret_conv, true);
57437 }
57438
57439 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) {
57440         LDKInvoice invoice_conv;
57441         invoice_conv.inner = untag_ptr(invoice);
57442         invoice_conv.is_owned = ptr_is_owned(invoice);
57443         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
57444         invoice_conv.is_owned = false;
57445         LDKThirtyTwoBytes payment_id_ref;
57446         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
57447         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
57448         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57449         CHECK_ACCESS(retry_strategy_ptr);
57450         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57451         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57452         LDKChannelManager channelmanager_conv;
57453         channelmanager_conv.inner = untag_ptr(channelmanager);
57454         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57455         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57456         channelmanager_conv.is_owned = false;
57457         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
57458         *ret_conv = pay_zero_value_invoice_with_id(&invoice_conv, amount_msats, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
57459         return tag_ptr(ret_conv, true);
57460 }
57461
57462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
57463         if (!ptr_is_owned(this_ptr)) return;
57464         void* this_ptr_ptr = untag_ptr(this_ptr);
57465         CHECK_ACCESS(this_ptr_ptr);
57466         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
57467         FREE(untag_ptr(this_ptr));
57468         PaymentError_free(this_ptr_conv);
57469 }
57470
57471 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
57472         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57473         *ret_copy = PaymentError_clone(arg);
57474         int64_t ret_ref = tag_ptr(ret_copy, true);
57475         return ret_ref;
57476 }
57477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
57478         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
57479         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
57480         return ret_conv;
57481 }
57482
57483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57484         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
57485         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57486         *ret_copy = PaymentError_clone(orig_conv);
57487         int64_t ret_ref = tag_ptr(ret_copy, true);
57488         return ret_ref;
57489 }
57490
57491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
57492         LDKStr a_conv = java_to_owned_str(env, a);
57493         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57494         *ret_copy = PaymentError_invoice(a_conv);
57495         int64_t ret_ref = tag_ptr(ret_copy, true);
57496         return ret_ref;
57497 }
57498
57499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, jclass a) {
57500         LDKRetryableSendFailure a_conv = LDKRetryableSendFailure_from_java(env, a);
57501         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57502         *ret_copy = PaymentError_sending(a_conv);
57503         int64_t ret_ref = tag_ptr(ret_copy, true);
57504         return ret_ref;
57505 }
57506
57507 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) {
57508         void* amt_msat_ptr = untag_ptr(amt_msat);
57509         CHECK_ACCESS(amt_msat_ptr);
57510         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57511         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57512         LDKThirtyTwoBytes payment_hash_ref;
57513         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
57514         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
57515         LDKStr description_conv = java_to_owned_str(env, description);
57516         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
57517         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
57518         if (phantom_route_hints_constr.datalen > 0)
57519                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
57520         else
57521                 phantom_route_hints_constr.data = NULL;
57522         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
57523         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
57524                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
57525                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
57526                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
57527                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
57528                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
57529                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
57530                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
57531         }
57532         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
57533         void* entropy_source_ptr = untag_ptr(entropy_source);
57534         CHECK_ACCESS(entropy_source_ptr);
57535         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
57536         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
57537                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57538                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
57539         }
57540         void* node_signer_ptr = untag_ptr(node_signer);
57541         CHECK_ACCESS(node_signer_ptr);
57542         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57543         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57544                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57545                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57546         }
57547         void* logger_ptr = untag_ptr(logger);
57548         CHECK_ACCESS(logger_ptr);
57549         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57550         if (logger_conv.free == LDKLogger_JCalls_free) {
57551                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57552                 LDKLogger_JCalls_cloned(&logger_conv);
57553         }
57554         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57555         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57556         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57557         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57558         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57559         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57560         *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);
57561         return tag_ptr(ret_conv, true);
57562 }
57563
57564 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) {
57565         void* amt_msat_ptr = untag_ptr(amt_msat);
57566         CHECK_ACCESS(amt_msat_ptr);
57567         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57568         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57569         LDKThirtyTwoBytes payment_hash_ref;
57570         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
57571         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
57572         LDKSha256 description_hash_conv;
57573         description_hash_conv.inner = untag_ptr(description_hash);
57574         description_hash_conv.is_owned = ptr_is_owned(description_hash);
57575         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
57576         description_hash_conv = Sha256_clone(&description_hash_conv);
57577         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
57578         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
57579         if (phantom_route_hints_constr.datalen > 0)
57580                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
57581         else
57582                 phantom_route_hints_constr.data = NULL;
57583         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
57584         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
57585                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
57586                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
57587                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
57588                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
57589                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
57590                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
57591                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
57592         }
57593         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
57594         void* entropy_source_ptr = untag_ptr(entropy_source);
57595         CHECK_ACCESS(entropy_source_ptr);
57596         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
57597         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
57598                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57599                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
57600         }
57601         void* node_signer_ptr = untag_ptr(node_signer);
57602         CHECK_ACCESS(node_signer_ptr);
57603         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57604         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57605                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57606                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57607         }
57608         void* logger_ptr = untag_ptr(logger);
57609         CHECK_ACCESS(logger_ptr);
57610         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57611         if (logger_conv.free == LDKLogger_JCalls_free) {
57612                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57613                 LDKLogger_JCalls_cloned(&logger_conv);
57614         }
57615         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57616         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57617         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57618         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57619         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57620         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57621         *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);
57622         return tag_ptr(ret_conv, true);
57623 }
57624
57625 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) {
57626         LDKChannelManager channelmanager_conv;
57627         channelmanager_conv.inner = untag_ptr(channelmanager);
57628         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57629         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57630         channelmanager_conv.is_owned = false;
57631         void* node_signer_ptr = untag_ptr(node_signer);
57632         CHECK_ACCESS(node_signer_ptr);
57633         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57634         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57635                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57636                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57637         }
57638         void* logger_ptr = untag_ptr(logger);
57639         CHECK_ACCESS(logger_ptr);
57640         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57641         if (logger_conv.free == LDKLogger_JCalls_free) {
57642                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57643                 LDKLogger_JCalls_cloned(&logger_conv);
57644         }
57645         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57646         void* amt_msat_ptr = untag_ptr(amt_msat);
57647         CHECK_ACCESS(amt_msat_ptr);
57648         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57649         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57650         LDKStr description_conv = java_to_owned_str(env, description);
57651         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57652         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57653         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57654         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57655         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57656         *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);
57657         return tag_ptr(ret_conv, true);
57658 }
57659
57660 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) {
57661         LDKChannelManager channelmanager_conv;
57662         channelmanager_conv.inner = untag_ptr(channelmanager);
57663         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57664         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57665         channelmanager_conv.is_owned = false;
57666         void* node_signer_ptr = untag_ptr(node_signer);
57667         CHECK_ACCESS(node_signer_ptr);
57668         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57669         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57670                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57671                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57672         }
57673         void* logger_ptr = untag_ptr(logger);
57674         CHECK_ACCESS(logger_ptr);
57675         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57676         if (logger_conv.free == LDKLogger_JCalls_free) {
57677                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57678                 LDKLogger_JCalls_cloned(&logger_conv);
57679         }
57680         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57681         void* amt_msat_ptr = untag_ptr(amt_msat);
57682         CHECK_ACCESS(amt_msat_ptr);
57683         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57684         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57685         LDKSha256 description_hash_conv;
57686         description_hash_conv.inner = untag_ptr(description_hash);
57687         description_hash_conv.is_owned = ptr_is_owned(description_hash);
57688         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
57689         description_hash_conv = Sha256_clone(&description_hash_conv);
57690         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57691         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57692         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57693         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57694         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57695         *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);
57696         return tag_ptr(ret_conv, true);
57697 }
57698
57699 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) {
57700         LDKChannelManager channelmanager_conv;
57701         channelmanager_conv.inner = untag_ptr(channelmanager);
57702         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57703         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57704         channelmanager_conv.is_owned = false;
57705         void* node_signer_ptr = untag_ptr(node_signer);
57706         CHECK_ACCESS(node_signer_ptr);
57707         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57708         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57709                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57710                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57711         }
57712         void* logger_ptr = untag_ptr(logger);
57713         CHECK_ACCESS(logger_ptr);
57714         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57715         if (logger_conv.free == LDKLogger_JCalls_free) {
57716                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57717                 LDKLogger_JCalls_cloned(&logger_conv);
57718         }
57719         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57720         void* amt_msat_ptr = untag_ptr(amt_msat);
57721         CHECK_ACCESS(amt_msat_ptr);
57722         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57723         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57724         LDKSha256 description_hash_conv;
57725         description_hash_conv.inner = untag_ptr(description_hash);
57726         description_hash_conv.is_owned = ptr_is_owned(description_hash);
57727         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
57728         description_hash_conv = Sha256_clone(&description_hash_conv);
57729         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57730         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57731         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57732         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57733         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57734         *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);
57735         return tag_ptr(ret_conv, true);
57736 }
57737
57738 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) {
57739         LDKChannelManager channelmanager_conv;
57740         channelmanager_conv.inner = untag_ptr(channelmanager);
57741         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57742         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57743         channelmanager_conv.is_owned = false;
57744         void* node_signer_ptr = untag_ptr(node_signer);
57745         CHECK_ACCESS(node_signer_ptr);
57746         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57747         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57748                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57749                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57750         }
57751         void* logger_ptr = untag_ptr(logger);
57752         CHECK_ACCESS(logger_ptr);
57753         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57754         if (logger_conv.free == LDKLogger_JCalls_free) {
57755                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57756                 LDKLogger_JCalls_cloned(&logger_conv);
57757         }
57758         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57759         void* amt_msat_ptr = untag_ptr(amt_msat);
57760         CHECK_ACCESS(amt_msat_ptr);
57761         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57762         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57763         LDKStr description_conv = java_to_owned_str(env, description);
57764         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57765         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57766         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57767         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57768         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57769         *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);
57770         return tag_ptr(ret_conv, true);
57771 }
57772
57773 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) {
57774         LDKChannelManager channelmanager_conv;
57775         channelmanager_conv.inner = untag_ptr(channelmanager);
57776         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57777         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57778         channelmanager_conv.is_owned = false;
57779         void* node_signer_ptr = untag_ptr(node_signer);
57780         CHECK_ACCESS(node_signer_ptr);
57781         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57782         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57783                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57784                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57785         }
57786         void* logger_ptr = untag_ptr(logger);
57787         CHECK_ACCESS(logger_ptr);
57788         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57789         if (logger_conv.free == LDKLogger_JCalls_free) {
57790                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57791                 LDKLogger_JCalls_cloned(&logger_conv);
57792         }
57793         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57794         void* amt_msat_ptr = untag_ptr(amt_msat);
57795         CHECK_ACCESS(amt_msat_ptr);
57796         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57797         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57798         LDKStr description_conv = java_to_owned_str(env, description);
57799         LDKThirtyTwoBytes payment_hash_ref;
57800         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
57801         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
57802         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57803         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57804         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57805         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57806         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57807         *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);
57808         return tag_ptr(ret_conv, true);
57809 }
57810
57811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
57812         LDKStr s_conv = java_to_owned_str(env, s);
57813         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
57814         *ret_conv = SiPrefix_from_str(s_conv);
57815         return tag_ptr(ret_conv, true);
57816 }
57817
57818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
57819         LDKStr s_conv = java_to_owned_str(env, s);
57820         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
57821         *ret_conv = Invoice_from_str(s_conv);
57822         return tag_ptr(ret_conv, true);
57823 }
57824
57825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
57826         LDKStr s_conv = java_to_owned_str(env, s);
57827         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
57828         *ret_conv = SignedRawInvoice_from_str(s_conv);
57829         return tag_ptr(ret_conv, true);
57830 }
57831
57832 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57833         LDKParseError* o_conv = (LDKParseError*)untag_ptr(o);
57834         LDKStr ret_str = ParseError_to_str(o_conv);
57835         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57836         Str_free(ret_str);
57837         return ret_conv;
57838 }
57839
57840 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57841         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
57842         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
57843         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57844         Str_free(ret_str);
57845         return ret_conv;
57846 }
57847
57848 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57849         LDKInvoice o_conv;
57850         o_conv.inner = untag_ptr(o);
57851         o_conv.is_owned = ptr_is_owned(o);
57852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
57853         o_conv.is_owned = false;
57854         LDKStr ret_str = Invoice_to_str(&o_conv);
57855         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57856         Str_free(ret_str);
57857         return ret_conv;
57858 }
57859
57860 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57861         LDKSignedRawInvoice o_conv;
57862         o_conv.inner = untag_ptr(o);
57863         o_conv.is_owned = ptr_is_owned(o);
57864         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
57865         o_conv.is_owned = false;
57866         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
57867         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57868         Str_free(ret_str);
57869         return ret_conv;
57870 }
57871
57872 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57873         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
57874         LDKStr ret_str = Currency_to_str(o_conv);
57875         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57876         Str_free(ret_str);
57877         return ret_conv;
57878 }
57879
57880 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57881         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
57882         LDKStr ret_str = SiPrefix_to_str(o_conv);
57883         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57884         Str_free(ret_str);
57885         return ret_conv;
57886 }
57887
57888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
57889         LDKRapidGossipSync this_obj_conv;
57890         this_obj_conv.inner = untag_ptr(this_obj);
57891         this_obj_conv.is_owned = ptr_is_owned(this_obj);
57892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
57893         RapidGossipSync_free(this_obj_conv);
57894 }
57895
57896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
57897         LDKNetworkGraph network_graph_conv;
57898         network_graph_conv.inner = untag_ptr(network_graph);
57899         network_graph_conv.is_owned = ptr_is_owned(network_graph);
57900         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
57901         network_graph_conv.is_owned = false;
57902         void* logger_ptr = untag_ptr(logger);
57903         CHECK_ACCESS(logger_ptr);
57904         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57905         if (logger_conv.free == LDKLogger_JCalls_free) {
57906                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57907                 LDKLogger_JCalls_cloned(&logger_conv);
57908         }
57909         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv, logger_conv);
57910         int64_t ret_ref = 0;
57911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57912         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57913         return ret_ref;
57914 }
57915
57916 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) {
57917         LDKRapidGossipSync this_arg_conv;
57918         this_arg_conv.inner = untag_ptr(this_arg);
57919         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57921         this_arg_conv.is_owned = false;
57922         LDKu8slice update_data_ref;
57923         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
57924         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
57925         void* current_time_unix_ptr = untag_ptr(current_time_unix);
57926         CHECK_ACCESS(current_time_unix_ptr);
57927         LDKCOption_u64Z current_time_unix_conv = *(LDKCOption_u64Z*)(current_time_unix_ptr);
57928         current_time_unix_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(current_time_unix));
57929         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
57930         *ret_conv = RapidGossipSync_update_network_graph_no_std(&this_arg_conv, update_data_ref, current_time_unix_conv);
57931         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
57932         return tag_ptr(ret_conv, true);
57933 }
57934
57935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
57936         LDKRapidGossipSync this_arg_conv;
57937         this_arg_conv.inner = untag_ptr(this_arg);
57938         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57940         this_arg_conv.is_owned = false;
57941         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
57942         return ret_conv;
57943 }
57944
57945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
57946         if (!ptr_is_owned(this_ptr)) return;
57947         void* this_ptr_ptr = untag_ptr(this_ptr);
57948         CHECK_ACCESS(this_ptr_ptr);
57949         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
57950         FREE(untag_ptr(this_ptr));
57951         GraphSyncError_free(this_ptr_conv);
57952 }
57953
57954 static inline uint64_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
57955         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57956         *ret_copy = GraphSyncError_clone(arg);
57957         int64_t ret_ref = tag_ptr(ret_copy, true);
57958         return ret_ref;
57959 }
57960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
57961         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)untag_ptr(arg);
57962         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
57963         return ret_conv;
57964 }
57965
57966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57967         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)untag_ptr(orig);
57968         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57969         *ret_copy = GraphSyncError_clone(orig_conv);
57970         int64_t ret_ref = tag_ptr(ret_copy, true);
57971         return ret_ref;
57972 }
57973
57974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
57975         void* a_ptr = untag_ptr(a);
57976         CHECK_ACCESS(a_ptr);
57977         LDKDecodeError a_conv = *(LDKDecodeError*)(a_ptr);
57978         a_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(a));
57979         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57980         *ret_copy = GraphSyncError_decode_error(a_conv);
57981         int64_t ret_ref = tag_ptr(ret_copy, true);
57982         return ret_ref;
57983 }
57984
57985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
57986         LDKLightningError a_conv;
57987         a_conv.inner = untag_ptr(a);
57988         a_conv.is_owned = ptr_is_owned(a);
57989         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
57990         a_conv = LightningError_clone(&a_conv);
57991         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57992         *ret_copy = GraphSyncError_lightning_error(a_conv);
57993         int64_t ret_ref = tag_ptr(ret_copy, true);
57994         return ret_ref;
57995 }
57996