6a44bd7f87e91693ee122a7c76938e3726b06f99
[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, "Ljava/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         // WARNING: we may need a move here but no clone is available for LDKCOption_ScalarZ
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20931         LDKThirtyTwoBytes o_ref;
20932         CHECK((*env)->GetArrayLength(env, o) == 32);
20933         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20934         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20935         *ret_conv = CResult_SharedSecretNoneZ_ok(o_ref);
20936         return tag_ptr(ret_conv, true);
20937 }
20938
20939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1err(JNIEnv *env, jclass clz) {
20940         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20941         *ret_conv = CResult_SharedSecretNoneZ_err();
20942         return tag_ptr(ret_conv, true);
20943 }
20944
20945 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20946         LDKCResult_SharedSecretNoneZ* o_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(o);
20947         jboolean ret_conv = CResult_SharedSecretNoneZ_is_ok(o_conv);
20948         return ret_conv;
20949 }
20950
20951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20952         if (!ptr_is_owned(_res)) return;
20953         void* _res_ptr = untag_ptr(_res);
20954         CHECK_ACCESS(_res_ptr);
20955         LDKCResult_SharedSecretNoneZ _res_conv = *(LDKCResult_SharedSecretNoneZ*)(_res_ptr);
20956         FREE(untag_ptr(_res));
20957         CResult_SharedSecretNoneZ_free(_res_conv);
20958 }
20959
20960 static inline uint64_t CResult_SharedSecretNoneZ_clone_ptr(LDKCResult_SharedSecretNoneZ *NONNULL_PTR arg) {
20961         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20962         *ret_conv = CResult_SharedSecretNoneZ_clone(arg);
20963         return tag_ptr(ret_conv, true);
20964 }
20965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20966         LDKCResult_SharedSecretNoneZ* arg_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(arg);
20967         int64_t ret_conv = CResult_SharedSecretNoneZ_clone_ptr(arg_conv);
20968         return ret_conv;
20969 }
20970
20971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20972         LDKCResult_SharedSecretNoneZ* orig_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(orig);
20973         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20974         *ret_conv = CResult_SharedSecretNoneZ_clone(orig_conv);
20975         return tag_ptr(ret_conv, true);
20976 }
20977
20978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1U5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20979         LDKCVec_U5Z _res_constr;
20980         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20981         if (_res_constr.datalen > 0)
20982                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
20983         else
20984                 _res_constr.data = NULL;
20985         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
20986         for (size_t h = 0; h < _res_constr.datalen; h++) {
20987                 int8_t _res_conv_7 = _res_vals[h];
20988                 
20989                 _res_constr.data[h] = (LDKU5){ ._0 = _res_conv_7 };
20990         }
20991         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
20992         CVec_U5Z_free(_res_constr);
20993 }
20994
20995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20996         LDKRecoverableSignature o_ref;
20997         CHECK((*env)->GetArrayLength(env, o) == 68);
20998         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
20999         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21000         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
21001         return tag_ptr(ret_conv, true);
21002 }
21003
21004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
21005         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21006         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
21007         return tag_ptr(ret_conv, true);
21008 }
21009
21010 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21011         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
21012         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
21013         return ret_conv;
21014 }
21015
21016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21017         if (!ptr_is_owned(_res)) return;
21018         void* _res_ptr = untag_ptr(_res);
21019         CHECK_ACCESS(_res_ptr);
21020         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
21021         FREE(untag_ptr(_res));
21022         CResult_RecoverableSignatureNoneZ_free(_res_conv);
21023 }
21024
21025 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
21026         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21027         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
21028         return tag_ptr(ret_conv, true);
21029 }
21030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21031         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
21032         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
21033         return ret_conv;
21034 }
21035
21036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21037         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
21038         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
21039         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
21040         return tag_ptr(ret_conv, true);
21041 }
21042
21043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21044         void* o_ptr = untag_ptr(o);
21045         CHECK_ACCESS(o_ptr);
21046         LDKWriteableEcdsaChannelSigner o_conv = *(LDKWriteableEcdsaChannelSigner*)(o_ptr);
21047         if (o_conv.free == LDKWriteableEcdsaChannelSigner_JCalls_free) {
21048                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21049                 LDKWriteableEcdsaChannelSigner_JCalls_cloned(&o_conv);
21050         }
21051         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21052         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(o_conv);
21053         return tag_ptr(ret_conv, true);
21054 }
21055
21056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21057         void* e_ptr = untag_ptr(e);
21058         CHECK_ACCESS(e_ptr);
21059         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21060         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21061         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21062         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e_conv);
21063         return tag_ptr(ret_conv, true);
21064 }
21065
21066 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21067         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* o_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(o);
21068         jboolean ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(o_conv);
21069         return ret_conv;
21070 }
21071
21072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21073         if (!ptr_is_owned(_res)) return;
21074         void* _res_ptr = untag_ptr(_res);
21075         CHECK_ACCESS(_res_ptr);
21076         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ _res_conv = *(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)(_res_ptr);
21077         FREE(untag_ptr(_res));
21078         CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(_res_conv);
21079 }
21080
21081 static inline uint64_t CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR arg) {
21082         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21083         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(arg);
21084         return tag_ptr(ret_conv, true);
21085 }
21086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21087         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* arg_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(arg);
21088         int64_t ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(arg_conv);
21089         return ret_conv;
21090 }
21091
21092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WriteableEcdsaChannelSignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21093         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* orig_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(orig);
21094         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
21095         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(orig_conv);
21096         return tag_ptr(ret_conv, true);
21097 }
21098
21099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21100         LDKCVec_CVec_u8ZZ _res_constr;
21101         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21102         if (_res_constr.datalen > 0)
21103                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
21104         else
21105                 _res_constr.data = NULL;
21106         for (size_t i = 0; i < _res_constr.datalen; i++) {
21107                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21108                 LDKCVec_u8Z _res_conv_8_ref;
21109                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
21110                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
21111                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
21112                 _res_constr.data[i] = _res_conv_8_ref;
21113         }
21114         CVec_CVec_u8ZZ_free(_res_constr);
21115 }
21116
21117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
21118         LDKCVec_CVec_u8ZZ o_constr;
21119         o_constr.datalen = (*env)->GetArrayLength(env, o);
21120         if (o_constr.datalen > 0)
21121                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
21122         else
21123                 o_constr.data = NULL;
21124         for (size_t i = 0; i < o_constr.datalen; i++) {
21125                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
21126                 LDKCVec_u8Z o_conv_8_ref;
21127                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
21128                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
21129                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
21130                 o_constr.data[i] = o_conv_8_ref;
21131         }
21132         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21133         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
21134         return tag_ptr(ret_conv, true);
21135 }
21136
21137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
21138         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21139         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
21140         return tag_ptr(ret_conv, true);
21141 }
21142
21143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21144         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
21145         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
21146         return ret_conv;
21147 }
21148
21149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21150         if (!ptr_is_owned(_res)) return;
21151         void* _res_ptr = untag_ptr(_res);
21152         CHECK_ACCESS(_res_ptr);
21153         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
21154         FREE(untag_ptr(_res));
21155         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
21156 }
21157
21158 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
21159         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21160         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
21161         return tag_ptr(ret_conv, true);
21162 }
21163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21164         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
21165         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
21166         return ret_conv;
21167 }
21168
21169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21170         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
21171         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
21172         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
21173         return tag_ptr(ret_conv, true);
21174 }
21175
21176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21177         LDKInMemorySigner o_conv;
21178         o_conv.inner = untag_ptr(o);
21179         o_conv.is_owned = ptr_is_owned(o);
21180         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21181         o_conv = InMemorySigner_clone(&o_conv);
21182         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21183         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
21184         return tag_ptr(ret_conv, true);
21185 }
21186
21187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21188         void* e_ptr = untag_ptr(e);
21189         CHECK_ACCESS(e_ptr);
21190         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21191         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21192         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21193         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
21194         return tag_ptr(ret_conv, true);
21195 }
21196
21197 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21198         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
21199         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
21200         return ret_conv;
21201 }
21202
21203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21204         if (!ptr_is_owned(_res)) return;
21205         void* _res_ptr = untag_ptr(_res);
21206         CHECK_ACCESS(_res_ptr);
21207         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
21208         FREE(untag_ptr(_res));
21209         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
21210 }
21211
21212 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
21213         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21214         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
21215         return tag_ptr(ret_conv, true);
21216 }
21217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21218         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
21219         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
21220         return ret_conv;
21221 }
21222
21223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21224         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
21225         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
21226         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
21227         return tag_ptr(ret_conv, true);
21228 }
21229
21230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21231         LDKCVec_TxOutZ _res_constr;
21232         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21233         if (_res_constr.datalen > 0)
21234                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
21235         else
21236                 _res_constr.data = NULL;
21237         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21238         for (size_t h = 0; h < _res_constr.datalen; h++) {
21239                 int64_t _res_conv_7 = _res_vals[h];
21240                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
21241                 CHECK_ACCESS(_res_conv_7_ptr);
21242                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
21243                 FREE(untag_ptr(_res_conv_7));
21244                 _res_constr.data[h] = _res_conv_7_conv;
21245         }
21246         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21247         CVec_TxOutZ_free(_res_constr);
21248 }
21249
21250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21251         LDKTransaction o_ref;
21252         o_ref.datalen = (*env)->GetArrayLength(env, o);
21253         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
21254         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
21255         o_ref.data_is_owned = true;
21256         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21257         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
21258         return tag_ptr(ret_conv, true);
21259 }
21260
21261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
21262         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21263         *ret_conv = CResult_TransactionNoneZ_err();
21264         return tag_ptr(ret_conv, true);
21265 }
21266
21267 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21268         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
21269         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
21270         return ret_conv;
21271 }
21272
21273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21274         if (!ptr_is_owned(_res)) return;
21275         void* _res_ptr = untag_ptr(_res);
21276         CHECK_ACCESS(_res_ptr);
21277         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
21278         FREE(untag_ptr(_res));
21279         CResult_TransactionNoneZ_free(_res_conv);
21280 }
21281
21282 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
21283         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21284         *ret_conv = CResult_TransactionNoneZ_clone(arg);
21285         return tag_ptr(ret_conv, true);
21286 }
21287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21288         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
21289         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
21290         return ret_conv;
21291 }
21292
21293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21294         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
21295         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
21296         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
21297         return tag_ptr(ret_conv, true);
21298 }
21299
21300 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
21301         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
21302         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
21303         return tag_ptr(ret_conv, true);
21304 }
21305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21306         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(arg);
21307         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
21308         return ret_conv;
21309 }
21310
21311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21312         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(orig);
21313         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
21314         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
21315         return tag_ptr(ret_conv, true);
21316 }
21317
21318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21319         LDKThirtyTwoBytes a_ref;
21320         CHECK((*env)->GetArrayLength(env, a) == 32);
21321         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21322         LDKChannelMonitor b_conv;
21323         b_conv.inner = untag_ptr(b);
21324         b_conv.is_owned = ptr_is_owned(b);
21325         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21326         b_conv = ChannelMonitor_clone(&b_conv);
21327         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
21328         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
21329         return tag_ptr(ret_conv, true);
21330 }
21331
21332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21333         if (!ptr_is_owned(_res)) return;
21334         void* _res_ptr = untag_ptr(_res);
21335         CHECK_ACCESS(_res_ptr);
21336         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
21337         FREE(untag_ptr(_res));
21338         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
21339 }
21340
21341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21342         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
21343         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21344         if (_res_constr.datalen > 0)
21345                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
21346         else
21347                 _res_constr.data = NULL;
21348         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21349         for (size_t j = 0; j < _res_constr.datalen; j++) {
21350                 int64_t _res_conv_35 = _res_vals[j];
21351                 void* _res_conv_35_ptr = untag_ptr(_res_conv_35);
21352                 CHECK_ACCESS(_res_conv_35_ptr);
21353                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
21354                 FREE(untag_ptr(_res_conv_35));
21355                 _res_constr.data[j] = _res_conv_35_conv;
21356         }
21357         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21358         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
21359 }
21360
21361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
21362         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
21363         o_constr.datalen = (*env)->GetArrayLength(env, o);
21364         if (o_constr.datalen > 0)
21365                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
21366         else
21367                 o_constr.data = NULL;
21368         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
21369         for (size_t j = 0; j < o_constr.datalen; j++) {
21370                 int64_t o_conv_35 = o_vals[j];
21371                 void* o_conv_35_ptr = untag_ptr(o_conv_35);
21372                 CHECK_ACCESS(o_conv_35_ptr);
21373                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
21374                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o_conv_35));
21375                 o_constr.data[j] = o_conv_35_conv;
21376         }
21377         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
21378         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21379         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
21380         return tag_ptr(ret_conv, true);
21381 }
21382
21383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21384         LDKIOError e_conv = LDKIOError_from_java(env, e);
21385         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21386         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
21387         return tag_ptr(ret_conv, true);
21388 }
21389
21390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21391         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(o);
21392         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
21393         return ret_conv;
21394 }
21395
21396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21397         if (!ptr_is_owned(_res)) return;
21398         void* _res_ptr = untag_ptr(_res);
21399         CHECK_ACCESS(_res_ptr);
21400         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
21401         FREE(untag_ptr(_res));
21402         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
21403 }
21404
21405 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
21406         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21407         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
21408         return tag_ptr(ret_conv, true);
21409 }
21410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21411         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(arg);
21412         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
21413         return ret_conv;
21414 }
21415
21416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21417         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(orig);
21418         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
21419         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
21420         return tag_ptr(ret_conv, true);
21421 }
21422
21423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
21424         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21425         *ret_copy = COption_u16Z_some(o);
21426         int64_t ret_ref = tag_ptr(ret_copy, true);
21427         return ret_ref;
21428 }
21429
21430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
21431         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21432         *ret_copy = COption_u16Z_none();
21433         int64_t ret_ref = tag_ptr(ret_copy, true);
21434         return ret_ref;
21435 }
21436
21437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
21438         if (!ptr_is_owned(_res)) return;
21439         void* _res_ptr = untag_ptr(_res);
21440         CHECK_ACCESS(_res_ptr);
21441         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
21442         FREE(untag_ptr(_res));
21443         COption_u16Z_free(_res_conv);
21444 }
21445
21446 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
21447         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21448         *ret_copy = COption_u16Z_clone(arg);
21449         int64_t ret_ref = tag_ptr(ret_copy, true);
21450         return ret_ref;
21451 }
21452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21453         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
21454         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
21455         return ret_conv;
21456 }
21457
21458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21459         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
21460         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21461         *ret_copy = COption_u16Z_clone(orig_conv);
21462         int64_t ret_ref = tag_ptr(ret_copy, true);
21463         return ret_ref;
21464 }
21465
21466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21467         LDKThirtyTwoBytes o_ref;
21468         CHECK((*env)->GetArrayLength(env, o) == 32);
21469         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21470         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21471         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
21472         return tag_ptr(ret_conv, true);
21473 }
21474
21475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21476         void* e_ptr = untag_ptr(e);
21477         CHECK_ACCESS(e_ptr);
21478         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21479         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21480         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21481         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
21482         return tag_ptr(ret_conv, true);
21483 }
21484
21485 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21486         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(o);
21487         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
21488         return ret_conv;
21489 }
21490
21491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21492         if (!ptr_is_owned(_res)) return;
21493         void* _res_ptr = untag_ptr(_res);
21494         CHECK_ACCESS(_res_ptr);
21495         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
21496         FREE(untag_ptr(_res));
21497         CResult__u832APIErrorZ_free(_res_conv);
21498 }
21499
21500 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
21501         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21502         *ret_conv = CResult__u832APIErrorZ_clone(arg);
21503         return tag_ptr(ret_conv, true);
21504 }
21505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21506         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(arg);
21507         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
21508         return ret_conv;
21509 }
21510
21511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21512         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(orig);
21513         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21514         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
21515         return tag_ptr(ret_conv, true);
21516 }
21517
21518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RecentPaymentDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21519         LDKCVec_RecentPaymentDetailsZ _res_constr;
21520         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21521         if (_res_constr.datalen > 0)
21522                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRecentPaymentDetails), "LDKCVec_RecentPaymentDetailsZ Elements");
21523         else
21524                 _res_constr.data = NULL;
21525         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21526         for (size_t w = 0; w < _res_constr.datalen; w++) {
21527                 int64_t _res_conv_22 = _res_vals[w];
21528                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
21529                 CHECK_ACCESS(_res_conv_22_ptr);
21530                 LDKRecentPaymentDetails _res_conv_22_conv = *(LDKRecentPaymentDetails*)(_res_conv_22_ptr);
21531                 FREE(untag_ptr(_res_conv_22));
21532                 _res_constr.data[w] = _res_conv_22_conv;
21533         }
21534         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21535         CVec_RecentPaymentDetailsZ_free(_res_constr);
21536 }
21537
21538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
21539         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21540         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
21541         return tag_ptr(ret_conv, true);
21542 }
21543
21544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21545         void* e_ptr = untag_ptr(e);
21546         CHECK_ACCESS(e_ptr);
21547         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21548         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21549         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21550         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
21551         return tag_ptr(ret_conv, true);
21552 }
21553
21554 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21555         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
21556         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
21557         return ret_conv;
21558 }
21559
21560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21561         if (!ptr_is_owned(_res)) return;
21562         void* _res_ptr = untag_ptr(_res);
21563         CHECK_ACCESS(_res_ptr);
21564         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
21565         FREE(untag_ptr(_res));
21566         CResult_NonePaymentSendFailureZ_free(_res_conv);
21567 }
21568
21569 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
21570         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21571         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
21572         return tag_ptr(ret_conv, true);
21573 }
21574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21575         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
21576         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
21577         return ret_conv;
21578 }
21579
21580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21581         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
21582         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21583         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
21584         return tag_ptr(ret_conv, true);
21585 }
21586
21587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1ok(JNIEnv *env, jclass clz) {
21588         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21589         *ret_conv = CResult_NoneRetryableSendFailureZ_ok();
21590         return tag_ptr(ret_conv, true);
21591 }
21592
21593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1err(JNIEnv *env, jclass clz, jclass e) {
21594         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_java(env, e);
21595         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21596         *ret_conv = CResult_NoneRetryableSendFailureZ_err(e_conv);
21597         return tag_ptr(ret_conv, true);
21598 }
21599
21600 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21601         LDKCResult_NoneRetryableSendFailureZ* o_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(o);
21602         jboolean ret_conv = CResult_NoneRetryableSendFailureZ_is_ok(o_conv);
21603         return ret_conv;
21604 }
21605
21606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21607         if (!ptr_is_owned(_res)) return;
21608         void* _res_ptr = untag_ptr(_res);
21609         CHECK_ACCESS(_res_ptr);
21610         LDKCResult_NoneRetryableSendFailureZ _res_conv = *(LDKCResult_NoneRetryableSendFailureZ*)(_res_ptr);
21611         FREE(untag_ptr(_res));
21612         CResult_NoneRetryableSendFailureZ_free(_res_conv);
21613 }
21614
21615 static inline uint64_t CResult_NoneRetryableSendFailureZ_clone_ptr(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR arg) {
21616         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21617         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(arg);
21618         return tag_ptr(ret_conv, true);
21619 }
21620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21621         LDKCResult_NoneRetryableSendFailureZ* arg_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(arg);
21622         int64_t ret_conv = CResult_NoneRetryableSendFailureZ_clone_ptr(arg_conv);
21623         return ret_conv;
21624 }
21625
21626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneRetryableSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21627         LDKCResult_NoneRetryableSendFailureZ* orig_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(orig);
21628         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
21629         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(orig_conv);
21630         return tag_ptr(ret_conv, true);
21631 }
21632
21633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21634         LDKThirtyTwoBytes o_ref;
21635         CHECK((*env)->GetArrayLength(env, o) == 32);
21636         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21637         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21638         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
21639         return tag_ptr(ret_conv, true);
21640 }
21641
21642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21643         void* e_ptr = untag_ptr(e);
21644         CHECK_ACCESS(e_ptr);
21645         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21646         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21647         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21648         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
21649         return tag_ptr(ret_conv, true);
21650 }
21651
21652 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21653         LDKCResult_PaymentHashPaymentSendFailureZ* o_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(o);
21654         jboolean ret_conv = CResult_PaymentHashPaymentSendFailureZ_is_ok(o_conv);
21655         return ret_conv;
21656 }
21657
21658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21659         if (!ptr_is_owned(_res)) return;
21660         void* _res_ptr = untag_ptr(_res);
21661         CHECK_ACCESS(_res_ptr);
21662         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(_res_ptr);
21663         FREE(untag_ptr(_res));
21664         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
21665 }
21666
21667 static inline uint64_t CResult_PaymentHashPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR arg) {
21668         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21669         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(arg);
21670         return tag_ptr(ret_conv, true);
21671 }
21672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21673         LDKCResult_PaymentHashPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(arg);
21674         int64_t ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone_ptr(arg_conv);
21675         return ret_conv;
21676 }
21677
21678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21679         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(orig);
21680         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21681         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
21682         return tag_ptr(ret_conv, true);
21683 }
21684
21685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21686         LDKThirtyTwoBytes o_ref;
21687         CHECK((*env)->GetArrayLength(env, o) == 32);
21688         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21689         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21690         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_ok(o_ref);
21691         return tag_ptr(ret_conv, true);
21692 }
21693
21694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1err(JNIEnv *env, jclass clz, jclass e) {
21695         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_java(env, e);
21696         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21697         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_err(e_conv);
21698         return tag_ptr(ret_conv, true);
21699 }
21700
21701 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21702         LDKCResult_PaymentHashRetryableSendFailureZ* o_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(o);
21703         jboolean ret_conv = CResult_PaymentHashRetryableSendFailureZ_is_ok(o_conv);
21704         return ret_conv;
21705 }
21706
21707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21708         if (!ptr_is_owned(_res)) return;
21709         void* _res_ptr = untag_ptr(_res);
21710         CHECK_ACCESS(_res_ptr);
21711         LDKCResult_PaymentHashRetryableSendFailureZ _res_conv = *(LDKCResult_PaymentHashRetryableSendFailureZ*)(_res_ptr);
21712         FREE(untag_ptr(_res));
21713         CResult_PaymentHashRetryableSendFailureZ_free(_res_conv);
21714 }
21715
21716 static inline uint64_t CResult_PaymentHashRetryableSendFailureZ_clone_ptr(LDKCResult_PaymentHashRetryableSendFailureZ *NONNULL_PTR arg) {
21717         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21718         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone(arg);
21719         return tag_ptr(ret_conv, true);
21720 }
21721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21722         LDKCResult_PaymentHashRetryableSendFailureZ* arg_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(arg);
21723         int64_t ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone_ptr(arg_conv);
21724         return ret_conv;
21725 }
21726
21727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashRetryableSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21728         LDKCResult_PaymentHashRetryableSendFailureZ* orig_conv = (LDKCResult_PaymentHashRetryableSendFailureZ*)untag_ptr(orig);
21729         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
21730         *ret_conv = CResult_PaymentHashRetryableSendFailureZ_clone(orig_conv);
21731         return tag_ptr(ret_conv, true);
21732 }
21733
21734 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
21735         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21736         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
21737         return tag_ptr(ret_conv, true);
21738 }
21739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21740         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(arg);
21741         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
21742         return ret_conv;
21743 }
21744
21745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21746         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(orig);
21747         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21748         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
21749         return tag_ptr(ret_conv, true);
21750 }
21751
21752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21753         LDKThirtyTwoBytes a_ref;
21754         CHECK((*env)->GetArrayLength(env, a) == 32);
21755         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21756         LDKThirtyTwoBytes b_ref;
21757         CHECK((*env)->GetArrayLength(env, b) == 32);
21758         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21759         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21760         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
21761         return tag_ptr(ret_conv, true);
21762 }
21763
21764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21765         if (!ptr_is_owned(_res)) return;
21766         void* _res_ptr = untag_ptr(_res);
21767         CHECK_ACCESS(_res_ptr);
21768         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
21769         FREE(untag_ptr(_res));
21770         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
21771 }
21772
21773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21774         void* o_ptr = untag_ptr(o);
21775         CHECK_ACCESS(o_ptr);
21776         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
21777         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(o));
21778         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21779         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
21780         return tag_ptr(ret_conv, true);
21781 }
21782
21783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21784         void* e_ptr = untag_ptr(e);
21785         CHECK_ACCESS(e_ptr);
21786         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21787         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21788         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21789         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
21790         return tag_ptr(ret_conv, true);
21791 }
21792
21793 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21794         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(o);
21795         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
21796         return ret_conv;
21797 }
21798
21799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21800         if (!ptr_is_owned(_res)) return;
21801         void* _res_ptr = untag_ptr(_res);
21802         CHECK_ACCESS(_res_ptr);
21803         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
21804         FREE(untag_ptr(_res));
21805         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
21806 }
21807
21808 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
21809         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21810         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
21811         return tag_ptr(ret_conv, true);
21812 }
21813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21814         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(arg);
21815         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
21816         return ret_conv;
21817 }
21818
21819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21820         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(orig);
21821         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21822         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
21823         return tag_ptr(ret_conv, true);
21824 }
21825
21826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21827         LDKCVec_ThirtyTwoBytesZ _res_constr;
21828         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21829         if (_res_constr.datalen > 0)
21830                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
21831         else
21832                 _res_constr.data = NULL;
21833         for (size_t i = 0; i < _res_constr.datalen; i++) {
21834                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21835                 LDKThirtyTwoBytes _res_conv_8_ref;
21836                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
21837                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
21838                 _res_constr.data[i] = _res_conv_8_ref;
21839         }
21840         CVec_ThirtyTwoBytesZ_free(_res_constr);
21841 }
21842
21843 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
21844         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21845         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
21846         return tag_ptr(ret_conv, true);
21847 }
21848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21849         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(arg);
21850         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
21851         return ret_conv;
21852 }
21853
21854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21855         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(orig);
21856         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21857         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
21858         return tag_ptr(ret_conv, true);
21859 }
21860
21861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21862         LDKThirtyTwoBytes a_ref;
21863         CHECK((*env)->GetArrayLength(env, a) == 32);
21864         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21865         LDKThirtyTwoBytes b_ref;
21866         CHECK((*env)->GetArrayLength(env, b) == 32);
21867         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21868         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21869         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
21870         return tag_ptr(ret_conv, true);
21871 }
21872
21873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21874         if (!ptr_is_owned(_res)) return;
21875         void* _res_ptr = untag_ptr(_res);
21876         CHECK_ACCESS(_res_ptr);
21877         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
21878         FREE(untag_ptr(_res));
21879         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
21880 }
21881
21882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21883         void* o_ptr = untag_ptr(o);
21884         CHECK_ACCESS(o_ptr);
21885         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21886         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21887         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21888         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
21889         return tag_ptr(ret_conv, true);
21890 }
21891
21892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
21893         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21894         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
21895         return tag_ptr(ret_conv, true);
21896 }
21897
21898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21899         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(o);
21900         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
21901         return ret_conv;
21902 }
21903
21904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21905         if (!ptr_is_owned(_res)) return;
21906         void* _res_ptr = untag_ptr(_res);
21907         CHECK_ACCESS(_res_ptr);
21908         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
21909         FREE(untag_ptr(_res));
21910         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
21911 }
21912
21913 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
21914         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21915         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
21916         return tag_ptr(ret_conv, true);
21917 }
21918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21919         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(arg);
21920         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
21921         return ret_conv;
21922 }
21923
21924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21925         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(orig);
21926         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21927         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
21928         return tag_ptr(ret_conv, true);
21929 }
21930
21931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21932         void* o_ptr = untag_ptr(o);
21933         CHECK_ACCESS(o_ptr);
21934         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21935         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21936         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21937         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
21938         return tag_ptr(ret_conv, true);
21939 }
21940
21941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21942         void* e_ptr = untag_ptr(e);
21943         CHECK_ACCESS(e_ptr);
21944         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21945         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21946         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21947         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
21948         return tag_ptr(ret_conv, true);
21949 }
21950
21951 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21952         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(o);
21953         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
21954         return ret_conv;
21955 }
21956
21957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21958         if (!ptr_is_owned(_res)) return;
21959         void* _res_ptr = untag_ptr(_res);
21960         CHECK_ACCESS(_res_ptr);
21961         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
21962         FREE(untag_ptr(_res));
21963         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
21964 }
21965
21966 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
21967         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21968         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
21969         return tag_ptr(ret_conv, true);
21970 }
21971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21972         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(arg);
21973         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
21974         return ret_conv;
21975 }
21976
21977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21978         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(orig);
21979         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21980         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
21981         return tag_ptr(ret_conv, true);
21982 }
21983
21984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21985         LDKThirtyTwoBytes o_ref;
21986         CHECK((*env)->GetArrayLength(env, o) == 32);
21987         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21988         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21989         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
21990         return tag_ptr(ret_conv, true);
21991 }
21992
21993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
21994         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21995         *ret_conv = CResult_PaymentSecretNoneZ_err();
21996         return tag_ptr(ret_conv, true);
21997 }
21998
21999 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22000         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(o);
22001         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
22002         return ret_conv;
22003 }
22004
22005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22006         if (!ptr_is_owned(_res)) return;
22007         void* _res_ptr = untag_ptr(_res);
22008         CHECK_ACCESS(_res_ptr);
22009         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
22010         FREE(untag_ptr(_res));
22011         CResult_PaymentSecretNoneZ_free(_res_conv);
22012 }
22013
22014 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
22015         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22016         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
22017         return tag_ptr(ret_conv, true);
22018 }
22019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22020         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(arg);
22021         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
22022         return ret_conv;
22023 }
22024
22025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22026         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(orig);
22027         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22028         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
22029         return tag_ptr(ret_conv, true);
22030 }
22031
22032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22033         LDKThirtyTwoBytes o_ref;
22034         CHECK((*env)->GetArrayLength(env, o) == 32);
22035         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22036         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22037         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
22038         return tag_ptr(ret_conv, true);
22039 }
22040
22041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22042         void* e_ptr = untag_ptr(e);
22043         CHECK_ACCESS(e_ptr);
22044         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
22045         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
22046         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22047         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
22048         return tag_ptr(ret_conv, true);
22049 }
22050
22051 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22052         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(o);
22053         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
22054         return ret_conv;
22055 }
22056
22057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22058         if (!ptr_is_owned(_res)) return;
22059         void* _res_ptr = untag_ptr(_res);
22060         CHECK_ACCESS(_res_ptr);
22061         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
22062         FREE(untag_ptr(_res));
22063         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
22064 }
22065
22066 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
22067         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22068         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
22069         return tag_ptr(ret_conv, true);
22070 }
22071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22072         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(arg);
22073         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
22074         return ret_conv;
22075 }
22076
22077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22078         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(orig);
22079         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22080         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
22081         return tag_ptr(ret_conv, true);
22082 }
22083
22084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22085         LDKThirtyTwoBytes o_ref;
22086         CHECK((*env)->GetArrayLength(env, o) == 32);
22087         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22088         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22089         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
22090         return tag_ptr(ret_conv, true);
22091 }
22092
22093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22094         void* e_ptr = untag_ptr(e);
22095         CHECK_ACCESS(e_ptr);
22096         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
22097         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
22098         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22099         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
22100         return tag_ptr(ret_conv, true);
22101 }
22102
22103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22104         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(o);
22105         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
22106         return ret_conv;
22107 }
22108
22109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22110         if (!ptr_is_owned(_res)) return;
22111         void* _res_ptr = untag_ptr(_res);
22112         CHECK_ACCESS(_res_ptr);
22113         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
22114         FREE(untag_ptr(_res));
22115         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
22116 }
22117
22118 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
22119         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22120         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
22121         return tag_ptr(ret_conv, true);
22122 }
22123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22124         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(arg);
22125         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
22126         return ret_conv;
22127 }
22128
22129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22130         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(orig);
22131         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22132         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
22133         return tag_ptr(ret_conv, true);
22134 }
22135
22136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22137         LDKCounterpartyForwardingInfo o_conv;
22138         o_conv.inner = untag_ptr(o);
22139         o_conv.is_owned = ptr_is_owned(o);
22140         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22141         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
22142         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22143         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
22144         return tag_ptr(ret_conv, true);
22145 }
22146
22147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22148         void* e_ptr = untag_ptr(e);
22149         CHECK_ACCESS(e_ptr);
22150         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22151         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22152         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22153         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
22154         return tag_ptr(ret_conv, true);
22155 }
22156
22157 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22158         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
22159         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
22160         return ret_conv;
22161 }
22162
22163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22164         if (!ptr_is_owned(_res)) return;
22165         void* _res_ptr = untag_ptr(_res);
22166         CHECK_ACCESS(_res_ptr);
22167         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
22168         FREE(untag_ptr(_res));
22169         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
22170 }
22171
22172 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
22173         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22174         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
22175         return tag_ptr(ret_conv, true);
22176 }
22177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22178         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
22179         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
22180         return ret_conv;
22181 }
22182
22183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22184         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
22185         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
22186         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
22187         return tag_ptr(ret_conv, true);
22188 }
22189
22190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22191         LDKChannelCounterparty o_conv;
22192         o_conv.inner = untag_ptr(o);
22193         o_conv.is_owned = ptr_is_owned(o);
22194         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22195         o_conv = ChannelCounterparty_clone(&o_conv);
22196         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22197         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
22198         return tag_ptr(ret_conv, true);
22199 }
22200
22201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22202         void* e_ptr = untag_ptr(e);
22203         CHECK_ACCESS(e_ptr);
22204         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22205         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22206         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22207         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
22208         return tag_ptr(ret_conv, true);
22209 }
22210
22211 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22212         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
22213         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
22214         return ret_conv;
22215 }
22216
22217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22218         if (!ptr_is_owned(_res)) return;
22219         void* _res_ptr = untag_ptr(_res);
22220         CHECK_ACCESS(_res_ptr);
22221         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
22222         FREE(untag_ptr(_res));
22223         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
22224 }
22225
22226 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
22227         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22228         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
22229         return tag_ptr(ret_conv, true);
22230 }
22231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22232         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
22233         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
22234         return ret_conv;
22235 }
22236
22237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22238         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
22239         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
22240         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
22241         return tag_ptr(ret_conv, true);
22242 }
22243
22244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22245         LDKChannelDetails o_conv;
22246         o_conv.inner = untag_ptr(o);
22247         o_conv.is_owned = ptr_is_owned(o);
22248         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22249         o_conv = ChannelDetails_clone(&o_conv);
22250         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22251         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
22252         return tag_ptr(ret_conv, true);
22253 }
22254
22255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22256         void* e_ptr = untag_ptr(e);
22257         CHECK_ACCESS(e_ptr);
22258         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22259         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22260         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22261         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
22262         return tag_ptr(ret_conv, true);
22263 }
22264
22265 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22266         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
22267         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
22268         return ret_conv;
22269 }
22270
22271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22272         if (!ptr_is_owned(_res)) return;
22273         void* _res_ptr = untag_ptr(_res);
22274         CHECK_ACCESS(_res_ptr);
22275         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
22276         FREE(untag_ptr(_res));
22277         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
22278 }
22279
22280 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
22281         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22282         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
22283         return tag_ptr(ret_conv, true);
22284 }
22285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22286         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
22287         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
22288         return ret_conv;
22289 }
22290
22291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22292         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
22293         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
22294         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
22295         return tag_ptr(ret_conv, true);
22296 }
22297
22298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22299         LDKPhantomRouteHints o_conv;
22300         o_conv.inner = untag_ptr(o);
22301         o_conv.is_owned = ptr_is_owned(o);
22302         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22303         o_conv = PhantomRouteHints_clone(&o_conv);
22304         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22305         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
22306         return tag_ptr(ret_conv, true);
22307 }
22308
22309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22310         void* e_ptr = untag_ptr(e);
22311         CHECK_ACCESS(e_ptr);
22312         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22313         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22314         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22315         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
22316         return tag_ptr(ret_conv, true);
22317 }
22318
22319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22320         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
22321         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
22322         return ret_conv;
22323 }
22324
22325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22326         if (!ptr_is_owned(_res)) return;
22327         void* _res_ptr = untag_ptr(_res);
22328         CHECK_ACCESS(_res_ptr);
22329         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
22330         FREE(untag_ptr(_res));
22331         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
22332 }
22333
22334 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
22335         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22336         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
22337         return tag_ptr(ret_conv, true);
22338 }
22339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22340         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
22341         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
22342         return ret_conv;
22343 }
22344
22345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22346         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
22347         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
22348         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
22349         return tag_ptr(ret_conv, true);
22350 }
22351
22352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22353         LDKCVec_ChannelMonitorZ _res_constr;
22354         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22355         if (_res_constr.datalen > 0)
22356                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
22357         else
22358                 _res_constr.data = NULL;
22359         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22360         for (size_t q = 0; q < _res_constr.datalen; q++) {
22361                 int64_t _res_conv_16 = _res_vals[q];
22362                 LDKChannelMonitor _res_conv_16_conv;
22363                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
22364                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
22365                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
22366                 _res_constr.data[q] = _res_conv_16_conv;
22367         }
22368         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22369         CVec_ChannelMonitorZ_free(_res_constr);
22370 }
22371
22372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
22373         LDKThirtyTwoBytes a_ref;
22374         CHECK((*env)->GetArrayLength(env, a) == 32);
22375         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22376         LDKChannelManager b_conv;
22377         b_conv.inner = untag_ptr(b);
22378         b_conv.is_owned = ptr_is_owned(b);
22379         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22380         // WARNING: we need a move here but no clone is available for LDKChannelManager
22381         
22382         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
22383         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
22384         return tag_ptr(ret_conv, true);
22385 }
22386
22387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22388         if (!ptr_is_owned(_res)) return;
22389         void* _res_ptr = untag_ptr(_res);
22390         CHECK_ACCESS(_res_ptr);
22391         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
22392         FREE(untag_ptr(_res));
22393         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
22394 }
22395
22396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22397         void* o_ptr = untag_ptr(o);
22398         CHECK_ACCESS(o_ptr);
22399         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
22400         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
22401         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
22402         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
22403         return tag_ptr(ret_conv, true);
22404 }
22405
22406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22407         void* e_ptr = untag_ptr(e);
22408         CHECK_ACCESS(e_ptr);
22409         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22410         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22411         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
22412         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
22413         return tag_ptr(ret_conv, true);
22414 }
22415
22416 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22417         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(o);
22418         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
22419         return ret_conv;
22420 }
22421
22422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22423         if (!ptr_is_owned(_res)) return;
22424         void* _res_ptr = untag_ptr(_res);
22425         CHECK_ACCESS(_res_ptr);
22426         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
22427         FREE(untag_ptr(_res));
22428         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
22429 }
22430
22431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22432         LDKChannelConfig o_conv;
22433         o_conv.inner = untag_ptr(o);
22434         o_conv.is_owned = ptr_is_owned(o);
22435         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22436         o_conv = ChannelConfig_clone(&o_conv);
22437         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22438         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
22439         return tag_ptr(ret_conv, true);
22440 }
22441
22442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22443         void* e_ptr = untag_ptr(e);
22444         CHECK_ACCESS(e_ptr);
22445         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22446         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22447         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22448         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
22449         return tag_ptr(ret_conv, true);
22450 }
22451
22452 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22453         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
22454         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
22455         return ret_conv;
22456 }
22457
22458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22459         if (!ptr_is_owned(_res)) return;
22460         void* _res_ptr = untag_ptr(_res);
22461         CHECK_ACCESS(_res_ptr);
22462         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
22463         FREE(untag_ptr(_res));
22464         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
22465 }
22466
22467 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
22468         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22469         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
22470         return tag_ptr(ret_conv, true);
22471 }
22472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22473         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
22474         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
22475         return ret_conv;
22476 }
22477
22478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22479         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
22480         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22481         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
22482         return tag_ptr(ret_conv, true);
22483 }
22484
22485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22486         void* o_ptr = untag_ptr(o);
22487         CHECK_ACCESS(o_ptr);
22488         LDKAPIError o_conv = *(LDKAPIError*)(o_ptr);
22489         o_conv = APIError_clone((LDKAPIError*)untag_ptr(o));
22490         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22491         *ret_copy = COption_APIErrorZ_some(o_conv);
22492         int64_t ret_ref = tag_ptr(ret_copy, true);
22493         return ret_ref;
22494 }
22495
22496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1none(JNIEnv *env, jclass clz) {
22497         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22498         *ret_copy = COption_APIErrorZ_none();
22499         int64_t ret_ref = tag_ptr(ret_copy, true);
22500         return ret_ref;
22501 }
22502
22503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22504         if (!ptr_is_owned(_res)) return;
22505         void* _res_ptr = untag_ptr(_res);
22506         CHECK_ACCESS(_res_ptr);
22507         LDKCOption_APIErrorZ _res_conv = *(LDKCOption_APIErrorZ*)(_res_ptr);
22508         FREE(untag_ptr(_res));
22509         COption_APIErrorZ_free(_res_conv);
22510 }
22511
22512 static inline uint64_t COption_APIErrorZ_clone_ptr(LDKCOption_APIErrorZ *NONNULL_PTR arg) {
22513         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22514         *ret_copy = COption_APIErrorZ_clone(arg);
22515         int64_t ret_ref = tag_ptr(ret_copy, true);
22516         return ret_ref;
22517 }
22518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22519         LDKCOption_APIErrorZ* arg_conv = (LDKCOption_APIErrorZ*)untag_ptr(arg);
22520         int64_t ret_conv = COption_APIErrorZ_clone_ptr(arg_conv);
22521         return ret_conv;
22522 }
22523
22524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22525         LDKCOption_APIErrorZ* orig_conv = (LDKCOption_APIErrorZ*)untag_ptr(orig);
22526         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
22527         *ret_copy = COption_APIErrorZ_clone(orig_conv);
22528         int64_t ret_ref = tag_ptr(ret_copy, true);
22529         return ret_ref;
22530 }
22531
22532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22533         void* o_ptr = untag_ptr(o);
22534         CHECK_ACCESS(o_ptr);
22535         LDKCOption_APIErrorZ o_conv = *(LDKCOption_APIErrorZ*)(o_ptr);
22536         o_conv = COption_APIErrorZ_clone((LDKCOption_APIErrorZ*)untag_ptr(o));
22537         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22538         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_ok(o_conv);
22539         return tag_ptr(ret_conv, true);
22540 }
22541
22542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22543         void* e_ptr = untag_ptr(e);
22544         CHECK_ACCESS(e_ptr);
22545         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22546         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22547         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22548         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_err(e_conv);
22549         return tag_ptr(ret_conv, true);
22550 }
22551
22552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22553         LDKCResult_COption_APIErrorZDecodeErrorZ* o_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(o);
22554         jboolean ret_conv = CResult_COption_APIErrorZDecodeErrorZ_is_ok(o_conv);
22555         return ret_conv;
22556 }
22557
22558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22559         if (!ptr_is_owned(_res)) return;
22560         void* _res_ptr = untag_ptr(_res);
22561         CHECK_ACCESS(_res_ptr);
22562         LDKCResult_COption_APIErrorZDecodeErrorZ _res_conv = *(LDKCResult_COption_APIErrorZDecodeErrorZ*)(_res_ptr);
22563         FREE(untag_ptr(_res));
22564         CResult_COption_APIErrorZDecodeErrorZ_free(_res_conv);
22565 }
22566
22567 static inline uint64_t CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR arg) {
22568         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22569         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(arg);
22570         return tag_ptr(ret_conv, true);
22571 }
22572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22573         LDKCResult_COption_APIErrorZDecodeErrorZ* arg_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(arg);
22574         int64_t ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(arg_conv);
22575         return ret_conv;
22576 }
22577
22578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1APIErrorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22579         LDKCResult_COption_APIErrorZDecodeErrorZ* orig_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(orig);
22580         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
22581         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(orig_conv);
22582         return tag_ptr(ret_conv, true);
22583 }
22584
22585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22586         LDKUntrustedString o_conv;
22587         o_conv.inner = untag_ptr(o);
22588         o_conv.is_owned = ptr_is_owned(o);
22589         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22590         o_conv = UntrustedString_clone(&o_conv);
22591         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22592         *ret_conv = CResult_UntrustedStringDecodeErrorZ_ok(o_conv);
22593         return tag_ptr(ret_conv, true);
22594 }
22595
22596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22597         void* e_ptr = untag_ptr(e);
22598         CHECK_ACCESS(e_ptr);
22599         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22600         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22601         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22602         *ret_conv = CResult_UntrustedStringDecodeErrorZ_err(e_conv);
22603         return tag_ptr(ret_conv, true);
22604 }
22605
22606 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22607         LDKCResult_UntrustedStringDecodeErrorZ* o_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(o);
22608         jboolean ret_conv = CResult_UntrustedStringDecodeErrorZ_is_ok(o_conv);
22609         return ret_conv;
22610 }
22611
22612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22613         if (!ptr_is_owned(_res)) return;
22614         void* _res_ptr = untag_ptr(_res);
22615         CHECK_ACCESS(_res_ptr);
22616         LDKCResult_UntrustedStringDecodeErrorZ _res_conv = *(LDKCResult_UntrustedStringDecodeErrorZ*)(_res_ptr);
22617         FREE(untag_ptr(_res));
22618         CResult_UntrustedStringDecodeErrorZ_free(_res_conv);
22619 }
22620
22621 static inline uint64_t CResult_UntrustedStringDecodeErrorZ_clone_ptr(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR arg) {
22622         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22623         *ret_conv = CResult_UntrustedStringDecodeErrorZ_clone(arg);
22624         return tag_ptr(ret_conv, true);
22625 }
22626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22627         LDKCResult_UntrustedStringDecodeErrorZ* arg_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(arg);
22628         int64_t ret_conv = CResult_UntrustedStringDecodeErrorZ_clone_ptr(arg_conv);
22629         return ret_conv;
22630 }
22631
22632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UntrustedStringDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22633         LDKCResult_UntrustedStringDecodeErrorZ* orig_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(orig);
22634         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
22635         *ret_conv = CResult_UntrustedStringDecodeErrorZ_clone(orig_conv);
22636         return tag_ptr(ret_conv, true);
22637 }
22638
22639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22640         LDKOutPoint o_conv;
22641         o_conv.inner = untag_ptr(o);
22642         o_conv.is_owned = ptr_is_owned(o);
22643         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22644         o_conv = OutPoint_clone(&o_conv);
22645         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22646         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
22647         return tag_ptr(ret_conv, true);
22648 }
22649
22650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22651         void* e_ptr = untag_ptr(e);
22652         CHECK_ACCESS(e_ptr);
22653         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22654         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22655         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22656         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
22657         return tag_ptr(ret_conv, true);
22658 }
22659
22660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22661         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
22662         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
22663         return ret_conv;
22664 }
22665
22666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22667         if (!ptr_is_owned(_res)) return;
22668         void* _res_ptr = untag_ptr(_res);
22669         CHECK_ACCESS(_res_ptr);
22670         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
22671         FREE(untag_ptr(_res));
22672         CResult_OutPointDecodeErrorZ_free(_res_conv);
22673 }
22674
22675 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
22676         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22677         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
22678         return tag_ptr(ret_conv, true);
22679 }
22680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22681         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
22682         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
22683         return ret_conv;
22684 }
22685
22686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22687         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
22688         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22689         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
22690         return tag_ptr(ret_conv, true);
22691 }
22692
22693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22694         void* o_ptr = untag_ptr(o);
22695         CHECK_ACCESS(o_ptr);
22696         LDKType o_conv = *(LDKType*)(o_ptr);
22697         if (o_conv.free == LDKType_JCalls_free) {
22698                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22699                 LDKType_JCalls_cloned(&o_conv);
22700         }
22701         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22702         *ret_copy = COption_TypeZ_some(o_conv);
22703         int64_t ret_ref = tag_ptr(ret_copy, true);
22704         return ret_ref;
22705 }
22706
22707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
22708         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22709         *ret_copy = COption_TypeZ_none();
22710         int64_t ret_ref = tag_ptr(ret_copy, true);
22711         return ret_ref;
22712 }
22713
22714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22715         if (!ptr_is_owned(_res)) return;
22716         void* _res_ptr = untag_ptr(_res);
22717         CHECK_ACCESS(_res_ptr);
22718         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
22719         FREE(untag_ptr(_res));
22720         COption_TypeZ_free(_res_conv);
22721 }
22722
22723 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
22724         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22725         *ret_copy = COption_TypeZ_clone(arg);
22726         int64_t ret_ref = tag_ptr(ret_copy, true);
22727         return ret_ref;
22728 }
22729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22730         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
22731         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
22732         return ret_conv;
22733 }
22734
22735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22736         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
22737         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22738         *ret_copy = COption_TypeZ_clone(orig_conv);
22739         int64_t ret_ref = tag_ptr(ret_copy, true);
22740         return ret_ref;
22741 }
22742
22743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22744         void* o_ptr = untag_ptr(o);
22745         CHECK_ACCESS(o_ptr);
22746         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
22747         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
22748         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22749         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
22750         return tag_ptr(ret_conv, true);
22751 }
22752
22753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22754         void* e_ptr = untag_ptr(e);
22755         CHECK_ACCESS(e_ptr);
22756         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22757         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22758         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22759         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
22760         return tag_ptr(ret_conv, true);
22761 }
22762
22763 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22764         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
22765         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
22766         return ret_conv;
22767 }
22768
22769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22770         if (!ptr_is_owned(_res)) return;
22771         void* _res_ptr = untag_ptr(_res);
22772         CHECK_ACCESS(_res_ptr);
22773         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
22774         FREE(untag_ptr(_res));
22775         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
22776 }
22777
22778 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
22779         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22780         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
22781         return tag_ptr(ret_conv, true);
22782 }
22783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22784         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
22785         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
22786         return ret_conv;
22787 }
22788
22789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22790         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
22791         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22792         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
22793         return tag_ptr(ret_conv, true);
22794 }
22795
22796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22797         LDKThirtyTwoBytes o_ref;
22798         CHECK((*env)->GetArrayLength(env, o) == 32);
22799         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
22800         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22801         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
22802         return tag_ptr(ret_conv, true);
22803 }
22804
22805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22806         void* e_ptr = untag_ptr(e);
22807         CHECK_ACCESS(e_ptr);
22808         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
22809         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
22810         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22811         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
22812         return tag_ptr(ret_conv, true);
22813 }
22814
22815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22816         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(o);
22817         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
22818         return ret_conv;
22819 }
22820
22821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22822         if (!ptr_is_owned(_res)) return;
22823         void* _res_ptr = untag_ptr(_res);
22824         CHECK_ACCESS(_res_ptr);
22825         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
22826         FREE(untag_ptr(_res));
22827         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
22828 }
22829
22830 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
22831         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22832         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
22833         return tag_ptr(ret_conv, true);
22834 }
22835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22836         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(arg);
22837         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
22838         return ret_conv;
22839 }
22840
22841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22842         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(orig);
22843         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
22844         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
22845         return tag_ptr(ret_conv, true);
22846 }
22847
22848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1ok(JNIEnv *env, jclass clz) {
22849         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22850         *ret_conv = CResult_NonePaymentErrorZ_ok();
22851         return tag_ptr(ret_conv, true);
22852 }
22853
22854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22855         void* e_ptr = untag_ptr(e);
22856         CHECK_ACCESS(e_ptr);
22857         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
22858         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
22859         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22860         *ret_conv = CResult_NonePaymentErrorZ_err(e_conv);
22861         return tag_ptr(ret_conv, true);
22862 }
22863
22864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22865         LDKCResult_NonePaymentErrorZ* o_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(o);
22866         jboolean ret_conv = CResult_NonePaymentErrorZ_is_ok(o_conv);
22867         return ret_conv;
22868 }
22869
22870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22871         if (!ptr_is_owned(_res)) return;
22872         void* _res_ptr = untag_ptr(_res);
22873         CHECK_ACCESS(_res_ptr);
22874         LDKCResult_NonePaymentErrorZ _res_conv = *(LDKCResult_NonePaymentErrorZ*)(_res_ptr);
22875         FREE(untag_ptr(_res));
22876         CResult_NonePaymentErrorZ_free(_res_conv);
22877 }
22878
22879 static inline uint64_t CResult_NonePaymentErrorZ_clone_ptr(LDKCResult_NonePaymentErrorZ *NONNULL_PTR arg) {
22880         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22881         *ret_conv = CResult_NonePaymentErrorZ_clone(arg);
22882         return tag_ptr(ret_conv, true);
22883 }
22884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22885         LDKCResult_NonePaymentErrorZ* arg_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(arg);
22886         int64_t ret_conv = CResult_NonePaymentErrorZ_clone_ptr(arg_conv);
22887         return ret_conv;
22888 }
22889
22890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22891         LDKCResult_NonePaymentErrorZ* orig_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(orig);
22892         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22893         *ret_conv = CResult_NonePaymentErrorZ_clone(orig_conv);
22894         return tag_ptr(ret_conv, true);
22895 }
22896
22897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
22898         LDKStr o_conv = java_to_owned_str(env, o);
22899         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22900         *ret_conv = CResult_StringErrorZ_ok(o_conv);
22901         return tag_ptr(ret_conv, true);
22902 }
22903
22904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
22905         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
22906         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22907         *ret_conv = CResult_StringErrorZ_err(e_conv);
22908         return tag_ptr(ret_conv, true);
22909 }
22910
22911 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22912         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)untag_ptr(o);
22913         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
22914         return ret_conv;
22915 }
22916
22917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22918         if (!ptr_is_owned(_res)) return;
22919         void* _res_ptr = untag_ptr(_res);
22920         CHECK_ACCESS(_res_ptr);
22921         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
22922         FREE(untag_ptr(_res));
22923         CResult_StringErrorZ_free(_res_conv);
22924 }
22925
22926 static inline uint64_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
22927         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22928         *ret_conv = CResult_StringErrorZ_clone(arg);
22929         return tag_ptr(ret_conv, true);
22930 }
22931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22932         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)untag_ptr(arg);
22933         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
22934         return ret_conv;
22935 }
22936
22937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22938         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)untag_ptr(orig);
22939         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22940         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
22941         return tag_ptr(ret_conv, true);
22942 }
22943
22944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22945         LDKChannelMonitorUpdate o_conv;
22946         o_conv.inner = untag_ptr(o);
22947         o_conv.is_owned = ptr_is_owned(o);
22948         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22949         o_conv = ChannelMonitorUpdate_clone(&o_conv);
22950         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22951         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
22952         return tag_ptr(ret_conv, true);
22953 }
22954
22955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22956         void* e_ptr = untag_ptr(e);
22957         CHECK_ACCESS(e_ptr);
22958         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22959         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22960         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22961         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
22962         return tag_ptr(ret_conv, true);
22963 }
22964
22965 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22966         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
22967         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
22968         return ret_conv;
22969 }
22970
22971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22972         if (!ptr_is_owned(_res)) return;
22973         void* _res_ptr = untag_ptr(_res);
22974         CHECK_ACCESS(_res_ptr);
22975         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
22976         FREE(untag_ptr(_res));
22977         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
22978 }
22979
22980 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
22981         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22982         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
22983         return tag_ptr(ret_conv, true);
22984 }
22985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22986         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
22987         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
22988         return ret_conv;
22989 }
22990
22991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22992         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
22993         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22994         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
22995         return tag_ptr(ret_conv, true);
22996 }
22997
22998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22999         void* o_ptr = untag_ptr(o);
23000         CHECK_ACCESS(o_ptr);
23001         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
23002         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
23003         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23004         *ret_copy = COption_MonitorEventZ_some(o_conv);
23005         int64_t ret_ref = tag_ptr(ret_copy, true);
23006         return ret_ref;
23007 }
23008
23009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
23010         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23011         *ret_copy = COption_MonitorEventZ_none();
23012         int64_t ret_ref = tag_ptr(ret_copy, true);
23013         return ret_ref;
23014 }
23015
23016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23017         if (!ptr_is_owned(_res)) return;
23018         void* _res_ptr = untag_ptr(_res);
23019         CHECK_ACCESS(_res_ptr);
23020         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
23021         FREE(untag_ptr(_res));
23022         COption_MonitorEventZ_free(_res_conv);
23023 }
23024
23025 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
23026         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23027         *ret_copy = COption_MonitorEventZ_clone(arg);
23028         int64_t ret_ref = tag_ptr(ret_copy, true);
23029         return ret_ref;
23030 }
23031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23032         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
23033         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
23034         return ret_conv;
23035 }
23036
23037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23038         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
23039         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
23040         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
23041         int64_t ret_ref = tag_ptr(ret_copy, true);
23042         return ret_ref;
23043 }
23044
23045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23046         void* o_ptr = untag_ptr(o);
23047         CHECK_ACCESS(o_ptr);
23048         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
23049         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
23050         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23051         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
23052         return tag_ptr(ret_conv, true);
23053 }
23054
23055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23056         void* e_ptr = untag_ptr(e);
23057         CHECK_ACCESS(e_ptr);
23058         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23059         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23060         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23061         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
23062         return tag_ptr(ret_conv, true);
23063 }
23064
23065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23066         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
23067         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
23068         return ret_conv;
23069 }
23070
23071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23072         if (!ptr_is_owned(_res)) return;
23073         void* _res_ptr = untag_ptr(_res);
23074         CHECK_ACCESS(_res_ptr);
23075         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
23076         FREE(untag_ptr(_res));
23077         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
23078 }
23079
23080 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
23081         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23082         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
23083         return tag_ptr(ret_conv, true);
23084 }
23085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23086         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
23087         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
23088         return ret_conv;
23089 }
23090
23091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23092         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
23093         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23094         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
23095         return tag_ptr(ret_conv, true);
23096 }
23097
23098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23099         LDKHTLCUpdate o_conv;
23100         o_conv.inner = untag_ptr(o);
23101         o_conv.is_owned = ptr_is_owned(o);
23102         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23103         o_conv = HTLCUpdate_clone(&o_conv);
23104         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23105         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
23106         return tag_ptr(ret_conv, true);
23107 }
23108
23109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23110         void* e_ptr = untag_ptr(e);
23111         CHECK_ACCESS(e_ptr);
23112         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23113         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23114         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23115         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
23116         return tag_ptr(ret_conv, true);
23117 }
23118
23119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23120         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
23121         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
23122         return ret_conv;
23123 }
23124
23125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23126         if (!ptr_is_owned(_res)) return;
23127         void* _res_ptr = untag_ptr(_res);
23128         CHECK_ACCESS(_res_ptr);
23129         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
23130         FREE(untag_ptr(_res));
23131         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
23132 }
23133
23134 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
23135         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23136         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
23137         return tag_ptr(ret_conv, true);
23138 }
23139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23140         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
23141         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
23142         return ret_conv;
23143 }
23144
23145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23146         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
23147         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23148         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
23149         return tag_ptr(ret_conv, true);
23150 }
23151
23152 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
23153         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23154         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
23155         return tag_ptr(ret_conv, true);
23156 }
23157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23158         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(arg);
23159         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
23160         return ret_conv;
23161 }
23162
23163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23164         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(orig);
23165         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23166         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
23167         return tag_ptr(ret_conv, true);
23168 }
23169
23170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
23171         LDKOutPoint a_conv;
23172         a_conv.inner = untag_ptr(a);
23173         a_conv.is_owned = ptr_is_owned(a);
23174         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23175         a_conv = OutPoint_clone(&a_conv);
23176         LDKCVec_u8Z b_ref;
23177         b_ref.datalen = (*env)->GetArrayLength(env, b);
23178         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
23179         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
23180         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23181         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
23182         return tag_ptr(ret_conv, true);
23183 }
23184
23185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23186         if (!ptr_is_owned(_res)) return;
23187         void* _res_ptr = untag_ptr(_res);
23188         CHECK_ACCESS(_res_ptr);
23189         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
23190         FREE(untag_ptr(_res));
23191         C2Tuple_OutPointScriptZ_free(_res_conv);
23192 }
23193
23194 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
23195         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
23196         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
23197         return tag_ptr(ret_conv, true);
23198 }
23199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23200         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(arg);
23201         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
23202         return ret_conv;
23203 }
23204
23205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23206         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(orig);
23207         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
23208         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
23209         return tag_ptr(ret_conv, true);
23210 }
23211
23212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
23213         LDKCVec_u8Z b_ref;
23214         b_ref.datalen = (*env)->GetArrayLength(env, b);
23215         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
23216         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
23217         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
23218         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
23219         return tag_ptr(ret_conv, true);
23220 }
23221
23222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23223         if (!ptr_is_owned(_res)) return;
23224         void* _res_ptr = untag_ptr(_res);
23225         CHECK_ACCESS(_res_ptr);
23226         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
23227         FREE(untag_ptr(_res));
23228         C2Tuple_u32ScriptZ_free(_res_conv);
23229 }
23230
23231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23232         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
23233         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23234         if (_res_constr.datalen > 0)
23235                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
23236         else
23237                 _res_constr.data = NULL;
23238         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23239         for (size_t v = 0; v < _res_constr.datalen; v++) {
23240                 int64_t _res_conv_21 = _res_vals[v];
23241                 void* _res_conv_21_ptr = untag_ptr(_res_conv_21);
23242                 CHECK_ACCESS(_res_conv_21_ptr);
23243                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
23244                 FREE(untag_ptr(_res_conv_21));
23245                 _res_constr.data[v] = _res_conv_21_conv;
23246         }
23247         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23248         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
23249 }
23250
23251 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
23252         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23253         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
23254         return tag_ptr(ret_conv, true);
23255 }
23256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23257         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(arg);
23258         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
23259         return ret_conv;
23260 }
23261
23262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23263         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(orig);
23264         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23265         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
23266         return tag_ptr(ret_conv, true);
23267 }
23268
23269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
23270         LDKThirtyTwoBytes a_ref;
23271         CHECK((*env)->GetArrayLength(env, a) == 32);
23272         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23273         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
23274         b_constr.datalen = (*env)->GetArrayLength(env, b);
23275         if (b_constr.datalen > 0)
23276                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
23277         else
23278                 b_constr.data = NULL;
23279         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
23280         for (size_t v = 0; v < b_constr.datalen; v++) {
23281                 int64_t b_conv_21 = b_vals[v];
23282                 void* b_conv_21_ptr = untag_ptr(b_conv_21);
23283                 CHECK_ACCESS(b_conv_21_ptr);
23284                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
23285                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)untag_ptr(b_conv_21));
23286                 b_constr.data[v] = b_conv_21_conv;
23287         }
23288         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
23289         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23290         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
23291         return tag_ptr(ret_conv, true);
23292 }
23293
23294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23295         if (!ptr_is_owned(_res)) return;
23296         void* _res_ptr = untag_ptr(_res);
23297         CHECK_ACCESS(_res_ptr);
23298         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
23299         FREE(untag_ptr(_res));
23300         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
23301 }
23302
23303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23304         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
23305         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23306         if (_res_constr.datalen > 0)
23307                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
23308         else
23309                 _res_constr.data = NULL;
23310         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23311         for (size_t o = 0; o < _res_constr.datalen; o++) {
23312                 int64_t _res_conv_40 = _res_vals[o];
23313                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
23314                 CHECK_ACCESS(_res_conv_40_ptr);
23315                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
23316                 FREE(untag_ptr(_res_conv_40));
23317                 _res_constr.data[o] = _res_conv_40_conv;
23318         }
23319         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23320         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
23321 }
23322
23323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23324         LDKCVec_EventZ _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(LDKEvent), "LDKCVec_EventZ Elements");
23328         else
23329                 _res_constr.data = NULL;
23330         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23331         for (size_t h = 0; h < _res_constr.datalen; h++) {
23332                 int64_t _res_conv_7 = _res_vals[h];
23333                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
23334                 CHECK_ACCESS(_res_conv_7_ptr);
23335                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
23336                 FREE(untag_ptr(_res_conv_7));
23337                 _res_constr.data[h] = _res_conv_7_conv;
23338         }
23339         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23340         CVec_EventZ_free(_res_constr);
23341 }
23342
23343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
23344         LDKCVec_TransactionZ _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(LDKTransaction), "LDKCVec_TransactionZ Elements");
23348         else
23349                 _res_constr.data = NULL;
23350         for (size_t i = 0; i < _res_constr.datalen; i++) {
23351                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
23352                 LDKTransaction _res_conv_8_ref;
23353                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
23354                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
23355                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
23356                 _res_conv_8_ref.data_is_owned = true;
23357                 _res_constr.data[i] = _res_conv_8_ref;
23358         }
23359         CVec_TransactionZ_free(_res_constr);
23360 }
23361
23362 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
23363         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
23364         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
23365         return tag_ptr(ret_conv, true);
23366 }
23367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23368         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
23369         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
23370         return ret_conv;
23371 }
23372
23373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23374         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
23375         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
23376         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
23377         return tag_ptr(ret_conv, true);
23378 }
23379
23380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
23381         void* b_ptr = untag_ptr(b);
23382         CHECK_ACCESS(b_ptr);
23383         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
23384         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
23385         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
23386         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
23387         return tag_ptr(ret_conv, true);
23388 }
23389
23390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23391         if (!ptr_is_owned(_res)) return;
23392         void* _res_ptr = untag_ptr(_res);
23393         CHECK_ACCESS(_res_ptr);
23394         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
23395         FREE(untag_ptr(_res));
23396         C2Tuple_u32TxOutZ_free(_res_conv);
23397 }
23398
23399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23400         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
23401         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23402         if (_res_constr.datalen > 0)
23403                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
23404         else
23405                 _res_constr.data = NULL;
23406         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23407         for (size_t u = 0; u < _res_constr.datalen; u++) {
23408                 int64_t _res_conv_20 = _res_vals[u];
23409                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
23410                 CHECK_ACCESS(_res_conv_20_ptr);
23411                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
23412                 FREE(untag_ptr(_res_conv_20));
23413                 _res_constr.data[u] = _res_conv_20_conv;
23414         }
23415         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23416         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
23417 }
23418
23419 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
23420         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23421         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
23422         return tag_ptr(ret_conv, true);
23423 }
23424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23425         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
23426         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
23427         return ret_conv;
23428 }
23429
23430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23431         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
23432         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23433         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
23434         return tag_ptr(ret_conv, true);
23435 }
23436
23437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
23438         LDKThirtyTwoBytes a_ref;
23439         CHECK((*env)->GetArrayLength(env, a) == 32);
23440         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23441         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
23442         b_constr.datalen = (*env)->GetArrayLength(env, b);
23443         if (b_constr.datalen > 0)
23444                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
23445         else
23446                 b_constr.data = NULL;
23447         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
23448         for (size_t u = 0; u < b_constr.datalen; u++) {
23449                 int64_t b_conv_20 = b_vals[u];
23450                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
23451                 CHECK_ACCESS(b_conv_20_ptr);
23452                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
23453                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
23454                 b_constr.data[u] = b_conv_20_conv;
23455         }
23456         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
23457         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23458         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
23459         return tag_ptr(ret_conv, true);
23460 }
23461
23462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23463         if (!ptr_is_owned(_res)) return;
23464         void* _res_ptr = untag_ptr(_res);
23465         CHECK_ACCESS(_res_ptr);
23466         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
23467         FREE(untag_ptr(_res));
23468         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
23469 }
23470
23471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23472         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
23473         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23474         if (_res_constr.datalen > 0)
23475                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
23476         else
23477                 _res_constr.data = NULL;
23478         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23479         for (size_t n = 0; n < _res_constr.datalen; n++) {
23480                 int64_t _res_conv_39 = _res_vals[n];
23481                 void* _res_conv_39_ptr = untag_ptr(_res_conv_39);
23482                 CHECK_ACCESS(_res_conv_39_ptr);
23483                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
23484                 FREE(untag_ptr(_res_conv_39));
23485                 _res_constr.data[n] = _res_conv_39_conv;
23486         }
23487         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23488         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
23489 }
23490
23491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23492         LDKCVec_BalanceZ _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(LDKBalance), "LDKCVec_BalanceZ Elements");
23496         else
23497                 _res_constr.data = NULL;
23498         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23499         for (size_t j = 0; j < _res_constr.datalen; j++) {
23500                 int64_t _res_conv_9 = _res_vals[j];
23501                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
23502                 CHECK_ACCESS(_res_conv_9_ptr);
23503                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
23504                 FREE(untag_ptr(_res_conv_9));
23505                 _res_constr.data[j] = _res_conv_9_conv;
23506         }
23507         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23508         CVec_BalanceZ_free(_res_constr);
23509 }
23510
23511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23512         void* o_ptr = untag_ptr(o);
23513         CHECK_ACCESS(o_ptr);
23514         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
23515         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o));
23516         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23517         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
23518         return tag_ptr(ret_conv, true);
23519 }
23520
23521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23522         void* e_ptr = untag_ptr(e);
23523         CHECK_ACCESS(e_ptr);
23524         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23525         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23526         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23527         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
23528         return tag_ptr(ret_conv, true);
23529 }
23530
23531 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23532         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(o);
23533         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
23534         return ret_conv;
23535 }
23536
23537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23538         if (!ptr_is_owned(_res)) return;
23539         void* _res_ptr = untag_ptr(_res);
23540         CHECK_ACCESS(_res_ptr);
23541         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
23542         FREE(untag_ptr(_res));
23543         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
23544 }
23545
23546 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
23547         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23548         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
23549         return tag_ptr(ret_conv, true);
23550 }
23551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23552         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
23553         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
23554         return ret_conv;
23555 }
23556
23557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23558         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
23559         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23560         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
23561         return tag_ptr(ret_conv, true);
23562 }
23563
23564 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
23565         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
23566         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
23567         return tag_ptr(ret_conv, true);
23568 }
23569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23570         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
23571         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
23572         return ret_conv;
23573 }
23574
23575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23576         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
23577         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
23578         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
23579         return tag_ptr(ret_conv, true);
23580 }
23581
23582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
23583         LDKPublicKey a_ref;
23584         CHECK((*env)->GetArrayLength(env, a) == 33);
23585         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
23586         void* b_ptr = untag_ptr(b);
23587         CHECK_ACCESS(b_ptr);
23588         LDKType b_conv = *(LDKType*)(b_ptr);
23589         if (b_conv.free == LDKType_JCalls_free) {
23590                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23591                 LDKType_JCalls_cloned(&b_conv);
23592         }
23593         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
23594         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
23595         return tag_ptr(ret_conv, true);
23596 }
23597
23598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23599         if (!ptr_is_owned(_res)) return;
23600         void* _res_ptr = untag_ptr(_res);
23601         CHECK_ACCESS(_res_ptr);
23602         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
23603         FREE(untag_ptr(_res));
23604         C2Tuple_PublicKeyTypeZ_free(_res_conv);
23605 }
23606
23607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23608         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
23609         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23610         if (_res_constr.datalen > 0)
23611                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
23612         else
23613                 _res_constr.data = NULL;
23614         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23615         for (size_t z = 0; z < _res_constr.datalen; z++) {
23616                 int64_t _res_conv_25 = _res_vals[z];
23617                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
23618                 CHECK_ACCESS(_res_conv_25_ptr);
23619                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
23620                 FREE(untag_ptr(_res_conv_25));
23621                 _res_constr.data[z] = _res_conv_25_conv;
23622         }
23623         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23624         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
23625 }
23626
23627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23628         void* o_ptr = untag_ptr(o);
23629         CHECK_ACCESS(o_ptr);
23630         LDKCustomOnionMessageContents o_conv = *(LDKCustomOnionMessageContents*)(o_ptr);
23631         if (o_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
23632                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23633                 LDKCustomOnionMessageContents_JCalls_cloned(&o_conv);
23634         }
23635         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23636         *ret_copy = COption_CustomOnionMessageContentsZ_some(o_conv);
23637         int64_t ret_ref = tag_ptr(ret_copy, true);
23638         return ret_ref;
23639 }
23640
23641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1none(JNIEnv *env, jclass clz) {
23642         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23643         *ret_copy = COption_CustomOnionMessageContentsZ_none();
23644         int64_t ret_ref = tag_ptr(ret_copy, true);
23645         return ret_ref;
23646 }
23647
23648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23649         if (!ptr_is_owned(_res)) return;
23650         void* _res_ptr = untag_ptr(_res);
23651         CHECK_ACCESS(_res_ptr);
23652         LDKCOption_CustomOnionMessageContentsZ _res_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(_res_ptr);
23653         FREE(untag_ptr(_res));
23654         COption_CustomOnionMessageContentsZ_free(_res_conv);
23655 }
23656
23657 static inline uint64_t COption_CustomOnionMessageContentsZ_clone_ptr(LDKCOption_CustomOnionMessageContentsZ *NONNULL_PTR arg) {
23658         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23659         *ret_copy = COption_CustomOnionMessageContentsZ_clone(arg);
23660         int64_t ret_ref = tag_ptr(ret_copy, true);
23661         return ret_ref;
23662 }
23663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23664         LDKCOption_CustomOnionMessageContentsZ* arg_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(arg);
23665         int64_t ret_conv = COption_CustomOnionMessageContentsZ_clone_ptr(arg_conv);
23666         return ret_conv;
23667 }
23668
23669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23670         LDKCOption_CustomOnionMessageContentsZ* orig_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(orig);
23671         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
23672         *ret_copy = COption_CustomOnionMessageContentsZ_clone(orig_conv);
23673         int64_t ret_ref = tag_ptr(ret_copy, true);
23674         return ret_ref;
23675 }
23676
23677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23678         void* o_ptr = untag_ptr(o);
23679         CHECK_ACCESS(o_ptr);
23680         LDKCOption_CustomOnionMessageContentsZ o_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(o_ptr);
23681         o_conv = COption_CustomOnionMessageContentsZ_clone((LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(o));
23682         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23683         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(o_conv);
23684         return tag_ptr(ret_conv, true);
23685 }
23686
23687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23688         void* e_ptr = untag_ptr(e);
23689         CHECK_ACCESS(e_ptr);
23690         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23691         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23692         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23693         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e_conv);
23694         return tag_ptr(ret_conv, true);
23695 }
23696
23697 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23698         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* o_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(o);
23699         jboolean ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(o_conv);
23700         return ret_conv;
23701 }
23702
23703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23704         if (!ptr_is_owned(_res)) return;
23705         void* _res_ptr = untag_ptr(_res);
23706         CHECK_ACCESS(_res_ptr);
23707         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ _res_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(_res_ptr);
23708         FREE(untag_ptr(_res));
23709         CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(_res_conv);
23710 }
23711
23712 static inline uint64_t CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR arg) {
23713         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23714         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(arg);
23715         return tag_ptr(ret_conv, true);
23716 }
23717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23718         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* arg_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(arg);
23719         int64_t ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(arg_conv);
23720         return ret_conv;
23721 }
23722
23723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23724         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* orig_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(orig);
23725         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
23726         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(orig_conv);
23727         return tag_ptr(ret_conv, true);
23728 }
23729
23730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23731         void* o_ptr = untag_ptr(o);
23732         CHECK_ACCESS(o_ptr);
23733         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
23734         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
23735         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23736         *ret_copy = COption_NetAddressZ_some(o_conv);
23737         int64_t ret_ref = tag_ptr(ret_copy, true);
23738         return ret_ref;
23739 }
23740
23741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
23742         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23743         *ret_copy = COption_NetAddressZ_none();
23744         int64_t ret_ref = tag_ptr(ret_copy, true);
23745         return ret_ref;
23746 }
23747
23748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23749         if (!ptr_is_owned(_res)) return;
23750         void* _res_ptr = untag_ptr(_res);
23751         CHECK_ACCESS(_res_ptr);
23752         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
23753         FREE(untag_ptr(_res));
23754         COption_NetAddressZ_free(_res_conv);
23755 }
23756
23757 static inline uint64_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
23758         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23759         *ret_copy = COption_NetAddressZ_clone(arg);
23760         int64_t ret_ref = tag_ptr(ret_copy, true);
23761         return ret_ref;
23762 }
23763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23764         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)untag_ptr(arg);
23765         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
23766         return ret_conv;
23767 }
23768
23769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23770         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)untag_ptr(orig);
23771         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
23772         *ret_copy = COption_NetAddressZ_clone(orig_conv);
23773         int64_t ret_ref = tag_ptr(ret_copy, true);
23774         return ret_ref;
23775 }
23776
23777 static inline uint64_t C2Tuple_PublicKeyCOption_NetAddressZZ_clone_ptr(LDKC2Tuple_PublicKeyCOption_NetAddressZZ *NONNULL_PTR arg) {
23778         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23779         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone(arg);
23780         return tag_ptr(ret_conv, true);
23781 }
23782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23783         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* arg_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(arg);
23784         int64_t ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone_ptr(arg_conv);
23785         return ret_conv;
23786 }
23787
23788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23789         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* orig_conv = (LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)untag_ptr(orig);
23790         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23791         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_clone(orig_conv);
23792         return tag_ptr(ret_conv, true);
23793 }
23794
23795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
23796         LDKPublicKey a_ref;
23797         CHECK((*env)->GetArrayLength(env, a) == 33);
23798         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
23799         void* b_ptr = untag_ptr(b);
23800         CHECK_ACCESS(b_ptr);
23801         LDKCOption_NetAddressZ b_conv = *(LDKCOption_NetAddressZ*)(b_ptr);
23802         b_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(b));
23803         LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
23804         *ret_conv = C2Tuple_PublicKeyCOption_NetAddressZZ_new(a_ref, b_conv);
23805         return tag_ptr(ret_conv, true);
23806 }
23807
23808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyCOption_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23809         if (!ptr_is_owned(_res)) return;
23810         void* _res_ptr = untag_ptr(_res);
23811         CHECK_ACCESS(_res_ptr);
23812         LDKC2Tuple_PublicKeyCOption_NetAddressZZ _res_conv = *(LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)(_res_ptr);
23813         FREE(untag_ptr(_res));
23814         C2Tuple_PublicKeyCOption_NetAddressZZ_free(_res_conv);
23815 }
23816
23817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyCOption_1NetAddressZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23818         LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ _res_constr;
23819         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23820         if (_res_constr.datalen > 0)
23821                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ Elements");
23822         else
23823                 _res_constr.data = NULL;
23824         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23825         for (size_t o = 0; o < _res_constr.datalen; o++) {
23826                 int64_t _res_conv_40 = _res_vals[o];
23827                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
23828                 CHECK_ACCESS(_res_conv_40_ptr);
23829                 LDKC2Tuple_PublicKeyCOption_NetAddressZZ _res_conv_40_conv = *(LDKC2Tuple_PublicKeyCOption_NetAddressZZ*)(_res_conv_40_ptr);
23830                 FREE(untag_ptr(_res_conv_40));
23831                 _res_constr.data[o] = _res_conv_40_conv;
23832         }
23833         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23834         CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ_free(_res_constr);
23835 }
23836
23837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
23838         LDKCVec_u8Z o_ref;
23839         o_ref.datalen = (*env)->GetArrayLength(env, o);
23840         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
23841         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
23842         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23843         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
23844         return tag_ptr(ret_conv, true);
23845 }
23846
23847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23848         LDKPeerHandleError e_conv;
23849         e_conv.inner = untag_ptr(e);
23850         e_conv.is_owned = ptr_is_owned(e);
23851         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23852         e_conv = PeerHandleError_clone(&e_conv);
23853         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23854         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
23855         return tag_ptr(ret_conv, true);
23856 }
23857
23858 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23859         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
23860         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
23861         return ret_conv;
23862 }
23863
23864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23865         if (!ptr_is_owned(_res)) return;
23866         void* _res_ptr = untag_ptr(_res);
23867         CHECK_ACCESS(_res_ptr);
23868         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
23869         FREE(untag_ptr(_res));
23870         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
23871 }
23872
23873 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
23874         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23875         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
23876         return tag_ptr(ret_conv, true);
23877 }
23878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23879         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
23880         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
23881         return ret_conv;
23882 }
23883
23884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23885         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
23886         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23887         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
23888         return tag_ptr(ret_conv, true);
23889 }
23890
23891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
23892         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23893         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
23894         return tag_ptr(ret_conv, true);
23895 }
23896
23897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23898         LDKPeerHandleError e_conv;
23899         e_conv.inner = untag_ptr(e);
23900         e_conv.is_owned = ptr_is_owned(e);
23901         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23902         e_conv = PeerHandleError_clone(&e_conv);
23903         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23904         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
23905         return tag_ptr(ret_conv, true);
23906 }
23907
23908 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23909         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
23910         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
23911         return ret_conv;
23912 }
23913
23914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23915         if (!ptr_is_owned(_res)) return;
23916         void* _res_ptr = untag_ptr(_res);
23917         CHECK_ACCESS(_res_ptr);
23918         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
23919         FREE(untag_ptr(_res));
23920         CResult_NonePeerHandleErrorZ_free(_res_conv);
23921 }
23922
23923 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
23924         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23925         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
23926         return tag_ptr(ret_conv, true);
23927 }
23928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23929         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
23930         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
23931         return ret_conv;
23932 }
23933
23934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23935         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
23936         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23937         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
23938         return tag_ptr(ret_conv, true);
23939 }
23940
23941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
23942         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23943         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
23944         return tag_ptr(ret_conv, true);
23945 }
23946
23947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23948         LDKPeerHandleError e_conv;
23949         e_conv.inner = untag_ptr(e);
23950         e_conv.is_owned = ptr_is_owned(e);
23951         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23952         e_conv = PeerHandleError_clone(&e_conv);
23953         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23954         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
23955         return tag_ptr(ret_conv, true);
23956 }
23957
23958 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23959         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
23960         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
23961         return ret_conv;
23962 }
23963
23964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23965         if (!ptr_is_owned(_res)) return;
23966         void* _res_ptr = untag_ptr(_res);
23967         CHECK_ACCESS(_res_ptr);
23968         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
23969         FREE(untag_ptr(_res));
23970         CResult_boolPeerHandleErrorZ_free(_res_conv);
23971 }
23972
23973 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
23974         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23975         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
23976         return tag_ptr(ret_conv, true);
23977 }
23978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23979         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
23980         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
23981         return ret_conv;
23982 }
23983
23984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23985         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
23986         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23987         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
23988         return tag_ptr(ret_conv, true);
23989 }
23990
23991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23992         void* o_ptr = untag_ptr(o);
23993         CHECK_ACCESS(o_ptr);
23994         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
23995         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
23996         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
23997         *ret_conv = CResult_TxOutUtxoLookupErrorZ_ok(o_conv);
23998         return tag_ptr(ret_conv, true);
23999 }
24000
24001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24002         LDKUtxoLookupError e_conv = LDKUtxoLookupError_from_java(env, e);
24003         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24004         *ret_conv = CResult_TxOutUtxoLookupErrorZ_err(e_conv);
24005         return tag_ptr(ret_conv, true);
24006 }
24007
24008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24009         LDKCResult_TxOutUtxoLookupErrorZ* o_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(o);
24010         jboolean ret_conv = CResult_TxOutUtxoLookupErrorZ_is_ok(o_conv);
24011         return ret_conv;
24012 }
24013
24014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24015         if (!ptr_is_owned(_res)) return;
24016         void* _res_ptr = untag_ptr(_res);
24017         CHECK_ACCESS(_res_ptr);
24018         LDKCResult_TxOutUtxoLookupErrorZ _res_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(_res_ptr);
24019         FREE(untag_ptr(_res));
24020         CResult_TxOutUtxoLookupErrorZ_free(_res_conv);
24021 }
24022
24023 static inline uint64_t CResult_TxOutUtxoLookupErrorZ_clone_ptr(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR arg) {
24024         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24025         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(arg);
24026         return tag_ptr(ret_conv, true);
24027 }
24028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24029         LDKCResult_TxOutUtxoLookupErrorZ* arg_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(arg);
24030         int64_t ret_conv = CResult_TxOutUtxoLookupErrorZ_clone_ptr(arg_conv);
24031         return ret_conv;
24032 }
24033
24034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutUtxoLookupErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24035         LDKCResult_TxOutUtxoLookupErrorZ* orig_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(orig);
24036         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
24037         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(orig_conv);
24038         return tag_ptr(ret_conv, true);
24039 }
24040
24041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1ok(JNIEnv *env, jclass clz) {
24042         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
24043         *ret_conv = CResult_NoneSendErrorZ_ok();
24044         return tag_ptr(ret_conv, true);
24045 }
24046
24047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24048         void* e_ptr = untag_ptr(e);
24049         CHECK_ACCESS(e_ptr);
24050         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
24051         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
24052         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
24053         *ret_conv = CResult_NoneSendErrorZ_err(e_conv);
24054         return tag_ptr(ret_conv, true);
24055 }
24056
24057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24058         LDKCResult_NoneSendErrorZ* o_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(o);
24059         jboolean ret_conv = CResult_NoneSendErrorZ_is_ok(o_conv);
24060         return ret_conv;
24061 }
24062
24063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24064         if (!ptr_is_owned(_res)) return;
24065         void* _res_ptr = untag_ptr(_res);
24066         CHECK_ACCESS(_res_ptr);
24067         LDKCResult_NoneSendErrorZ _res_conv = *(LDKCResult_NoneSendErrorZ*)(_res_ptr);
24068         FREE(untag_ptr(_res));
24069         CResult_NoneSendErrorZ_free(_res_conv);
24070 }
24071
24072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24073         LDKBlindedPath o_conv;
24074         o_conv.inner = untag_ptr(o);
24075         o_conv.is_owned = ptr_is_owned(o);
24076         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24077         o_conv = BlindedPath_clone(&o_conv);
24078         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24079         *ret_conv = CResult_BlindedPathNoneZ_ok(o_conv);
24080         return tag_ptr(ret_conv, true);
24081 }
24082
24083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1err(JNIEnv *env, jclass clz) {
24084         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24085         *ret_conv = CResult_BlindedPathNoneZ_err();
24086         return tag_ptr(ret_conv, true);
24087 }
24088
24089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24090         LDKCResult_BlindedPathNoneZ* o_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(o);
24091         jboolean ret_conv = CResult_BlindedPathNoneZ_is_ok(o_conv);
24092         return ret_conv;
24093 }
24094
24095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24096         if (!ptr_is_owned(_res)) return;
24097         void* _res_ptr = untag_ptr(_res);
24098         CHECK_ACCESS(_res_ptr);
24099         LDKCResult_BlindedPathNoneZ _res_conv = *(LDKCResult_BlindedPathNoneZ*)(_res_ptr);
24100         FREE(untag_ptr(_res));
24101         CResult_BlindedPathNoneZ_free(_res_conv);
24102 }
24103
24104 static inline uint64_t CResult_BlindedPathNoneZ_clone_ptr(LDKCResult_BlindedPathNoneZ *NONNULL_PTR arg) {
24105         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24106         *ret_conv = CResult_BlindedPathNoneZ_clone(arg);
24107         return tag_ptr(ret_conv, true);
24108 }
24109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24110         LDKCResult_BlindedPathNoneZ* arg_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(arg);
24111         int64_t ret_conv = CResult_BlindedPathNoneZ_clone_ptr(arg_conv);
24112         return ret_conv;
24113 }
24114
24115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24116         LDKCResult_BlindedPathNoneZ* orig_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(orig);
24117         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
24118         *ret_conv = CResult_BlindedPathNoneZ_clone(orig_conv);
24119         return tag_ptr(ret_conv, true);
24120 }
24121
24122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24123         LDKBlindedPath o_conv;
24124         o_conv.inner = untag_ptr(o);
24125         o_conv.is_owned = ptr_is_owned(o);
24126         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24127         o_conv = BlindedPath_clone(&o_conv);
24128         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24129         *ret_conv = CResult_BlindedPathDecodeErrorZ_ok(o_conv);
24130         return tag_ptr(ret_conv, true);
24131 }
24132
24133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24134         void* e_ptr = untag_ptr(e);
24135         CHECK_ACCESS(e_ptr);
24136         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24137         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24138         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24139         *ret_conv = CResult_BlindedPathDecodeErrorZ_err(e_conv);
24140         return tag_ptr(ret_conv, true);
24141 }
24142
24143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24144         LDKCResult_BlindedPathDecodeErrorZ* o_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(o);
24145         jboolean ret_conv = CResult_BlindedPathDecodeErrorZ_is_ok(o_conv);
24146         return ret_conv;
24147 }
24148
24149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24150         if (!ptr_is_owned(_res)) return;
24151         void* _res_ptr = untag_ptr(_res);
24152         CHECK_ACCESS(_res_ptr);
24153         LDKCResult_BlindedPathDecodeErrorZ _res_conv = *(LDKCResult_BlindedPathDecodeErrorZ*)(_res_ptr);
24154         FREE(untag_ptr(_res));
24155         CResult_BlindedPathDecodeErrorZ_free(_res_conv);
24156 }
24157
24158 static inline uint64_t CResult_BlindedPathDecodeErrorZ_clone_ptr(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR arg) {
24159         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24160         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(arg);
24161         return tag_ptr(ret_conv, true);
24162 }
24163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24164         LDKCResult_BlindedPathDecodeErrorZ* arg_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(arg);
24165         int64_t ret_conv = CResult_BlindedPathDecodeErrorZ_clone_ptr(arg_conv);
24166         return ret_conv;
24167 }
24168
24169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24170         LDKCResult_BlindedPathDecodeErrorZ* orig_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(orig);
24171         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
24172         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(orig_conv);
24173         return tag_ptr(ret_conv, true);
24174 }
24175
24176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24177         LDKBlindedHop o_conv;
24178         o_conv.inner = untag_ptr(o);
24179         o_conv.is_owned = ptr_is_owned(o);
24180         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24181         o_conv = BlindedHop_clone(&o_conv);
24182         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24183         *ret_conv = CResult_BlindedHopDecodeErrorZ_ok(o_conv);
24184         return tag_ptr(ret_conv, true);
24185 }
24186
24187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24188         void* e_ptr = untag_ptr(e);
24189         CHECK_ACCESS(e_ptr);
24190         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24191         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24192         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24193         *ret_conv = CResult_BlindedHopDecodeErrorZ_err(e_conv);
24194         return tag_ptr(ret_conv, true);
24195 }
24196
24197 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24198         LDKCResult_BlindedHopDecodeErrorZ* o_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(o);
24199         jboolean ret_conv = CResult_BlindedHopDecodeErrorZ_is_ok(o_conv);
24200         return ret_conv;
24201 }
24202
24203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24204         if (!ptr_is_owned(_res)) return;
24205         void* _res_ptr = untag_ptr(_res);
24206         CHECK_ACCESS(_res_ptr);
24207         LDKCResult_BlindedHopDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopDecodeErrorZ*)(_res_ptr);
24208         FREE(untag_ptr(_res));
24209         CResult_BlindedHopDecodeErrorZ_free(_res_conv);
24210 }
24211
24212 static inline uint64_t CResult_BlindedHopDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR arg) {
24213         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24214         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(arg);
24215         return tag_ptr(ret_conv, true);
24216 }
24217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24218         LDKCResult_BlindedHopDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(arg);
24219         int64_t ret_conv = CResult_BlindedHopDecodeErrorZ_clone_ptr(arg_conv);
24220         return ret_conv;
24221 }
24222
24223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24224         LDKCResult_BlindedHopDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(orig);
24225         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
24226         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(orig_conv);
24227         return tag_ptr(ret_conv, true);
24228 }
24229
24230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
24231         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
24232         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24233         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
24234         return tag_ptr(ret_conv, true);
24235 }
24236
24237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24238         void* e_ptr = untag_ptr(e);
24239         CHECK_ACCESS(e_ptr);
24240         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
24241         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
24242         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24243         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
24244         return tag_ptr(ret_conv, true);
24245 }
24246
24247 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24248         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(o);
24249         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
24250         return ret_conv;
24251 }
24252
24253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24254         if (!ptr_is_owned(_res)) return;
24255         void* _res_ptr = untag_ptr(_res);
24256         CHECK_ACCESS(_res_ptr);
24257         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
24258         FREE(untag_ptr(_res));
24259         CResult_SiPrefixParseErrorZ_free(_res_conv);
24260 }
24261
24262 static inline uint64_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
24263         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24264         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
24265         return tag_ptr(ret_conv, true);
24266 }
24267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24268         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(arg);
24269         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
24270         return ret_conv;
24271 }
24272
24273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24274         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(orig);
24275         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
24276         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
24277         return tag_ptr(ret_conv, true);
24278 }
24279
24280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24281         LDKInvoice o_conv;
24282         o_conv.inner = untag_ptr(o);
24283         o_conv.is_owned = ptr_is_owned(o);
24284         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24285         o_conv = Invoice_clone(&o_conv);
24286         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24287         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
24288         return tag_ptr(ret_conv, true);
24289 }
24290
24291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24292         void* e_ptr = untag_ptr(e);
24293         CHECK_ACCESS(e_ptr);
24294         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
24295         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
24296         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24297         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
24298         return tag_ptr(ret_conv, true);
24299 }
24300
24301 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24302         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
24303         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
24304         return ret_conv;
24305 }
24306
24307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24308         if (!ptr_is_owned(_res)) return;
24309         void* _res_ptr = untag_ptr(_res);
24310         CHECK_ACCESS(_res_ptr);
24311         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
24312         FREE(untag_ptr(_res));
24313         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
24314 }
24315
24316 static inline uint64_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
24317         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24318         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
24319         return tag_ptr(ret_conv, true);
24320 }
24321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24322         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
24323         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
24324         return ret_conv;
24325 }
24326
24327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24328         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
24329         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
24330         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
24331         return tag_ptr(ret_conv, true);
24332 }
24333
24334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24335         LDKSignedRawInvoice o_conv;
24336         o_conv.inner = untag_ptr(o);
24337         o_conv.is_owned = ptr_is_owned(o);
24338         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24339         o_conv = SignedRawInvoice_clone(&o_conv);
24340         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24341         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
24342         return tag_ptr(ret_conv, true);
24343 }
24344
24345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24346         void* e_ptr = untag_ptr(e);
24347         CHECK_ACCESS(e_ptr);
24348         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
24349         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
24350         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24351         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
24352         return tag_ptr(ret_conv, true);
24353 }
24354
24355 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24356         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(o);
24357         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
24358         return ret_conv;
24359 }
24360
24361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24362         if (!ptr_is_owned(_res)) return;
24363         void* _res_ptr = untag_ptr(_res);
24364         CHECK_ACCESS(_res_ptr);
24365         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
24366         FREE(untag_ptr(_res));
24367         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
24368 }
24369
24370 static inline uint64_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
24371         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24372         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
24373         return tag_ptr(ret_conv, true);
24374 }
24375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24376         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(arg);
24377         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
24378         return ret_conv;
24379 }
24380
24381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24382         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(orig);
24383         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
24384         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
24385         return tag_ptr(ret_conv, true);
24386 }
24387
24388 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
24389         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24390         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
24391         return tag_ptr(ret_conv, true);
24392 }
24393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24394         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(arg);
24395         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
24396         return ret_conv;
24397 }
24398
24399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24400         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(orig);
24401         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24402         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
24403         return tag_ptr(ret_conv, true);
24404 }
24405
24406 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) {
24407         LDKRawInvoice a_conv;
24408         a_conv.inner = untag_ptr(a);
24409         a_conv.is_owned = ptr_is_owned(a);
24410         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24411         a_conv = RawInvoice_clone(&a_conv);
24412         LDKThirtyTwoBytes b_ref;
24413         CHECK((*env)->GetArrayLength(env, b) == 32);
24414         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
24415         LDKInvoiceSignature c_conv;
24416         c_conv.inner = untag_ptr(c);
24417         c_conv.is_owned = ptr_is_owned(c);
24418         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
24419         c_conv = InvoiceSignature_clone(&c_conv);
24420         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
24421         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
24422         return tag_ptr(ret_conv, true);
24423 }
24424
24425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24426         if (!ptr_is_owned(_res)) return;
24427         void* _res_ptr = untag_ptr(_res);
24428         CHECK_ACCESS(_res_ptr);
24429         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
24430         FREE(untag_ptr(_res));
24431         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
24432 }
24433
24434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24435         LDKPayeePubKey o_conv;
24436         o_conv.inner = untag_ptr(o);
24437         o_conv.is_owned = ptr_is_owned(o);
24438         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24439         o_conv = PayeePubKey_clone(&o_conv);
24440         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24441         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
24442         return tag_ptr(ret_conv, true);
24443 }
24444
24445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24446         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
24447         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24448         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
24449         return tag_ptr(ret_conv, true);
24450 }
24451
24452 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24453         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(o);
24454         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
24455         return ret_conv;
24456 }
24457
24458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24459         if (!ptr_is_owned(_res)) return;
24460         void* _res_ptr = untag_ptr(_res);
24461         CHECK_ACCESS(_res_ptr);
24462         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
24463         FREE(untag_ptr(_res));
24464         CResult_PayeePubKeyErrorZ_free(_res_conv);
24465 }
24466
24467 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
24468         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24469         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
24470         return tag_ptr(ret_conv, true);
24471 }
24472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24473         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(arg);
24474         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
24475         return ret_conv;
24476 }
24477
24478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24479         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(orig);
24480         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
24481         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
24482         return tag_ptr(ret_conv, true);
24483 }
24484
24485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24486         LDKCVec_PrivateRouteZ _res_constr;
24487         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24488         if (_res_constr.datalen > 0)
24489                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
24490         else
24491                 _res_constr.data = NULL;
24492         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24493         for (size_t o = 0; o < _res_constr.datalen; o++) {
24494                 int64_t _res_conv_14 = _res_vals[o];
24495                 LDKPrivateRoute _res_conv_14_conv;
24496                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
24497                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
24498                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
24499                 _res_constr.data[o] = _res_conv_14_conv;
24500         }
24501         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24502         CVec_PrivateRouteZ_free(_res_constr);
24503 }
24504
24505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24506         LDKPositiveTimestamp o_conv;
24507         o_conv.inner = untag_ptr(o);
24508         o_conv.is_owned = ptr_is_owned(o);
24509         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24510         o_conv = PositiveTimestamp_clone(&o_conv);
24511         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24512         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
24513         return tag_ptr(ret_conv, true);
24514 }
24515
24516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24517         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
24518         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24519         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
24520         return tag_ptr(ret_conv, true);
24521 }
24522
24523 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24524         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
24525         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
24526         return ret_conv;
24527 }
24528
24529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24530         if (!ptr_is_owned(_res)) return;
24531         void* _res_ptr = untag_ptr(_res);
24532         CHECK_ACCESS(_res_ptr);
24533         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
24534         FREE(untag_ptr(_res));
24535         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
24536 }
24537
24538 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
24539         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24540         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
24541         return tag_ptr(ret_conv, true);
24542 }
24543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24544         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
24545         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
24546         return ret_conv;
24547 }
24548
24549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24550         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
24551         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
24552         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
24553         return tag_ptr(ret_conv, true);
24554 }
24555
24556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
24557         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24558         *ret_conv = CResult_NoneSemanticErrorZ_ok();
24559         return tag_ptr(ret_conv, true);
24560 }
24561
24562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24563         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
24564         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24565         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
24566         return tag_ptr(ret_conv, true);
24567 }
24568
24569 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24570         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(o);
24571         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
24572         return ret_conv;
24573 }
24574
24575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24576         if (!ptr_is_owned(_res)) return;
24577         void* _res_ptr = untag_ptr(_res);
24578         CHECK_ACCESS(_res_ptr);
24579         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
24580         FREE(untag_ptr(_res));
24581         CResult_NoneSemanticErrorZ_free(_res_conv);
24582 }
24583
24584 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
24585         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24586         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
24587         return tag_ptr(ret_conv, true);
24588 }
24589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24590         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(arg);
24591         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
24592         return ret_conv;
24593 }
24594
24595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24596         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(orig);
24597         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
24598         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
24599         return tag_ptr(ret_conv, true);
24600 }
24601
24602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24603         LDKInvoice o_conv;
24604         o_conv.inner = untag_ptr(o);
24605         o_conv.is_owned = ptr_is_owned(o);
24606         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24607         o_conv = Invoice_clone(&o_conv);
24608         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24609         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
24610         return tag_ptr(ret_conv, true);
24611 }
24612
24613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24614         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
24615         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24616         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
24617         return tag_ptr(ret_conv, true);
24618 }
24619
24620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24621         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(o);
24622         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
24623         return ret_conv;
24624 }
24625
24626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24627         if (!ptr_is_owned(_res)) return;
24628         void* _res_ptr = untag_ptr(_res);
24629         CHECK_ACCESS(_res_ptr);
24630         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
24631         FREE(untag_ptr(_res));
24632         CResult_InvoiceSemanticErrorZ_free(_res_conv);
24633 }
24634
24635 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
24636         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24637         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
24638         return tag_ptr(ret_conv, true);
24639 }
24640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24641         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(arg);
24642         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
24643         return ret_conv;
24644 }
24645
24646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24647         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(orig);
24648         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
24649         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
24650         return tag_ptr(ret_conv, true);
24651 }
24652
24653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1AddressZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
24654         LDKCVec_AddressZ _res_constr;
24655         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24656         if (_res_constr.datalen > 0)
24657                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKStr), "LDKCVec_AddressZ Elements");
24658         else
24659                 _res_constr.data = NULL;
24660         for (size_t i = 0; i < _res_constr.datalen; i++) {
24661                 jstring _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
24662                 LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
24663                 _res_constr.data[i] = dummy;
24664         }
24665         CVec_AddressZ_free(_res_constr);
24666 }
24667
24668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24669         LDKDescription o_conv;
24670         o_conv.inner = untag_ptr(o);
24671         o_conv.is_owned = ptr_is_owned(o);
24672         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24673         o_conv = Description_clone(&o_conv);
24674         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24675         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
24676         return tag_ptr(ret_conv, true);
24677 }
24678
24679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24680         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
24681         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24682         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
24683         return tag_ptr(ret_conv, true);
24684 }
24685
24686 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24687         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
24688         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
24689         return ret_conv;
24690 }
24691
24692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24693         if (!ptr_is_owned(_res)) return;
24694         void* _res_ptr = untag_ptr(_res);
24695         CHECK_ACCESS(_res_ptr);
24696         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
24697         FREE(untag_ptr(_res));
24698         CResult_DescriptionCreationErrorZ_free(_res_conv);
24699 }
24700
24701 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
24702         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24703         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
24704         return tag_ptr(ret_conv, true);
24705 }
24706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24707         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
24708         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
24709         return ret_conv;
24710 }
24711
24712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24713         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
24714         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
24715         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
24716         return tag_ptr(ret_conv, true);
24717 }
24718
24719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24720         LDKPrivateRoute o_conv;
24721         o_conv.inner = untag_ptr(o);
24722         o_conv.is_owned = ptr_is_owned(o);
24723         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24724         o_conv = PrivateRoute_clone(&o_conv);
24725         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24726         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
24727         return tag_ptr(ret_conv, true);
24728 }
24729
24730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
24731         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
24732         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24733         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
24734         return tag_ptr(ret_conv, true);
24735 }
24736
24737 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24738         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
24739         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
24740         return ret_conv;
24741 }
24742
24743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24744         if (!ptr_is_owned(_res)) return;
24745         void* _res_ptr = untag_ptr(_res);
24746         CHECK_ACCESS(_res_ptr);
24747         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
24748         FREE(untag_ptr(_res));
24749         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
24750 }
24751
24752 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
24753         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24754         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
24755         return tag_ptr(ret_conv, true);
24756 }
24757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24758         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
24759         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
24760         return ret_conv;
24761 }
24762
24763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24764         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
24765         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
24766         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
24767         return tag_ptr(ret_conv, true);
24768 }
24769
24770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24771         void* o_ptr = untag_ptr(o);
24772         CHECK_ACCESS(o_ptr);
24773         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
24774         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
24775         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24776         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
24777         return tag_ptr(ret_conv, true);
24778 }
24779
24780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24781         void* e_ptr = untag_ptr(e);
24782         CHECK_ACCESS(e_ptr);
24783         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24784         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24785         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24786         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
24787         return tag_ptr(ret_conv, true);
24788 }
24789
24790 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24791         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(o);
24792         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
24793         return ret_conv;
24794 }
24795
24796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24797         if (!ptr_is_owned(_res)) return;
24798         void* _res_ptr = untag_ptr(_res);
24799         CHECK_ACCESS(_res_ptr);
24800         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
24801         FREE(untag_ptr(_res));
24802         CResult_NetAddressDecodeErrorZ_free(_res_conv);
24803 }
24804
24805 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
24806         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24807         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
24808         return tag_ptr(ret_conv, true);
24809 }
24810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24811         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(arg);
24812         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
24813         return ret_conv;
24814 }
24815
24816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24817         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(orig);
24818         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24819         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
24820         return tag_ptr(ret_conv, true);
24821 }
24822
24823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24824         LDKCVec_UpdateAddHTLCZ _res_constr;
24825         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24826         if (_res_constr.datalen > 0)
24827                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
24828         else
24829                 _res_constr.data = NULL;
24830         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24831         for (size_t p = 0; p < _res_constr.datalen; p++) {
24832                 int64_t _res_conv_15 = _res_vals[p];
24833                 LDKUpdateAddHTLC _res_conv_15_conv;
24834                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
24835                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
24836                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
24837                 _res_constr.data[p] = _res_conv_15_conv;
24838         }
24839         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24840         CVec_UpdateAddHTLCZ_free(_res_constr);
24841 }
24842
24843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24844         LDKCVec_UpdateFulfillHTLCZ _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(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
24848         else
24849                 _res_constr.data = NULL;
24850         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24851         for (size_t t = 0; t < _res_constr.datalen; t++) {
24852                 int64_t _res_conv_19 = _res_vals[t];
24853                 LDKUpdateFulfillHTLC _res_conv_19_conv;
24854                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
24855                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
24856                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
24857                 _res_constr.data[t] = _res_conv_19_conv;
24858         }
24859         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24860         CVec_UpdateFulfillHTLCZ_free(_res_constr);
24861 }
24862
24863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24864         LDKCVec_UpdateFailHTLCZ _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(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
24868         else
24869                 _res_constr.data = NULL;
24870         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24871         for (size_t q = 0; q < _res_constr.datalen; q++) {
24872                 int64_t _res_conv_16 = _res_vals[q];
24873                 LDKUpdateFailHTLC _res_conv_16_conv;
24874                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
24875                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
24876                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
24877                 _res_constr.data[q] = _res_conv_16_conv;
24878         }
24879         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24880         CVec_UpdateFailHTLCZ_free(_res_constr);
24881 }
24882
24883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24884         LDKCVec_UpdateFailMalformedHTLCZ _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(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
24888         else
24889                 _res_constr.data = NULL;
24890         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24891         for (size_t z = 0; z < _res_constr.datalen; z++) {
24892                 int64_t _res_conv_25 = _res_vals[z];
24893                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
24894                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
24895                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
24896                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
24897                 _res_constr.data[z] = _res_conv_25_conv;
24898         }
24899         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24900         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
24901 }
24902
24903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24904         LDKAcceptChannel o_conv;
24905         o_conv.inner = untag_ptr(o);
24906         o_conv.is_owned = ptr_is_owned(o);
24907         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24908         o_conv = AcceptChannel_clone(&o_conv);
24909         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24910         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
24911         return tag_ptr(ret_conv, true);
24912 }
24913
24914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24915         void* e_ptr = untag_ptr(e);
24916         CHECK_ACCESS(e_ptr);
24917         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24918         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24919         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24920         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
24921         return tag_ptr(ret_conv, true);
24922 }
24923
24924 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24925         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
24926         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
24927         return ret_conv;
24928 }
24929
24930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24931         if (!ptr_is_owned(_res)) return;
24932         void* _res_ptr = untag_ptr(_res);
24933         CHECK_ACCESS(_res_ptr);
24934         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
24935         FREE(untag_ptr(_res));
24936         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
24937 }
24938
24939 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
24940         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24941         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
24942         return tag_ptr(ret_conv, true);
24943 }
24944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24945         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
24946         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
24947         return ret_conv;
24948 }
24949
24950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24951         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
24952         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
24953         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
24954         return tag_ptr(ret_conv, true);
24955 }
24956
24957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24958         LDKAnnouncementSignatures o_conv;
24959         o_conv.inner = untag_ptr(o);
24960         o_conv.is_owned = ptr_is_owned(o);
24961         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24962         o_conv = AnnouncementSignatures_clone(&o_conv);
24963         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24964         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
24965         return tag_ptr(ret_conv, true);
24966 }
24967
24968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24969         void* e_ptr = untag_ptr(e);
24970         CHECK_ACCESS(e_ptr);
24971         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24972         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24973         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24974         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
24975         return tag_ptr(ret_conv, true);
24976 }
24977
24978 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24979         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
24980         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
24981         return ret_conv;
24982 }
24983
24984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24985         if (!ptr_is_owned(_res)) return;
24986         void* _res_ptr = untag_ptr(_res);
24987         CHECK_ACCESS(_res_ptr);
24988         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
24989         FREE(untag_ptr(_res));
24990         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
24991 }
24992
24993 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
24994         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24995         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
24996         return tag_ptr(ret_conv, true);
24997 }
24998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24999         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
25000         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
25001         return ret_conv;
25002 }
25003
25004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25005         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
25006         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
25007         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
25008         return tag_ptr(ret_conv, true);
25009 }
25010
25011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25012         LDKChannelReestablish o_conv;
25013         o_conv.inner = untag_ptr(o);
25014         o_conv.is_owned = ptr_is_owned(o);
25015         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25016         o_conv = ChannelReestablish_clone(&o_conv);
25017         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25018         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
25019         return tag_ptr(ret_conv, true);
25020 }
25021
25022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25023         void* e_ptr = untag_ptr(e);
25024         CHECK_ACCESS(e_ptr);
25025         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25026         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25027         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25028         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
25029         return tag_ptr(ret_conv, true);
25030 }
25031
25032 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25033         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
25034         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
25035         return ret_conv;
25036 }
25037
25038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25039         if (!ptr_is_owned(_res)) return;
25040         void* _res_ptr = untag_ptr(_res);
25041         CHECK_ACCESS(_res_ptr);
25042         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
25043         FREE(untag_ptr(_res));
25044         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
25045 }
25046
25047 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
25048         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25049         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
25050         return tag_ptr(ret_conv, true);
25051 }
25052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25053         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
25054         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
25055         return ret_conv;
25056 }
25057
25058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25059         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
25060         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
25061         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
25062         return tag_ptr(ret_conv, true);
25063 }
25064
25065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25066         LDKClosingSigned o_conv;
25067         o_conv.inner = untag_ptr(o);
25068         o_conv.is_owned = ptr_is_owned(o);
25069         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25070         o_conv = ClosingSigned_clone(&o_conv);
25071         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25072         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
25073         return tag_ptr(ret_conv, true);
25074 }
25075
25076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25077         void* e_ptr = untag_ptr(e);
25078         CHECK_ACCESS(e_ptr);
25079         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25080         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25081         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25082         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
25083         return tag_ptr(ret_conv, true);
25084 }
25085
25086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25087         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
25088         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
25089         return ret_conv;
25090 }
25091
25092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25093         if (!ptr_is_owned(_res)) return;
25094         void* _res_ptr = untag_ptr(_res);
25095         CHECK_ACCESS(_res_ptr);
25096         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
25097         FREE(untag_ptr(_res));
25098         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
25099 }
25100
25101 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
25102         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25103         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
25104         return tag_ptr(ret_conv, true);
25105 }
25106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25107         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
25108         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
25109         return ret_conv;
25110 }
25111
25112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25113         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
25114         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
25115         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
25116         return tag_ptr(ret_conv, true);
25117 }
25118
25119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25120         LDKClosingSignedFeeRange o_conv;
25121         o_conv.inner = untag_ptr(o);
25122         o_conv.is_owned = ptr_is_owned(o);
25123         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25124         o_conv = ClosingSignedFeeRange_clone(&o_conv);
25125         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25126         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
25127         return tag_ptr(ret_conv, true);
25128 }
25129
25130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25131         void* e_ptr = untag_ptr(e);
25132         CHECK_ACCESS(e_ptr);
25133         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25134         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25135         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25136         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
25137         return tag_ptr(ret_conv, true);
25138 }
25139
25140 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25141         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
25142         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
25143         return ret_conv;
25144 }
25145
25146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25147         if (!ptr_is_owned(_res)) return;
25148         void* _res_ptr = untag_ptr(_res);
25149         CHECK_ACCESS(_res_ptr);
25150         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
25151         FREE(untag_ptr(_res));
25152         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
25153 }
25154
25155 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
25156         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25157         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
25158         return tag_ptr(ret_conv, true);
25159 }
25160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25161         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
25162         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
25163         return ret_conv;
25164 }
25165
25166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25167         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
25168         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
25169         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
25170         return tag_ptr(ret_conv, true);
25171 }
25172
25173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25174         LDKCommitmentSigned o_conv;
25175         o_conv.inner = untag_ptr(o);
25176         o_conv.is_owned = ptr_is_owned(o);
25177         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25178         o_conv = CommitmentSigned_clone(&o_conv);
25179         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25180         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
25181         return tag_ptr(ret_conv, true);
25182 }
25183
25184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25185         void* e_ptr = untag_ptr(e);
25186         CHECK_ACCESS(e_ptr);
25187         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25188         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25189         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25190         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
25191         return tag_ptr(ret_conv, true);
25192 }
25193
25194 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25195         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
25196         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
25197         return ret_conv;
25198 }
25199
25200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25201         if (!ptr_is_owned(_res)) return;
25202         void* _res_ptr = untag_ptr(_res);
25203         CHECK_ACCESS(_res_ptr);
25204         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
25205         FREE(untag_ptr(_res));
25206         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
25207 }
25208
25209 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
25210         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25211         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
25212         return tag_ptr(ret_conv, true);
25213 }
25214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25215         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
25216         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
25217         return ret_conv;
25218 }
25219
25220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25221         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
25222         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
25223         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
25224         return tag_ptr(ret_conv, true);
25225 }
25226
25227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25228         LDKFundingCreated o_conv;
25229         o_conv.inner = untag_ptr(o);
25230         o_conv.is_owned = ptr_is_owned(o);
25231         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25232         o_conv = FundingCreated_clone(&o_conv);
25233         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25234         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
25235         return tag_ptr(ret_conv, true);
25236 }
25237
25238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25239         void* e_ptr = untag_ptr(e);
25240         CHECK_ACCESS(e_ptr);
25241         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25242         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25243         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25244         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
25245         return tag_ptr(ret_conv, true);
25246 }
25247
25248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25249         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
25250         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
25251         return ret_conv;
25252 }
25253
25254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25255         if (!ptr_is_owned(_res)) return;
25256         void* _res_ptr = untag_ptr(_res);
25257         CHECK_ACCESS(_res_ptr);
25258         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
25259         FREE(untag_ptr(_res));
25260         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
25261 }
25262
25263 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
25264         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25265         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
25266         return tag_ptr(ret_conv, true);
25267 }
25268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25269         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
25270         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
25271         return ret_conv;
25272 }
25273
25274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25275         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
25276         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
25277         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
25278         return tag_ptr(ret_conv, true);
25279 }
25280
25281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25282         LDKFundingSigned o_conv;
25283         o_conv.inner = untag_ptr(o);
25284         o_conv.is_owned = ptr_is_owned(o);
25285         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25286         o_conv = FundingSigned_clone(&o_conv);
25287         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25288         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
25289         return tag_ptr(ret_conv, true);
25290 }
25291
25292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25293         void* e_ptr = untag_ptr(e);
25294         CHECK_ACCESS(e_ptr);
25295         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25296         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25297         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25298         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
25299         return tag_ptr(ret_conv, true);
25300 }
25301
25302 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25303         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
25304         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
25305         return ret_conv;
25306 }
25307
25308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25309         if (!ptr_is_owned(_res)) return;
25310         void* _res_ptr = untag_ptr(_res);
25311         CHECK_ACCESS(_res_ptr);
25312         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
25313         FREE(untag_ptr(_res));
25314         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
25315 }
25316
25317 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
25318         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25319         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
25320         return tag_ptr(ret_conv, true);
25321 }
25322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25323         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
25324         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
25325         return ret_conv;
25326 }
25327
25328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25329         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
25330         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
25331         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
25332         return tag_ptr(ret_conv, true);
25333 }
25334
25335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25336         LDKChannelReady o_conv;
25337         o_conv.inner = untag_ptr(o);
25338         o_conv.is_owned = ptr_is_owned(o);
25339         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25340         o_conv = ChannelReady_clone(&o_conv);
25341         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25342         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
25343         return tag_ptr(ret_conv, true);
25344 }
25345
25346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25347         void* e_ptr = untag_ptr(e);
25348         CHECK_ACCESS(e_ptr);
25349         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25350         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25351         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25352         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
25353         return tag_ptr(ret_conv, true);
25354 }
25355
25356 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25357         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
25358         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
25359         return ret_conv;
25360 }
25361
25362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25363         if (!ptr_is_owned(_res)) return;
25364         void* _res_ptr = untag_ptr(_res);
25365         CHECK_ACCESS(_res_ptr);
25366         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
25367         FREE(untag_ptr(_res));
25368         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
25369 }
25370
25371 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
25372         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25373         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
25374         return tag_ptr(ret_conv, true);
25375 }
25376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25377         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
25378         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
25379         return ret_conv;
25380 }
25381
25382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25383         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
25384         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
25385         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
25386         return tag_ptr(ret_conv, true);
25387 }
25388
25389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25390         LDKInit o_conv;
25391         o_conv.inner = untag_ptr(o);
25392         o_conv.is_owned = ptr_is_owned(o);
25393         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25394         o_conv = Init_clone(&o_conv);
25395         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25396         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
25397         return tag_ptr(ret_conv, true);
25398 }
25399
25400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25401         void* e_ptr = untag_ptr(e);
25402         CHECK_ACCESS(e_ptr);
25403         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25404         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25405         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25406         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
25407         return tag_ptr(ret_conv, true);
25408 }
25409
25410 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25411         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
25412         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
25413         return ret_conv;
25414 }
25415
25416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25417         if (!ptr_is_owned(_res)) return;
25418         void* _res_ptr = untag_ptr(_res);
25419         CHECK_ACCESS(_res_ptr);
25420         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
25421         FREE(untag_ptr(_res));
25422         CResult_InitDecodeErrorZ_free(_res_conv);
25423 }
25424
25425 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
25426         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25427         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
25428         return tag_ptr(ret_conv, true);
25429 }
25430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25431         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
25432         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
25433         return ret_conv;
25434 }
25435
25436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25437         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
25438         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
25439         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
25440         return tag_ptr(ret_conv, true);
25441 }
25442
25443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25444         LDKOpenChannel o_conv;
25445         o_conv.inner = untag_ptr(o);
25446         o_conv.is_owned = ptr_is_owned(o);
25447         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25448         o_conv = OpenChannel_clone(&o_conv);
25449         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25450         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
25451         return tag_ptr(ret_conv, true);
25452 }
25453
25454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25455         void* e_ptr = untag_ptr(e);
25456         CHECK_ACCESS(e_ptr);
25457         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25458         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25459         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25460         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
25461         return tag_ptr(ret_conv, true);
25462 }
25463
25464 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25465         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
25466         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
25467         return ret_conv;
25468 }
25469
25470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25471         if (!ptr_is_owned(_res)) return;
25472         void* _res_ptr = untag_ptr(_res);
25473         CHECK_ACCESS(_res_ptr);
25474         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
25475         FREE(untag_ptr(_res));
25476         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
25477 }
25478
25479 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
25480         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25481         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
25482         return tag_ptr(ret_conv, true);
25483 }
25484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25485         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
25486         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
25487         return ret_conv;
25488 }
25489
25490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25491         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
25492         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25493         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
25494         return tag_ptr(ret_conv, true);
25495 }
25496
25497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25498         LDKRevokeAndACK o_conv;
25499         o_conv.inner = untag_ptr(o);
25500         o_conv.is_owned = ptr_is_owned(o);
25501         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25502         o_conv = RevokeAndACK_clone(&o_conv);
25503         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25504         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
25505         return tag_ptr(ret_conv, true);
25506 }
25507
25508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25509         void* e_ptr = untag_ptr(e);
25510         CHECK_ACCESS(e_ptr);
25511         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25512         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25513         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25514         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
25515         return tag_ptr(ret_conv, true);
25516 }
25517
25518 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25519         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
25520         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
25521         return ret_conv;
25522 }
25523
25524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25525         if (!ptr_is_owned(_res)) return;
25526         void* _res_ptr = untag_ptr(_res);
25527         CHECK_ACCESS(_res_ptr);
25528         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
25529         FREE(untag_ptr(_res));
25530         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
25531 }
25532
25533 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
25534         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25535         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
25536         return tag_ptr(ret_conv, true);
25537 }
25538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25539         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
25540         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
25541         return ret_conv;
25542 }
25543
25544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25545         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
25546         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25547         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
25548         return tag_ptr(ret_conv, true);
25549 }
25550
25551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25552         LDKShutdown o_conv;
25553         o_conv.inner = untag_ptr(o);
25554         o_conv.is_owned = ptr_is_owned(o);
25555         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25556         o_conv = Shutdown_clone(&o_conv);
25557         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25558         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
25559         return tag_ptr(ret_conv, true);
25560 }
25561
25562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25563         void* e_ptr = untag_ptr(e);
25564         CHECK_ACCESS(e_ptr);
25565         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25566         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25567         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25568         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
25569         return tag_ptr(ret_conv, true);
25570 }
25571
25572 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25573         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
25574         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
25575         return ret_conv;
25576 }
25577
25578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25579         if (!ptr_is_owned(_res)) return;
25580         void* _res_ptr = untag_ptr(_res);
25581         CHECK_ACCESS(_res_ptr);
25582         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
25583         FREE(untag_ptr(_res));
25584         CResult_ShutdownDecodeErrorZ_free(_res_conv);
25585 }
25586
25587 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
25588         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25589         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
25590         return tag_ptr(ret_conv, true);
25591 }
25592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25593         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
25594         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
25595         return ret_conv;
25596 }
25597
25598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25599         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
25600         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25601         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
25602         return tag_ptr(ret_conv, true);
25603 }
25604
25605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25606         LDKUpdateFailHTLC o_conv;
25607         o_conv.inner = untag_ptr(o);
25608         o_conv.is_owned = ptr_is_owned(o);
25609         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25610         o_conv = UpdateFailHTLC_clone(&o_conv);
25611         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25612         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
25613         return tag_ptr(ret_conv, true);
25614 }
25615
25616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25617         void* e_ptr = untag_ptr(e);
25618         CHECK_ACCESS(e_ptr);
25619         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25620         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25621         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25622         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
25623         return tag_ptr(ret_conv, true);
25624 }
25625
25626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25627         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
25628         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
25629         return ret_conv;
25630 }
25631
25632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25633         if (!ptr_is_owned(_res)) return;
25634         void* _res_ptr = untag_ptr(_res);
25635         CHECK_ACCESS(_res_ptr);
25636         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
25637         FREE(untag_ptr(_res));
25638         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
25639 }
25640
25641 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
25642         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25643         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
25644         return tag_ptr(ret_conv, true);
25645 }
25646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25647         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
25648         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
25649         return ret_conv;
25650 }
25651
25652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25653         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
25654         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25655         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
25656         return tag_ptr(ret_conv, true);
25657 }
25658
25659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25660         LDKUpdateFailMalformedHTLC o_conv;
25661         o_conv.inner = untag_ptr(o);
25662         o_conv.is_owned = ptr_is_owned(o);
25663         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25664         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
25665         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25666         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
25667         return tag_ptr(ret_conv, true);
25668 }
25669
25670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25671         void* e_ptr = untag_ptr(e);
25672         CHECK_ACCESS(e_ptr);
25673         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25674         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25675         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25676         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
25677         return tag_ptr(ret_conv, true);
25678 }
25679
25680 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25681         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
25682         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
25683         return ret_conv;
25684 }
25685
25686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25687         if (!ptr_is_owned(_res)) return;
25688         void* _res_ptr = untag_ptr(_res);
25689         CHECK_ACCESS(_res_ptr);
25690         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
25691         FREE(untag_ptr(_res));
25692         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
25693 }
25694
25695 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
25696         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25697         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
25698         return tag_ptr(ret_conv, true);
25699 }
25700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25701         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
25702         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
25703         return ret_conv;
25704 }
25705
25706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25707         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
25708         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25709         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
25710         return tag_ptr(ret_conv, true);
25711 }
25712
25713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25714         LDKUpdateFee o_conv;
25715         o_conv.inner = untag_ptr(o);
25716         o_conv.is_owned = ptr_is_owned(o);
25717         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25718         o_conv = UpdateFee_clone(&o_conv);
25719         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25720         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
25721         return tag_ptr(ret_conv, true);
25722 }
25723
25724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25725         void* e_ptr = untag_ptr(e);
25726         CHECK_ACCESS(e_ptr);
25727         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25728         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25729         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25730         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
25731         return tag_ptr(ret_conv, true);
25732 }
25733
25734 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25735         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
25736         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
25737         return ret_conv;
25738 }
25739
25740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25741         if (!ptr_is_owned(_res)) return;
25742         void* _res_ptr = untag_ptr(_res);
25743         CHECK_ACCESS(_res_ptr);
25744         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
25745         FREE(untag_ptr(_res));
25746         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
25747 }
25748
25749 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
25750         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25751         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
25752         return tag_ptr(ret_conv, true);
25753 }
25754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25755         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
25756         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
25757         return ret_conv;
25758 }
25759
25760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25761         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
25762         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25763         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
25764         return tag_ptr(ret_conv, true);
25765 }
25766
25767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25768         LDKUpdateFulfillHTLC o_conv;
25769         o_conv.inner = untag_ptr(o);
25770         o_conv.is_owned = ptr_is_owned(o);
25771         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25772         o_conv = UpdateFulfillHTLC_clone(&o_conv);
25773         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25774         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
25775         return tag_ptr(ret_conv, true);
25776 }
25777
25778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25779         void* e_ptr = untag_ptr(e);
25780         CHECK_ACCESS(e_ptr);
25781         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25782         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25783         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25784         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
25785         return tag_ptr(ret_conv, true);
25786 }
25787
25788 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25789         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
25790         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
25791         return ret_conv;
25792 }
25793
25794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25795         if (!ptr_is_owned(_res)) return;
25796         void* _res_ptr = untag_ptr(_res);
25797         CHECK_ACCESS(_res_ptr);
25798         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
25799         FREE(untag_ptr(_res));
25800         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
25801 }
25802
25803 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
25804         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25805         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
25806         return tag_ptr(ret_conv, true);
25807 }
25808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25809         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
25810         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
25811         return ret_conv;
25812 }
25813
25814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25815         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
25816         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25817         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
25818         return tag_ptr(ret_conv, true);
25819 }
25820
25821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25822         LDKUpdateAddHTLC o_conv;
25823         o_conv.inner = untag_ptr(o);
25824         o_conv.is_owned = ptr_is_owned(o);
25825         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25826         o_conv = UpdateAddHTLC_clone(&o_conv);
25827         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25828         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
25829         return tag_ptr(ret_conv, true);
25830 }
25831
25832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25833         void* e_ptr = untag_ptr(e);
25834         CHECK_ACCESS(e_ptr);
25835         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25836         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25837         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25838         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
25839         return tag_ptr(ret_conv, true);
25840 }
25841
25842 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25843         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
25844         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
25845         return ret_conv;
25846 }
25847
25848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25849         if (!ptr_is_owned(_res)) return;
25850         void* _res_ptr = untag_ptr(_res);
25851         CHECK_ACCESS(_res_ptr);
25852         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
25853         FREE(untag_ptr(_res));
25854         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
25855 }
25856
25857 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
25858         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25859         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
25860         return tag_ptr(ret_conv, true);
25861 }
25862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25863         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
25864         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
25865         return ret_conv;
25866 }
25867
25868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25869         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
25870         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25871         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
25872         return tag_ptr(ret_conv, true);
25873 }
25874
25875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25876         LDKOnionMessage o_conv;
25877         o_conv.inner = untag_ptr(o);
25878         o_conv.is_owned = ptr_is_owned(o);
25879         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25880         o_conv = OnionMessage_clone(&o_conv);
25881         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25882         *ret_conv = CResult_OnionMessageDecodeErrorZ_ok(o_conv);
25883         return tag_ptr(ret_conv, true);
25884 }
25885
25886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25887         void* e_ptr = untag_ptr(e);
25888         CHECK_ACCESS(e_ptr);
25889         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25890         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25891         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25892         *ret_conv = CResult_OnionMessageDecodeErrorZ_err(e_conv);
25893         return tag_ptr(ret_conv, true);
25894 }
25895
25896 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25897         LDKCResult_OnionMessageDecodeErrorZ* o_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(o);
25898         jboolean ret_conv = CResult_OnionMessageDecodeErrorZ_is_ok(o_conv);
25899         return ret_conv;
25900 }
25901
25902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25903         if (!ptr_is_owned(_res)) return;
25904         void* _res_ptr = untag_ptr(_res);
25905         CHECK_ACCESS(_res_ptr);
25906         LDKCResult_OnionMessageDecodeErrorZ _res_conv = *(LDKCResult_OnionMessageDecodeErrorZ*)(_res_ptr);
25907         FREE(untag_ptr(_res));
25908         CResult_OnionMessageDecodeErrorZ_free(_res_conv);
25909 }
25910
25911 static inline uint64_t CResult_OnionMessageDecodeErrorZ_clone_ptr(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR arg) {
25912         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25913         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(arg);
25914         return tag_ptr(ret_conv, true);
25915 }
25916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25917         LDKCResult_OnionMessageDecodeErrorZ* arg_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(arg);
25918         int64_t ret_conv = CResult_OnionMessageDecodeErrorZ_clone_ptr(arg_conv);
25919         return ret_conv;
25920 }
25921
25922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25923         LDKCResult_OnionMessageDecodeErrorZ* orig_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(orig);
25924         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25925         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(orig_conv);
25926         return tag_ptr(ret_conv, true);
25927 }
25928
25929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25930         LDKPing o_conv;
25931         o_conv.inner = untag_ptr(o);
25932         o_conv.is_owned = ptr_is_owned(o);
25933         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25934         o_conv = Ping_clone(&o_conv);
25935         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25936         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
25937         return tag_ptr(ret_conv, true);
25938 }
25939
25940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25941         void* e_ptr = untag_ptr(e);
25942         CHECK_ACCESS(e_ptr);
25943         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25944         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25945         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25946         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
25947         return tag_ptr(ret_conv, true);
25948 }
25949
25950 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25951         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
25952         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
25953         return ret_conv;
25954 }
25955
25956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25957         if (!ptr_is_owned(_res)) return;
25958         void* _res_ptr = untag_ptr(_res);
25959         CHECK_ACCESS(_res_ptr);
25960         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
25961         FREE(untag_ptr(_res));
25962         CResult_PingDecodeErrorZ_free(_res_conv);
25963 }
25964
25965 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
25966         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25967         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
25968         return tag_ptr(ret_conv, true);
25969 }
25970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25971         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
25972         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
25973         return ret_conv;
25974 }
25975
25976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25977         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
25978         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25979         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
25980         return tag_ptr(ret_conv, true);
25981 }
25982
25983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25984         LDKPong o_conv;
25985         o_conv.inner = untag_ptr(o);
25986         o_conv.is_owned = ptr_is_owned(o);
25987         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25988         o_conv = Pong_clone(&o_conv);
25989         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25990         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
25991         return tag_ptr(ret_conv, true);
25992 }
25993
25994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25995         void* e_ptr = untag_ptr(e);
25996         CHECK_ACCESS(e_ptr);
25997         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25998         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25999         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26000         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
26001         return tag_ptr(ret_conv, true);
26002 }
26003
26004 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26005         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
26006         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
26007         return ret_conv;
26008 }
26009
26010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26011         if (!ptr_is_owned(_res)) return;
26012         void* _res_ptr = untag_ptr(_res);
26013         CHECK_ACCESS(_res_ptr);
26014         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
26015         FREE(untag_ptr(_res));
26016         CResult_PongDecodeErrorZ_free(_res_conv);
26017 }
26018
26019 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
26020         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26021         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
26022         return tag_ptr(ret_conv, true);
26023 }
26024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26025         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
26026         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
26027         return ret_conv;
26028 }
26029
26030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26031         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
26032         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
26033         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
26034         return tag_ptr(ret_conv, true);
26035 }
26036
26037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26038         LDKUnsignedChannelAnnouncement o_conv;
26039         o_conv.inner = untag_ptr(o);
26040         o_conv.is_owned = ptr_is_owned(o);
26041         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26042         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
26043         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26044         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
26045         return tag_ptr(ret_conv, true);
26046 }
26047
26048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26049         void* e_ptr = untag_ptr(e);
26050         CHECK_ACCESS(e_ptr);
26051         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26052         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26053         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26054         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
26055         return tag_ptr(ret_conv, true);
26056 }
26057
26058 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26059         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
26060         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
26061         return ret_conv;
26062 }
26063
26064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26065         if (!ptr_is_owned(_res)) return;
26066         void* _res_ptr = untag_ptr(_res);
26067         CHECK_ACCESS(_res_ptr);
26068         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
26069         FREE(untag_ptr(_res));
26070         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
26071 }
26072
26073 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26074         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26075         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
26076         return tag_ptr(ret_conv, true);
26077 }
26078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26079         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
26080         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26081         return ret_conv;
26082 }
26083
26084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26085         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
26086         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
26087         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
26088         return tag_ptr(ret_conv, true);
26089 }
26090
26091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26092         LDKChannelAnnouncement o_conv;
26093         o_conv.inner = untag_ptr(o);
26094         o_conv.is_owned = ptr_is_owned(o);
26095         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26096         o_conv = ChannelAnnouncement_clone(&o_conv);
26097         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26098         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
26099         return tag_ptr(ret_conv, true);
26100 }
26101
26102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26103         void* e_ptr = untag_ptr(e);
26104         CHECK_ACCESS(e_ptr);
26105         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26106         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26107         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26108         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
26109         return tag_ptr(ret_conv, true);
26110 }
26111
26112 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26113         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
26114         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
26115         return ret_conv;
26116 }
26117
26118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26119         if (!ptr_is_owned(_res)) return;
26120         void* _res_ptr = untag_ptr(_res);
26121         CHECK_ACCESS(_res_ptr);
26122         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
26123         FREE(untag_ptr(_res));
26124         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
26125 }
26126
26127 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26128         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26129         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
26130         return tag_ptr(ret_conv, true);
26131 }
26132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26133         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
26134         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26135         return ret_conv;
26136 }
26137
26138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26139         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
26140         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
26141         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
26142         return tag_ptr(ret_conv, true);
26143 }
26144
26145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26146         LDKUnsignedChannelUpdate o_conv;
26147         o_conv.inner = untag_ptr(o);
26148         o_conv.is_owned = ptr_is_owned(o);
26149         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26150         o_conv = UnsignedChannelUpdate_clone(&o_conv);
26151         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26152         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
26153         return tag_ptr(ret_conv, true);
26154 }
26155
26156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26157         void* e_ptr = untag_ptr(e);
26158         CHECK_ACCESS(e_ptr);
26159         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26160         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26161         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26162         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
26163         return tag_ptr(ret_conv, true);
26164 }
26165
26166 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26167         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
26168         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
26169         return ret_conv;
26170 }
26171
26172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26173         if (!ptr_is_owned(_res)) return;
26174         void* _res_ptr = untag_ptr(_res);
26175         CHECK_ACCESS(_res_ptr);
26176         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
26177         FREE(untag_ptr(_res));
26178         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
26179 }
26180
26181 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
26182         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26183         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
26184         return tag_ptr(ret_conv, true);
26185 }
26186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26187         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
26188         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
26189         return ret_conv;
26190 }
26191
26192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26193         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
26194         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
26195         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
26196         return tag_ptr(ret_conv, true);
26197 }
26198
26199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26200         LDKChannelUpdate o_conv;
26201         o_conv.inner = untag_ptr(o);
26202         o_conv.is_owned = ptr_is_owned(o);
26203         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26204         o_conv = ChannelUpdate_clone(&o_conv);
26205         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26206         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
26207         return tag_ptr(ret_conv, true);
26208 }
26209
26210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26211         void* e_ptr = untag_ptr(e);
26212         CHECK_ACCESS(e_ptr);
26213         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26214         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26215         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26216         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
26217         return tag_ptr(ret_conv, true);
26218 }
26219
26220 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26221         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
26222         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
26223         return ret_conv;
26224 }
26225
26226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26227         if (!ptr_is_owned(_res)) return;
26228         void* _res_ptr = untag_ptr(_res);
26229         CHECK_ACCESS(_res_ptr);
26230         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
26231         FREE(untag_ptr(_res));
26232         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
26233 }
26234
26235 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
26236         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26237         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
26238         return tag_ptr(ret_conv, true);
26239 }
26240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26241         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
26242         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
26243         return ret_conv;
26244 }
26245
26246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26247         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
26248         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
26249         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
26250         return tag_ptr(ret_conv, true);
26251 }
26252
26253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26254         LDKErrorMessage o_conv;
26255         o_conv.inner = untag_ptr(o);
26256         o_conv.is_owned = ptr_is_owned(o);
26257         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26258         o_conv = ErrorMessage_clone(&o_conv);
26259         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26260         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
26261         return tag_ptr(ret_conv, true);
26262 }
26263
26264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26265         void* e_ptr = untag_ptr(e);
26266         CHECK_ACCESS(e_ptr);
26267         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26268         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26269         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26270         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
26271         return tag_ptr(ret_conv, true);
26272 }
26273
26274 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26275         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
26276         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
26277         return ret_conv;
26278 }
26279
26280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26281         if (!ptr_is_owned(_res)) return;
26282         void* _res_ptr = untag_ptr(_res);
26283         CHECK_ACCESS(_res_ptr);
26284         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
26285         FREE(untag_ptr(_res));
26286         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
26287 }
26288
26289 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
26290         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26291         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
26292         return tag_ptr(ret_conv, true);
26293 }
26294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26295         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
26296         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
26297         return ret_conv;
26298 }
26299
26300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26301         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
26302         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
26303         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
26304         return tag_ptr(ret_conv, true);
26305 }
26306
26307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26308         LDKWarningMessage o_conv;
26309         o_conv.inner = untag_ptr(o);
26310         o_conv.is_owned = ptr_is_owned(o);
26311         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26312         o_conv = WarningMessage_clone(&o_conv);
26313         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26314         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
26315         return tag_ptr(ret_conv, true);
26316 }
26317
26318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26319         void* e_ptr = untag_ptr(e);
26320         CHECK_ACCESS(e_ptr);
26321         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26322         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26323         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26324         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
26325         return tag_ptr(ret_conv, true);
26326 }
26327
26328 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26329         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
26330         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
26331         return ret_conv;
26332 }
26333
26334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26335         if (!ptr_is_owned(_res)) return;
26336         void* _res_ptr = untag_ptr(_res);
26337         CHECK_ACCESS(_res_ptr);
26338         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
26339         FREE(untag_ptr(_res));
26340         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
26341 }
26342
26343 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
26344         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26345         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
26346         return tag_ptr(ret_conv, true);
26347 }
26348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26349         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
26350         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
26351         return ret_conv;
26352 }
26353
26354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26355         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
26356         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
26357         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
26358         return tag_ptr(ret_conv, true);
26359 }
26360
26361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26362         LDKUnsignedNodeAnnouncement o_conv;
26363         o_conv.inner = untag_ptr(o);
26364         o_conv.is_owned = ptr_is_owned(o);
26365         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26366         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
26367         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26368         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
26369         return tag_ptr(ret_conv, true);
26370 }
26371
26372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26373         void* e_ptr = untag_ptr(e);
26374         CHECK_ACCESS(e_ptr);
26375         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26376         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26377         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26378         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
26379         return tag_ptr(ret_conv, true);
26380 }
26381
26382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26383         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
26384         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
26385         return ret_conv;
26386 }
26387
26388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26389         if (!ptr_is_owned(_res)) return;
26390         void* _res_ptr = untag_ptr(_res);
26391         CHECK_ACCESS(_res_ptr);
26392         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
26393         FREE(untag_ptr(_res));
26394         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
26395 }
26396
26397 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26398         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26399         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
26400         return tag_ptr(ret_conv, true);
26401 }
26402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26403         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
26404         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26405         return ret_conv;
26406 }
26407
26408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26409         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
26410         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26411         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
26412         return tag_ptr(ret_conv, true);
26413 }
26414
26415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26416         LDKNodeAnnouncement o_conv;
26417         o_conv.inner = untag_ptr(o);
26418         o_conv.is_owned = ptr_is_owned(o);
26419         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26420         o_conv = NodeAnnouncement_clone(&o_conv);
26421         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26422         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
26423         return tag_ptr(ret_conv, true);
26424 }
26425
26426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26427         void* e_ptr = untag_ptr(e);
26428         CHECK_ACCESS(e_ptr);
26429         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26430         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26431         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26432         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
26433         return tag_ptr(ret_conv, true);
26434 }
26435
26436 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26437         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
26438         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
26439         return ret_conv;
26440 }
26441
26442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26443         if (!ptr_is_owned(_res)) return;
26444         void* _res_ptr = untag_ptr(_res);
26445         CHECK_ACCESS(_res_ptr);
26446         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
26447         FREE(untag_ptr(_res));
26448         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
26449 }
26450
26451 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26452         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26453         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
26454         return tag_ptr(ret_conv, true);
26455 }
26456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26457         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
26458         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26459         return ret_conv;
26460 }
26461
26462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26463         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
26464         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26465         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
26466         return tag_ptr(ret_conv, true);
26467 }
26468
26469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26470         LDKQueryShortChannelIds o_conv;
26471         o_conv.inner = untag_ptr(o);
26472         o_conv.is_owned = ptr_is_owned(o);
26473         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26474         o_conv = QueryShortChannelIds_clone(&o_conv);
26475         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26476         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
26477         return tag_ptr(ret_conv, true);
26478 }
26479
26480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26481         void* e_ptr = untag_ptr(e);
26482         CHECK_ACCESS(e_ptr);
26483         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26484         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26485         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26486         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
26487         return tag_ptr(ret_conv, true);
26488 }
26489
26490 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26491         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
26492         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
26493         return ret_conv;
26494 }
26495
26496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26497         if (!ptr_is_owned(_res)) return;
26498         void* _res_ptr = untag_ptr(_res);
26499         CHECK_ACCESS(_res_ptr);
26500         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
26501         FREE(untag_ptr(_res));
26502         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
26503 }
26504
26505 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
26506         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26507         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
26508         return tag_ptr(ret_conv, true);
26509 }
26510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26511         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
26512         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
26513         return ret_conv;
26514 }
26515
26516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26517         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
26518         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26519         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
26520         return tag_ptr(ret_conv, true);
26521 }
26522
26523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26524         LDKReplyShortChannelIdsEnd o_conv;
26525         o_conv.inner = untag_ptr(o);
26526         o_conv.is_owned = ptr_is_owned(o);
26527         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26528         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
26529         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26530         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
26531         return tag_ptr(ret_conv, true);
26532 }
26533
26534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26535         void* e_ptr = untag_ptr(e);
26536         CHECK_ACCESS(e_ptr);
26537         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26538         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26539         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26540         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
26541         return tag_ptr(ret_conv, true);
26542 }
26543
26544 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26545         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
26546         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
26547         return ret_conv;
26548 }
26549
26550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26551         if (!ptr_is_owned(_res)) return;
26552         void* _res_ptr = untag_ptr(_res);
26553         CHECK_ACCESS(_res_ptr);
26554         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
26555         FREE(untag_ptr(_res));
26556         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
26557 }
26558
26559 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
26560         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26561         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
26562         return tag_ptr(ret_conv, true);
26563 }
26564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26565         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
26566         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
26567         return ret_conv;
26568 }
26569
26570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26571         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
26572         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26573         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
26574         return tag_ptr(ret_conv, true);
26575 }
26576
26577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26578         LDKQueryChannelRange o_conv;
26579         o_conv.inner = untag_ptr(o);
26580         o_conv.is_owned = ptr_is_owned(o);
26581         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26582         o_conv = QueryChannelRange_clone(&o_conv);
26583         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26584         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
26585         return tag_ptr(ret_conv, true);
26586 }
26587
26588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26589         void* e_ptr = untag_ptr(e);
26590         CHECK_ACCESS(e_ptr);
26591         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26592         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26593         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26594         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
26595         return tag_ptr(ret_conv, true);
26596 }
26597
26598 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26599         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
26600         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
26601         return ret_conv;
26602 }
26603
26604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26605         if (!ptr_is_owned(_res)) return;
26606         void* _res_ptr = untag_ptr(_res);
26607         CHECK_ACCESS(_res_ptr);
26608         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
26609         FREE(untag_ptr(_res));
26610         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
26611 }
26612
26613 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
26614         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26615         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
26616         return tag_ptr(ret_conv, true);
26617 }
26618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26619         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
26620         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
26621         return ret_conv;
26622 }
26623
26624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26625         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
26626         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26627         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
26628         return tag_ptr(ret_conv, true);
26629 }
26630
26631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26632         LDKReplyChannelRange o_conv;
26633         o_conv.inner = untag_ptr(o);
26634         o_conv.is_owned = ptr_is_owned(o);
26635         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26636         o_conv = ReplyChannelRange_clone(&o_conv);
26637         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26638         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
26639         return tag_ptr(ret_conv, true);
26640 }
26641
26642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26643         void* e_ptr = untag_ptr(e);
26644         CHECK_ACCESS(e_ptr);
26645         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26646         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26647         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26648         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
26649         return tag_ptr(ret_conv, true);
26650 }
26651
26652 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26653         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
26654         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
26655         return ret_conv;
26656 }
26657
26658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26659         if (!ptr_is_owned(_res)) return;
26660         void* _res_ptr = untag_ptr(_res);
26661         CHECK_ACCESS(_res_ptr);
26662         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
26663         FREE(untag_ptr(_res));
26664         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
26665 }
26666
26667 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
26668         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26669         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
26670         return tag_ptr(ret_conv, true);
26671 }
26672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26673         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
26674         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
26675         return ret_conv;
26676 }
26677
26678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26679         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
26680         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26681         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
26682         return tag_ptr(ret_conv, true);
26683 }
26684
26685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26686         LDKGossipTimestampFilter o_conv;
26687         o_conv.inner = untag_ptr(o);
26688         o_conv.is_owned = ptr_is_owned(o);
26689         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26690         o_conv = GossipTimestampFilter_clone(&o_conv);
26691         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26692         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
26693         return tag_ptr(ret_conv, true);
26694 }
26695
26696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26697         void* e_ptr = untag_ptr(e);
26698         CHECK_ACCESS(e_ptr);
26699         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26700         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26701         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26702         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
26703         return tag_ptr(ret_conv, true);
26704 }
26705
26706 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26707         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
26708         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
26709         return ret_conv;
26710 }
26711
26712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26713         if (!ptr_is_owned(_res)) return;
26714         void* _res_ptr = untag_ptr(_res);
26715         CHECK_ACCESS(_res_ptr);
26716         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
26717         FREE(untag_ptr(_res));
26718         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
26719 }
26720
26721 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
26722         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26723         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
26724         return tag_ptr(ret_conv, true);
26725 }
26726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26727         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
26728         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
26729         return ret_conv;
26730 }
26731
26732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26733         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
26734         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26735         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
26736         return tag_ptr(ret_conv, true);
26737 }
26738
26739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26740         LDKCVec_PhantomRouteHintsZ _res_constr;
26741         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26742         if (_res_constr.datalen > 0)
26743                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
26744         else
26745                 _res_constr.data = NULL;
26746         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26747         for (size_t t = 0; t < _res_constr.datalen; t++) {
26748                 int64_t _res_conv_19 = _res_vals[t];
26749                 LDKPhantomRouteHints _res_conv_19_conv;
26750                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
26751                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
26752                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
26753                 _res_constr.data[t] = _res_conv_19_conv;
26754         }
26755         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26756         CVec_PhantomRouteHintsZ_free(_res_constr);
26757 }
26758
26759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26760         LDKInvoice o_conv;
26761         o_conv.inner = untag_ptr(o);
26762         o_conv.is_owned = ptr_is_owned(o);
26763         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26764         o_conv = Invoice_clone(&o_conv);
26765         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26766         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
26767         return tag_ptr(ret_conv, true);
26768 }
26769
26770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
26771         void* e_ptr = untag_ptr(e);
26772         CHECK_ACCESS(e_ptr);
26773         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
26774         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
26775         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26776         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
26777         return tag_ptr(ret_conv, true);
26778 }
26779
26780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26781         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(o);
26782         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
26783         return ret_conv;
26784 }
26785
26786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26787         if (!ptr_is_owned(_res)) return;
26788         void* _res_ptr = untag_ptr(_res);
26789         CHECK_ACCESS(_res_ptr);
26790         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
26791         FREE(untag_ptr(_res));
26792         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
26793 }
26794
26795 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
26796         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26797         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
26798         return tag_ptr(ret_conv, true);
26799 }
26800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26801         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
26802         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
26803         return ret_conv;
26804 }
26805
26806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26807         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
26808         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26809         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
26810         return tag_ptr(ret_conv, true);
26811 }
26812
26813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1FutureZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26814         LDKCVec_FutureZ _res_constr;
26815         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26816         if (_res_constr.datalen > 0)
26817                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKFuture), "LDKCVec_FutureZ Elements");
26818         else
26819                 _res_constr.data = NULL;
26820         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26821         for (size_t i = 0; i < _res_constr.datalen; i++) {
26822                 int64_t _res_conv_8 = _res_vals[i];
26823                 LDKFuture _res_conv_8_conv;
26824                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
26825                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
26826                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
26827                 _res_constr.data[i] = _res_conv_8_conv;
26828         }
26829         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26830         CVec_FutureZ_free(_res_constr);
26831 }
26832
26833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
26834         void* o_ptr = untag_ptr(o);
26835         CHECK_ACCESS(o_ptr);
26836         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
26837         if (o_conv.free == LDKFilter_JCalls_free) {
26838                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26839                 LDKFilter_JCalls_cloned(&o_conv);
26840         }
26841         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
26842         *ret_copy = COption_FilterZ_some(o_conv);
26843         int64_t ret_ref = tag_ptr(ret_copy, true);
26844         return ret_ref;
26845 }
26846
26847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
26848         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
26849         *ret_copy = COption_FilterZ_none();
26850         int64_t ret_ref = tag_ptr(ret_copy, true);
26851         return ret_ref;
26852 }
26853
26854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26855         if (!ptr_is_owned(_res)) return;
26856         void* _res_ptr = untag_ptr(_res);
26857         CHECK_ACCESS(_res_ptr);
26858         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
26859         FREE(untag_ptr(_res));
26860         COption_FilterZ_free(_res_conv);
26861 }
26862
26863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
26864         LDKLockedChannelMonitor o_conv;
26865         o_conv.inner = untag_ptr(o);
26866         o_conv.is_owned = ptr_is_owned(o);
26867         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26868         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
26869         
26870         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
26871         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
26872         return tag_ptr(ret_conv, true);
26873 }
26874
26875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
26876         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
26877         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
26878         return tag_ptr(ret_conv, true);
26879 }
26880
26881 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
26882         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
26883         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
26884         return ret_conv;
26885 }
26886
26887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26888         if (!ptr_is_owned(_res)) return;
26889         void* _res_ptr = untag_ptr(_res);
26890         CHECK_ACCESS(_res_ptr);
26891         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
26892         FREE(untag_ptr(_res));
26893         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
26894 }
26895
26896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26897         LDKCVec_OutPointZ _res_constr;
26898         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26899         if (_res_constr.datalen > 0)
26900                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
26901         else
26902                 _res_constr.data = NULL;
26903         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26904         for (size_t k = 0; k < _res_constr.datalen; k++) {
26905                 int64_t _res_conv_10 = _res_vals[k];
26906                 LDKOutPoint _res_conv_10_conv;
26907                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
26908                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
26909                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
26910                 _res_constr.data[k] = _res_conv_10_conv;
26911         }
26912         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26913         CVec_OutPointZ_free(_res_constr);
26914 }
26915
26916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorUpdateIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26917         LDKCVec_MonitorUpdateIdZ _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(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
26921         else
26922                 _res_constr.data = NULL;
26923         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26924         for (size_t r = 0; r < _res_constr.datalen; r++) {
26925                 int64_t _res_conv_17 = _res_vals[r];
26926                 LDKMonitorUpdateId _res_conv_17_conv;
26927                 _res_conv_17_conv.inner = untag_ptr(_res_conv_17);
26928                 _res_conv_17_conv.is_owned = ptr_is_owned(_res_conv_17);
26929                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_17_conv);
26930                 _res_constr.data[r] = _res_conv_17_conv;
26931         }
26932         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
26933         CVec_MonitorUpdateIdZ_free(_res_constr);
26934 }
26935
26936 static inline uint64_t C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR arg) {
26937         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26938         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(arg);
26939         return tag_ptr(ret_conv, true);
26940 }
26941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26942         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(arg);
26943         int64_t ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(arg_conv);
26944         return ret_conv;
26945 }
26946
26947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26948         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(orig);
26949         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26950         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(orig_conv);
26951         return tag_ptr(ret_conv, true);
26952 }
26953
26954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b) {
26955         LDKOutPoint a_conv;
26956         a_conv.inner = untag_ptr(a);
26957         a_conv.is_owned = ptr_is_owned(a);
26958         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26959         a_conv = OutPoint_clone(&a_conv);
26960         LDKCVec_MonitorUpdateIdZ b_constr;
26961         b_constr.datalen = (*env)->GetArrayLength(env, b);
26962         if (b_constr.datalen > 0)
26963                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
26964         else
26965                 b_constr.data = NULL;
26966         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
26967         for (size_t r = 0; r < b_constr.datalen; r++) {
26968                 int64_t b_conv_17 = b_vals[r];
26969                 LDKMonitorUpdateId b_conv_17_conv;
26970                 b_conv_17_conv.inner = untag_ptr(b_conv_17);
26971                 b_conv_17_conv.is_owned = ptr_is_owned(b_conv_17);
26972                 CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv_17_conv);
26973                 b_conv_17_conv = MonitorUpdateId_clone(&b_conv_17_conv);
26974                 b_constr.data[r] = b_conv_17_conv;
26975         }
26976         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
26977         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
26978         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(a_conv, b_constr);
26979         return tag_ptr(ret_conv, true);
26980 }
26981
26982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
26983         if (!ptr_is_owned(_res)) return;
26984         void* _res_ptr = untag_ptr(_res);
26985         CHECK_ACCESS(_res_ptr);
26986         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_ptr);
26987         FREE(untag_ptr(_res));
26988         C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(_res_conv);
26989 }
26990
26991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1OutPointCVec_1MonitorUpdateIdZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
26992         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res_constr;
26993         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
26994         if (_res_constr.datalen > 0)
26995                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ Elements");
26996         else
26997                 _res_constr.data = NULL;
26998         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
26999         for (size_t p = 0; p < _res_constr.datalen; p++) {
27000                 int64_t _res_conv_41 = _res_vals[p];
27001                 void* _res_conv_41_ptr = untag_ptr(_res_conv_41);
27002                 CHECK_ACCESS(_res_conv_41_ptr);
27003                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv_41_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_conv_41_ptr);
27004                 FREE(untag_ptr(_res_conv_41));
27005                 _res_constr.data[p] = _res_conv_41_conv;
27006         }
27007         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
27008         CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(_res_constr);
27009 }
27010
27011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
27012         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
27013         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
27014         return tag_ptr(ret_conv, true);
27015 }
27016
27017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
27018         void* e_ptr = untag_ptr(e);
27019         CHECK_ACCESS(e_ptr);
27020         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
27021         e_conv = GraphSyncError_clone((LDKGraphSyncError*)untag_ptr(e));
27022         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
27023         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
27024         return tag_ptr(ret_conv, true);
27025 }
27026
27027 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
27028         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(o);
27029         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
27030         return ret_conv;
27031 }
27032
27033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
27034         if (!ptr_is_owned(_res)) return;
27035         void* _res_ptr = untag_ptr(_res);
27036         CHECK_ACCESS(_res_ptr);
27037         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
27038         FREE(untag_ptr(_res));
27039         CResult_u32GraphSyncErrorZ_free(_res_conv);
27040 }
27041
27042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27043         if (!ptr_is_owned(this_ptr)) return;
27044         void* this_ptr_ptr = untag_ptr(this_ptr);
27045         CHECK_ACCESS(this_ptr_ptr);
27046         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
27047         FREE(untag_ptr(this_ptr));
27048         APIError_free(this_ptr_conv);
27049 }
27050
27051 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
27052         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27053         *ret_copy = APIError_clone(arg);
27054         int64_t ret_ref = tag_ptr(ret_copy, true);
27055         return ret_ref;
27056 }
27057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27058         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
27059         int64_t ret_conv = APIError_clone_ptr(arg_conv);
27060         return ret_conv;
27061 }
27062
27063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27064         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
27065         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27066         *ret_copy = APIError_clone(orig_conv);
27067         int64_t ret_ref = tag_ptr(ret_copy, true);
27068         return ret_ref;
27069 }
27070
27071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
27072         LDKStr err_conv = java_to_owned_str(env, err);
27073         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27074         *ret_copy = APIError_apimisuse_error(err_conv);
27075         int64_t ret_ref = tag_ptr(ret_copy, true);
27076         return ret_ref;
27077 }
27078
27079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
27080         LDKStr err_conv = java_to_owned_str(env, err);
27081         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27082         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
27083         int64_t ret_ref = tag_ptr(ret_copy, true);
27084         return ret_ref;
27085 }
27086
27087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1invalid_1route(JNIEnv *env, jclass clz, jstring err) {
27088         LDKStr err_conv = java_to_owned_str(env, err);
27089         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27090         *ret_copy = APIError_invalid_route(err_conv);
27091         int64_t ret_ref = tag_ptr(ret_copy, true);
27092         return ret_ref;
27093 }
27094
27095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
27096         LDKStr err_conv = java_to_owned_str(env, err);
27097         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27098         *ret_copy = APIError_channel_unavailable(err_conv);
27099         int64_t ret_ref = tag_ptr(ret_copy, true);
27100         return ret_ref;
27101 }
27102
27103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1in_1progress(JNIEnv *env, jclass clz) {
27104         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27105         *ret_copy = APIError_monitor_update_in_progress();
27106         int64_t ret_ref = tag_ptr(ret_copy, true);
27107         return ret_ref;
27108 }
27109
27110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
27111         LDKShutdownScript script_conv;
27112         script_conv.inner = untag_ptr(script);
27113         script_conv.is_owned = ptr_is_owned(script);
27114         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
27115         script_conv = ShutdownScript_clone(&script_conv);
27116         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27117         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
27118         int64_t ret_ref = tag_ptr(ret_copy, true);
27119         return ret_ref;
27120 }
27121
27122 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_APIError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27123         LDKAPIError* a_conv = (LDKAPIError*)untag_ptr(a);
27124         LDKAPIError* b_conv = (LDKAPIError*)untag_ptr(b);
27125         jboolean ret_conv = APIError_eq(a_conv, b_conv);
27126         return ret_conv;
27127 }
27128
27129 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_APIError_1write(JNIEnv *env, jclass clz, int64_t obj) {
27130         LDKAPIError* obj_conv = (LDKAPIError*)untag_ptr(obj);
27131         LDKCVec_u8Z ret_var = APIError_write(obj_conv);
27132         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27133         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27134         CVec_u8Z_free(ret_var);
27135         return ret_arr;
27136 }
27137
27138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27139         LDKu8slice ser_ref;
27140         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27141         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27142         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
27143         *ret_conv = APIError_read(ser_ref);
27144         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27145         return tag_ptr(ret_conv, true);
27146 }
27147
27148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27149         LDKBigSize this_obj_conv;
27150         this_obj_conv.inner = untag_ptr(this_obj);
27151         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27153         BigSize_free(this_obj_conv);
27154 }
27155
27156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27157         LDKBigSize this_ptr_conv;
27158         this_ptr_conv.inner = untag_ptr(this_ptr);
27159         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27161         this_ptr_conv.is_owned = false;
27162         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
27163         return ret_conv;
27164 }
27165
27166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27167         LDKBigSize this_ptr_conv;
27168         this_ptr_conv.inner = untag_ptr(this_ptr);
27169         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27171         this_ptr_conv.is_owned = false;
27172         BigSize_set_a(&this_ptr_conv, val);
27173 }
27174
27175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
27176         LDKBigSize ret_var = BigSize_new(a_arg);
27177         int64_t ret_ref = 0;
27178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27179         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27180         return ret_ref;
27181 }
27182
27183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27184         LDKHostname this_obj_conv;
27185         this_obj_conv.inner = untag_ptr(this_obj);
27186         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27188         Hostname_free(this_obj_conv);
27189 }
27190
27191 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
27192         LDKHostname ret_var = Hostname_clone(arg);
27193         int64_t ret_ref = 0;
27194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27195         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27196         return ret_ref;
27197 }
27198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27199         LDKHostname arg_conv;
27200         arg_conv.inner = untag_ptr(arg);
27201         arg_conv.is_owned = ptr_is_owned(arg);
27202         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27203         arg_conv.is_owned = false;
27204         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
27205         return ret_conv;
27206 }
27207
27208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27209         LDKHostname orig_conv;
27210         orig_conv.inner = untag_ptr(orig);
27211         orig_conv.is_owned = ptr_is_owned(orig);
27212         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27213         orig_conv.is_owned = false;
27214         LDKHostname ret_var = Hostname_clone(&orig_conv);
27215         int64_t ret_ref = 0;
27216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27217         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27218         return ret_ref;
27219 }
27220
27221 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Hostname_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27222         LDKHostname a_conv;
27223         a_conv.inner = untag_ptr(a);
27224         a_conv.is_owned = ptr_is_owned(a);
27225         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27226         a_conv.is_owned = false;
27227         LDKHostname b_conv;
27228         b_conv.inner = untag_ptr(b);
27229         b_conv.is_owned = ptr_is_owned(b);
27230         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27231         b_conv.is_owned = false;
27232         jboolean ret_conv = Hostname_eq(&a_conv, &b_conv);
27233         return ret_conv;
27234 }
27235
27236 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
27237         LDKHostname this_arg_conv;
27238         this_arg_conv.inner = untag_ptr(this_arg);
27239         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27241         this_arg_conv.is_owned = false;
27242         int8_t ret_conv = Hostname_len(&this_arg_conv);
27243         return ret_conv;
27244 }
27245
27246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
27247         LDKu8slice msg_ref;
27248         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27249         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27250         uint8_t sk_arr[32];
27251         CHECK((*env)->GetArrayLength(env, sk) == 32);
27252         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
27253         uint8_t (*sk_ref)[32] = &sk_arr;
27254         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
27255         *ret_conv = sign(msg_ref, sk_ref);
27256         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27257         return tag_ptr(ret_conv, true);
27258 }
27259
27260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
27261         LDKu8slice msg_ref;
27262         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27263         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27264         LDKStr sig_conv = java_to_owned_str(env, sig);
27265         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
27266         *ret_conv = recover_pk(msg_ref, sig_conv);
27267         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27268         return tag_ptr(ret_conv, true);
27269 }
27270
27271 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
27272         LDKu8slice msg_ref;
27273         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27274         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27275         LDKStr sig_conv = java_to_owned_str(env, sig);
27276         LDKPublicKey pk_ref;
27277         CHECK((*env)->GetArrayLength(env, pk) == 33);
27278         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
27279         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
27280         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27281         return ret_conv;
27282 }
27283
27284 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
27285         LDKu8slice hrp_bytes_ref;
27286         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
27287         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
27288         LDKCVec_U5Z data_without_signature_constr;
27289         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
27290         if (data_without_signature_constr.datalen > 0)
27291                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
27292         else
27293                 data_without_signature_constr.data = NULL;
27294         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
27295         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
27296                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
27297                 
27298                 data_without_signature_constr.data[h] = (LDKU5){ ._0 = data_without_signature_conv_7 };
27299         }
27300         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
27301         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
27302         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27303         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27304         CVec_u8Z_free(ret_var);
27305         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
27306         return ret_arr;
27307 }
27308
27309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27310         if (!ptr_is_owned(this_ptr)) return;
27311         void* this_ptr_ptr = untag_ptr(this_ptr);
27312         CHECK_ACCESS(this_ptr_ptr);
27313         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
27314         FREE(untag_ptr(this_ptr));
27315         Persister_free(this_ptr_conv);
27316 }
27317
27318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UntrustedString_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27319         LDKUntrustedString this_obj_conv;
27320         this_obj_conv.inner = untag_ptr(this_obj);
27321         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27323         UntrustedString_free(this_obj_conv);
27324 }
27325
27326 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_UntrustedString_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27327         LDKUntrustedString this_ptr_conv;
27328         this_ptr_conv.inner = untag_ptr(this_ptr);
27329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27331         this_ptr_conv.is_owned = false;
27332         LDKStr ret_str = UntrustedString_get_a(&this_ptr_conv);
27333         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27334         Str_free(ret_str);
27335         return ret_conv;
27336 }
27337
27338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UntrustedString_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27339         LDKUntrustedString this_ptr_conv;
27340         this_ptr_conv.inner = untag_ptr(this_ptr);
27341         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27343         this_ptr_conv.is_owned = false;
27344         LDKStr val_conv = java_to_owned_str(env, val);
27345         UntrustedString_set_a(&this_ptr_conv, val_conv);
27346 }
27347
27348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1new(JNIEnv *env, jclass clz, jstring a_arg) {
27349         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
27350         LDKUntrustedString ret_var = UntrustedString_new(a_arg_conv);
27351         int64_t ret_ref = 0;
27352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27353         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27354         return ret_ref;
27355 }
27356
27357 static inline uint64_t UntrustedString_clone_ptr(LDKUntrustedString *NONNULL_PTR arg) {
27358         LDKUntrustedString ret_var = UntrustedString_clone(arg);
27359         int64_t ret_ref = 0;
27360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27361         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27362         return ret_ref;
27363 }
27364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27365         LDKUntrustedString arg_conv;
27366         arg_conv.inner = untag_ptr(arg);
27367         arg_conv.is_owned = ptr_is_owned(arg);
27368         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27369         arg_conv.is_owned = false;
27370         int64_t ret_conv = UntrustedString_clone_ptr(&arg_conv);
27371         return ret_conv;
27372 }
27373
27374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27375         LDKUntrustedString orig_conv;
27376         orig_conv.inner = untag_ptr(orig);
27377         orig_conv.is_owned = ptr_is_owned(orig);
27378         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27379         orig_conv.is_owned = false;
27380         LDKUntrustedString ret_var = UntrustedString_clone(&orig_conv);
27381         int64_t ret_ref = 0;
27382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27383         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27384         return ret_ref;
27385 }
27386
27387 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UntrustedString_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27388         LDKUntrustedString a_conv;
27389         a_conv.inner = untag_ptr(a);
27390         a_conv.is_owned = ptr_is_owned(a);
27391         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27392         a_conv.is_owned = false;
27393         LDKUntrustedString b_conv;
27394         b_conv.inner = untag_ptr(b);
27395         b_conv.is_owned = ptr_is_owned(b);
27396         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27397         b_conv.is_owned = false;
27398         jboolean ret_conv = UntrustedString_eq(&a_conv, &b_conv);
27399         return ret_conv;
27400 }
27401
27402 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UntrustedString_1write(JNIEnv *env, jclass clz, int64_t obj) {
27403         LDKUntrustedString obj_conv;
27404         obj_conv.inner = untag_ptr(obj);
27405         obj_conv.is_owned = ptr_is_owned(obj);
27406         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27407         obj_conv.is_owned = false;
27408         LDKCVec_u8Z ret_var = UntrustedString_write(&obj_conv);
27409         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27410         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27411         CVec_u8Z_free(ret_var);
27412         return ret_arr;
27413 }
27414
27415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UntrustedString_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27416         LDKu8slice ser_ref;
27417         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27418         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27419         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
27420         *ret_conv = UntrustedString_read(ser_ref);
27421         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27422         return tag_ptr(ret_conv, true);
27423 }
27424
27425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27426         LDKPrintableString this_obj_conv;
27427         this_obj_conv.inner = untag_ptr(this_obj);
27428         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27430         PrintableString_free(this_obj_conv);
27431 }
27432
27433 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_PrintableString_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27434         LDKPrintableString this_ptr_conv;
27435         this_ptr_conv.inner = untag_ptr(this_ptr);
27436         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27438         this_ptr_conv.is_owned = false;
27439         LDKStr ret_str = PrintableString_get_a(&this_ptr_conv);
27440         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27441         Str_free(ret_str);
27442         return ret_conv;
27443 }
27444
27445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27446         LDKPrintableString this_ptr_conv;
27447         this_ptr_conv.inner = untag_ptr(this_ptr);
27448         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27450         this_ptr_conv.is_owned = false;
27451         LDKStr val_conv = java_to_owned_str(env, val);
27452         PrintableString_set_a(&this_ptr_conv, val_conv);
27453 }
27454
27455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrintableString_1new(JNIEnv *env, jclass clz, jstring a_arg) {
27456         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
27457         LDKPrintableString ret_var = PrintableString_new(a_arg_conv);
27458         int64_t ret_ref = 0;
27459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27460         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27461         return ret_ref;
27462 }
27463
27464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27465         if (!ptr_is_owned(this_ptr)) return;
27466         void* this_ptr_ptr = untag_ptr(this_ptr);
27467         CHECK_ACCESS(this_ptr_ptr);
27468         LDKFutureCallback this_ptr_conv = *(LDKFutureCallback*)(this_ptr_ptr);
27469         FREE(untag_ptr(this_ptr));
27470         FutureCallback_free(this_ptr_conv);
27471 }
27472
27473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27474         LDKFuture this_obj_conv;
27475         this_obj_conv.inner = untag_ptr(this_obj);
27476         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27478         Future_free(this_obj_conv);
27479 }
27480
27481 static inline uint64_t Future_clone_ptr(LDKFuture *NONNULL_PTR arg) {
27482         LDKFuture ret_var = Future_clone(arg);
27483         int64_t ret_ref = 0;
27484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27485         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27486         return ret_ref;
27487 }
27488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Future_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27489         LDKFuture arg_conv;
27490         arg_conv.inner = untag_ptr(arg);
27491         arg_conv.is_owned = ptr_is_owned(arg);
27492         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27493         arg_conv.is_owned = false;
27494         int64_t ret_conv = Future_clone_ptr(&arg_conv);
27495         return ret_conv;
27496 }
27497
27498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Future_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27499         LDKFuture orig_conv;
27500         orig_conv.inner = untag_ptr(orig);
27501         orig_conv.is_owned = ptr_is_owned(orig);
27502         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27503         orig_conv.is_owned = false;
27504         LDKFuture ret_var = Future_clone(&orig_conv);
27505         int64_t ret_ref = 0;
27506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27507         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27508         return ret_ref;
27509 }
27510
27511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1register_1callback_1fn(JNIEnv *env, jclass clz, int64_t this_arg, int64_t callback) {
27512         LDKFuture this_arg_conv;
27513         this_arg_conv.inner = untag_ptr(this_arg);
27514         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27516         this_arg_conv.is_owned = false;
27517         void* callback_ptr = untag_ptr(callback);
27518         CHECK_ACCESS(callback_ptr);
27519         LDKFutureCallback callback_conv = *(LDKFutureCallback*)(callback_ptr);
27520         if (callback_conv.free == LDKFutureCallback_JCalls_free) {
27521                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27522                 LDKFutureCallback_JCalls_cloned(&callback_conv);
27523         }
27524         Future_register_callback_fn(&this_arg_conv, callback_conv);
27525 }
27526
27527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1wait(JNIEnv *env, jclass clz, int64_t this_arg) {
27528         LDKFuture this_arg_conv;
27529         this_arg_conv.inner = untag_ptr(this_arg);
27530         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27532         this_arg_conv = Future_clone(&this_arg_conv);
27533         Future_wait(this_arg_conv);
27534 }
27535
27536 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Future_1wait_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
27537         LDKFuture this_arg_conv;
27538         this_arg_conv.inner = untag_ptr(this_arg);
27539         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27541         this_arg_conv = Future_clone(&this_arg_conv);
27542         jboolean ret_conv = Future_wait_timeout(this_arg_conv, max_wait);
27543         return ret_conv;
27544 }
27545
27546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sleeper_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27547         LDKSleeper this_obj_conv;
27548         this_obj_conv.inner = untag_ptr(this_obj);
27549         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27551         Sleeper_free(this_obj_conv);
27552 }
27553
27554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sleeper_1from_1single_1future(JNIEnv *env, jclass clz, int64_t future) {
27555         LDKFuture future_conv;
27556         future_conv.inner = untag_ptr(future);
27557         future_conv.is_owned = ptr_is_owned(future);
27558         CHECK_INNER_FIELD_ACCESS_OR_NULL(future_conv);
27559         future_conv = Future_clone(&future_conv);
27560         LDKSleeper ret_var = Sleeper_from_single_future(future_conv);
27561         int64_t ret_ref = 0;
27562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27563         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27564         return ret_ref;
27565 }
27566
27567 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) {
27568         LDKFuture fut_a_conv;
27569         fut_a_conv.inner = untag_ptr(fut_a);
27570         fut_a_conv.is_owned = ptr_is_owned(fut_a);
27571         CHECK_INNER_FIELD_ACCESS_OR_NULL(fut_a_conv);
27572         fut_a_conv = Future_clone(&fut_a_conv);
27573         LDKFuture fut_b_conv;
27574         fut_b_conv.inner = untag_ptr(fut_b);
27575         fut_b_conv.is_owned = ptr_is_owned(fut_b);
27576         CHECK_INNER_FIELD_ACCESS_OR_NULL(fut_b_conv);
27577         fut_b_conv = Future_clone(&fut_b_conv);
27578         LDKSleeper ret_var = Sleeper_from_two_futures(fut_a_conv, fut_b_conv);
27579         int64_t ret_ref = 0;
27580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27581         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27582         return ret_ref;
27583 }
27584
27585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sleeper_1new(JNIEnv *env, jclass clz, int64_tArray futures) {
27586         LDKCVec_FutureZ futures_constr;
27587         futures_constr.datalen = (*env)->GetArrayLength(env, futures);
27588         if (futures_constr.datalen > 0)
27589                 futures_constr.data = MALLOC(futures_constr.datalen * sizeof(LDKFuture), "LDKCVec_FutureZ Elements");
27590         else
27591                 futures_constr.data = NULL;
27592         int64_t* futures_vals = (*env)->GetLongArrayElements (env, futures, NULL);
27593         for (size_t i = 0; i < futures_constr.datalen; i++) {
27594                 int64_t futures_conv_8 = futures_vals[i];
27595                 LDKFuture futures_conv_8_conv;
27596                 futures_conv_8_conv.inner = untag_ptr(futures_conv_8);
27597                 futures_conv_8_conv.is_owned = ptr_is_owned(futures_conv_8);
27598                 CHECK_INNER_FIELD_ACCESS_OR_NULL(futures_conv_8_conv);
27599                 futures_conv_8_conv = Future_clone(&futures_conv_8_conv);
27600                 futures_constr.data[i] = futures_conv_8_conv;
27601         }
27602         (*env)->ReleaseLongArrayElements(env, futures, futures_vals, 0);
27603         LDKSleeper ret_var = Sleeper_new(futures_constr);
27604         int64_t ret_ref = 0;
27605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27606         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27607         return ret_ref;
27608 }
27609
27610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sleeper_1wait(JNIEnv *env, jclass clz, int64_t this_arg) {
27611         LDKSleeper this_arg_conv;
27612         this_arg_conv.inner = untag_ptr(this_arg);
27613         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27615         this_arg_conv.is_owned = false;
27616         Sleeper_wait(&this_arg_conv);
27617 }
27618
27619 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sleeper_1wait_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
27620         LDKSleeper this_arg_conv;
27621         this_arg_conv.inner = untag_ptr(this_arg);
27622         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27624         this_arg_conv.is_owned = false;
27625         jboolean ret_conv = Sleeper_wait_timeout(&this_arg_conv, max_wait);
27626         return ret_conv;
27627 }
27628
27629 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27630         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
27631         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
27632         return ret_conv;
27633 }
27634
27635 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
27636         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
27637         return ret_conv;
27638 }
27639
27640 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
27641         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
27642         return ret_conv;
27643 }
27644
27645 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
27646         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
27647         return ret_conv;
27648 }
27649
27650 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
27651         jclass ret_conv = LDKLevel_to_java(env, Level_info());
27652         return ret_conv;
27653 }
27654
27655 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
27656         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
27657         return ret_conv;
27658 }
27659
27660 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
27661         jclass ret_conv = LDKLevel_to_java(env, Level_error());
27662         return ret_conv;
27663 }
27664
27665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27666         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
27667         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
27668         jboolean ret_conv = Level_eq(a_conv, b_conv);
27669         return ret_conv;
27670 }
27671
27672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
27673         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
27674         int64_t ret_conv = Level_hash(o_conv);
27675         return ret_conv;
27676 }
27677
27678 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
27679         jclass ret_conv = LDKLevel_to_java(env, Level_max());
27680         return ret_conv;
27681 }
27682
27683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27684         LDKRecord this_obj_conv;
27685         this_obj_conv.inner = untag_ptr(this_obj);
27686         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27688         Record_free(this_obj_conv);
27689 }
27690
27691 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
27692         LDKRecord this_ptr_conv;
27693         this_ptr_conv.inner = untag_ptr(this_ptr);
27694         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27696         this_ptr_conv.is_owned = false;
27697         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
27698         return ret_conv;
27699 }
27700
27701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
27702         LDKRecord this_ptr_conv;
27703         this_ptr_conv.inner = untag_ptr(this_ptr);
27704         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27706         this_ptr_conv.is_owned = false;
27707         LDKLevel val_conv = LDKLevel_from_java(env, val);
27708         Record_set_level(&this_ptr_conv, val_conv);
27709 }
27710
27711 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(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         LDKStr ret_str = Record_get_args(&this_ptr_conv);
27718         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27719         Str_free(ret_str);
27720         return ret_conv;
27721 }
27722
27723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27724         LDKRecord this_ptr_conv;
27725         this_ptr_conv.inner = untag_ptr(this_ptr);
27726         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27728         this_ptr_conv.is_owned = false;
27729         LDKStr val_conv = java_to_owned_str(env, val);
27730         Record_set_args(&this_ptr_conv, val_conv);
27731 }
27732
27733 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
27734         LDKRecord this_ptr_conv;
27735         this_ptr_conv.inner = untag_ptr(this_ptr);
27736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27738         this_ptr_conv.is_owned = false;
27739         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
27740         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27741         Str_free(ret_str);
27742         return ret_conv;
27743 }
27744
27745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27746         LDKRecord this_ptr_conv;
27747         this_ptr_conv.inner = untag_ptr(this_ptr);
27748         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27750         this_ptr_conv.is_owned = false;
27751         LDKStr val_conv = java_to_owned_str(env, val);
27752         Record_set_module_path(&this_ptr_conv, val_conv);
27753 }
27754
27755 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
27756         LDKRecord this_ptr_conv;
27757         this_ptr_conv.inner = untag_ptr(this_ptr);
27758         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27760         this_ptr_conv.is_owned = false;
27761         LDKStr ret_str = Record_get_file(&this_ptr_conv);
27762         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27763         Str_free(ret_str);
27764         return ret_conv;
27765 }
27766
27767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27768         LDKRecord this_ptr_conv;
27769         this_ptr_conv.inner = untag_ptr(this_ptr);
27770         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27772         this_ptr_conv.is_owned = false;
27773         LDKStr val_conv = java_to_owned_str(env, val);
27774         Record_set_file(&this_ptr_conv, val_conv);
27775 }
27776
27777 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
27778         LDKRecord this_ptr_conv;
27779         this_ptr_conv.inner = untag_ptr(this_ptr);
27780         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27782         this_ptr_conv.is_owned = false;
27783         int32_t ret_conv = Record_get_line(&this_ptr_conv);
27784         return ret_conv;
27785 }
27786
27787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t 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         Record_set_line(&this_ptr_conv, val);
27794 }
27795
27796 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
27797         LDKRecord ret_var = Record_clone(arg);
27798         int64_t ret_ref = 0;
27799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27800         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27801         return ret_ref;
27802 }
27803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27804         LDKRecord arg_conv;
27805         arg_conv.inner = untag_ptr(arg);
27806         arg_conv.is_owned = ptr_is_owned(arg);
27807         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27808         arg_conv.is_owned = false;
27809         int64_t ret_conv = Record_clone_ptr(&arg_conv);
27810         return ret_conv;
27811 }
27812
27813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27814         LDKRecord orig_conv;
27815         orig_conv.inner = untag_ptr(orig);
27816         orig_conv.is_owned = ptr_is_owned(orig);
27817         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27818         orig_conv.is_owned = false;
27819         LDKRecord ret_var = Record_clone(&orig_conv);
27820         int64_t ret_ref = 0;
27821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27822         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27823         return ret_ref;
27824 }
27825
27826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27827         if (!ptr_is_owned(this_ptr)) return;
27828         void* this_ptr_ptr = untag_ptr(this_ptr);
27829         CHECK_ACCESS(this_ptr_ptr);
27830         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
27831         FREE(untag_ptr(this_ptr));
27832         Logger_free(this_ptr_conv);
27833 }
27834
27835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27836         LDKChannelHandshakeConfig this_obj_conv;
27837         this_obj_conv.inner = untag_ptr(this_obj);
27838         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27840         ChannelHandshakeConfig_free(this_obj_conv);
27841 }
27842
27843 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
27844         LDKChannelHandshakeConfig this_ptr_conv;
27845         this_ptr_conv.inner = untag_ptr(this_ptr);
27846         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27848         this_ptr_conv.is_owned = false;
27849         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
27850         return ret_conv;
27851 }
27852
27853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27854         LDKChannelHandshakeConfig this_ptr_conv;
27855         this_ptr_conv.inner = untag_ptr(this_ptr);
27856         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27858         this_ptr_conv.is_owned = false;
27859         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
27860 }
27861
27862 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27863         LDKChannelHandshakeConfig this_ptr_conv;
27864         this_ptr_conv.inner = untag_ptr(this_ptr);
27865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27867         this_ptr_conv.is_owned = false;
27868         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
27869         return ret_conv;
27870 }
27871
27872 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) {
27873         LDKChannelHandshakeConfig this_ptr_conv;
27874         this_ptr_conv.inner = untag_ptr(this_ptr);
27875         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27877         this_ptr_conv.is_owned = false;
27878         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
27879 }
27880
27881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27882         LDKChannelHandshakeConfig this_ptr_conv;
27883         this_ptr_conv.inner = untag_ptr(this_ptr);
27884         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27886         this_ptr_conv.is_owned = false;
27887         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
27888         return ret_conv;
27889 }
27890
27891 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) {
27892         LDKChannelHandshakeConfig this_ptr_conv;
27893         this_ptr_conv.inner = untag_ptr(this_ptr);
27894         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27896         this_ptr_conv.is_owned = false;
27897         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
27898 }
27899
27900 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) {
27901         LDKChannelHandshakeConfig this_ptr_conv;
27902         this_ptr_conv.inner = untag_ptr(this_ptr);
27903         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27905         this_ptr_conv.is_owned = false;
27906         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
27907         return ret_conv;
27908 }
27909
27910 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) {
27911         LDKChannelHandshakeConfig this_ptr_conv;
27912         this_ptr_conv.inner = untag_ptr(this_ptr);
27913         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27915         this_ptr_conv.is_owned = false;
27916         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
27917 }
27918
27919 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
27920         LDKChannelHandshakeConfig this_ptr_conv;
27921         this_ptr_conv.inner = untag_ptr(this_ptr);
27922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27924         this_ptr_conv.is_owned = false;
27925         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
27926         return ret_conv;
27927 }
27928
27929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27930         LDKChannelHandshakeConfig this_ptr_conv;
27931         this_ptr_conv.inner = untag_ptr(this_ptr);
27932         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27934         this_ptr_conv.is_owned = false;
27935         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
27936 }
27937
27938 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
27939         LDKChannelHandshakeConfig this_ptr_conv;
27940         this_ptr_conv.inner = untag_ptr(this_ptr);
27941         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27943         this_ptr_conv.is_owned = false;
27944         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
27945         return ret_conv;
27946 }
27947
27948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27949         LDKChannelHandshakeConfig this_ptr_conv;
27950         this_ptr_conv.inner = untag_ptr(this_ptr);
27951         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27953         this_ptr_conv.is_owned = false;
27954         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
27955 }
27956
27957 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27958         LDKChannelHandshakeConfig this_ptr_conv;
27959         this_ptr_conv.inner = untag_ptr(this_ptr);
27960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27962         this_ptr_conv.is_owned = false;
27963         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
27964         return ret_conv;
27965 }
27966
27967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27968         LDKChannelHandshakeConfig this_ptr_conv;
27969         this_ptr_conv.inner = untag_ptr(this_ptr);
27970         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27972         this_ptr_conv.is_owned = false;
27973         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
27974 }
27975
27976 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1their_1channel_1reserve_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27977         LDKChannelHandshakeConfig this_ptr_conv;
27978         this_ptr_conv.inner = untag_ptr(this_ptr);
27979         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27981         this_ptr_conv.is_owned = false;
27982         int32_t ret_conv = ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(&this_ptr_conv);
27983         return ret_conv;
27984 }
27985
27986 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) {
27987         LDKChannelHandshakeConfig this_ptr_conv;
27988         this_ptr_conv.inner = untag_ptr(this_ptr);
27989         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27991         this_ptr_conv.is_owned = false;
27992         ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(&this_ptr_conv, val);
27993 }
27994
27995 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
27996         LDKChannelHandshakeConfig this_ptr_conv;
27997         this_ptr_conv.inner = untag_ptr(this_ptr);
27998         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28000         this_ptr_conv.is_owned = false;
28001         int16_t ret_conv = ChannelHandshakeConfig_get_our_max_accepted_htlcs(&this_ptr_conv);
28002         return ret_conv;
28003 }
28004
28005 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) {
28006         LDKChannelHandshakeConfig this_ptr_conv;
28007         this_ptr_conv.inner = untag_ptr(this_ptr);
28008         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28010         this_ptr_conv.is_owned = false;
28011         ChannelHandshakeConfig_set_our_max_accepted_htlcs(&this_ptr_conv, val);
28012 }
28013
28014 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) {
28015         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);
28016         int64_t ret_ref = 0;
28017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28019         return ret_ref;
28020 }
28021
28022 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
28023         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
28024         int64_t ret_ref = 0;
28025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28026         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28027         return ret_ref;
28028 }
28029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28030         LDKChannelHandshakeConfig arg_conv;
28031         arg_conv.inner = untag_ptr(arg);
28032         arg_conv.is_owned = ptr_is_owned(arg);
28033         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28034         arg_conv.is_owned = false;
28035         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
28036         return ret_conv;
28037 }
28038
28039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28040         LDKChannelHandshakeConfig orig_conv;
28041         orig_conv.inner = untag_ptr(orig);
28042         orig_conv.is_owned = ptr_is_owned(orig);
28043         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28044         orig_conv.is_owned = false;
28045         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
28046         int64_t ret_ref = 0;
28047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28048         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28049         return ret_ref;
28050 }
28051
28052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
28053         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
28054         int64_t ret_ref = 0;
28055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28056         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28057         return ret_ref;
28058 }
28059
28060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28061         LDKChannelHandshakeLimits this_obj_conv;
28062         this_obj_conv.inner = untag_ptr(this_obj);
28063         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28065         ChannelHandshakeLimits_free(this_obj_conv);
28066 }
28067
28068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28069         LDKChannelHandshakeLimits this_ptr_conv;
28070         this_ptr_conv.inner = untag_ptr(this_ptr);
28071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28073         this_ptr_conv.is_owned = false;
28074         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
28075         return ret_conv;
28076 }
28077
28078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28079         LDKChannelHandshakeLimits this_ptr_conv;
28080         this_ptr_conv.inner = untag_ptr(this_ptr);
28081         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28083         this_ptr_conv.is_owned = false;
28084         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
28085 }
28086
28087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28088         LDKChannelHandshakeLimits this_ptr_conv;
28089         this_ptr_conv.inner = untag_ptr(this_ptr);
28090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28092         this_ptr_conv.is_owned = false;
28093         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
28094         return ret_conv;
28095 }
28096
28097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28098         LDKChannelHandshakeLimits this_ptr_conv;
28099         this_ptr_conv.inner = untag_ptr(this_ptr);
28100         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28102         this_ptr_conv.is_owned = false;
28103         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
28104 }
28105
28106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28107         LDKChannelHandshakeLimits this_ptr_conv;
28108         this_ptr_conv.inner = untag_ptr(this_ptr);
28109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28111         this_ptr_conv.is_owned = false;
28112         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
28113         return ret_conv;
28114 }
28115
28116 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) {
28117         LDKChannelHandshakeLimits this_ptr_conv;
28118         this_ptr_conv.inner = untag_ptr(this_ptr);
28119         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28121         this_ptr_conv.is_owned = false;
28122         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
28123 }
28124
28125 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) {
28126         LDKChannelHandshakeLimits this_ptr_conv;
28127         this_ptr_conv.inner = untag_ptr(this_ptr);
28128         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28130         this_ptr_conv.is_owned = false;
28131         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
28132         return ret_conv;
28133 }
28134
28135 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) {
28136         LDKChannelHandshakeLimits this_ptr_conv;
28137         this_ptr_conv.inner = untag_ptr(this_ptr);
28138         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28140         this_ptr_conv.is_owned = false;
28141         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28142 }
28143
28144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28145         LDKChannelHandshakeLimits this_ptr_conv;
28146         this_ptr_conv.inner = untag_ptr(this_ptr);
28147         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28149         this_ptr_conv.is_owned = false;
28150         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
28151         return ret_conv;
28152 }
28153
28154 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) {
28155         LDKChannelHandshakeLimits this_ptr_conv;
28156         this_ptr_conv.inner = untag_ptr(this_ptr);
28157         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28159         this_ptr_conv.is_owned = false;
28160         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
28161 }
28162
28163 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28164         LDKChannelHandshakeLimits this_ptr_conv;
28165         this_ptr_conv.inner = untag_ptr(this_ptr);
28166         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28168         this_ptr_conv.is_owned = false;
28169         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
28170         return ret_conv;
28171 }
28172
28173 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) {
28174         LDKChannelHandshakeLimits this_ptr_conv;
28175         this_ptr_conv.inner = untag_ptr(this_ptr);
28176         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28178         this_ptr_conv.is_owned = false;
28179         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
28180 }
28181
28182 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
28183         LDKChannelHandshakeLimits this_ptr_conv;
28184         this_ptr_conv.inner = untag_ptr(this_ptr);
28185         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28187         this_ptr_conv.is_owned = false;
28188         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
28189         return ret_conv;
28190 }
28191
28192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28193         LDKChannelHandshakeLimits this_ptr_conv;
28194         this_ptr_conv.inner = untag_ptr(this_ptr);
28195         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28197         this_ptr_conv.is_owned = false;
28198         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
28199 }
28200
28201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
28202         LDKChannelHandshakeLimits this_ptr_conv;
28203         this_ptr_conv.inner = untag_ptr(this_ptr);
28204         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28206         this_ptr_conv.is_owned = false;
28207         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
28208         return ret_conv;
28209 }
28210
28211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28212         LDKChannelHandshakeLimits this_ptr_conv;
28213         this_ptr_conv.inner = untag_ptr(this_ptr);
28214         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28216         this_ptr_conv.is_owned = false;
28217         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
28218 }
28219
28220 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
28221         LDKChannelHandshakeLimits this_ptr_conv;
28222         this_ptr_conv.inner = untag_ptr(this_ptr);
28223         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28225         this_ptr_conv.is_owned = false;
28226         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
28227         return ret_conv;
28228 }
28229
28230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28231         LDKChannelHandshakeLimits this_ptr_conv;
28232         this_ptr_conv.inner = untag_ptr(this_ptr);
28233         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28235         this_ptr_conv.is_owned = false;
28236         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
28237 }
28238
28239 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28240         LDKChannelHandshakeLimits this_ptr_conv;
28241         this_ptr_conv.inner = untag_ptr(this_ptr);
28242         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28244         this_ptr_conv.is_owned = false;
28245         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
28246         return ret_conv;
28247 }
28248
28249 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) {
28250         LDKChannelHandshakeLimits this_ptr_conv;
28251         this_ptr_conv.inner = untag_ptr(this_ptr);
28252         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28254         this_ptr_conv.is_owned = false;
28255         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
28256 }
28257
28258 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) {
28259         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);
28260         int64_t ret_ref = 0;
28261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28262         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28263         return ret_ref;
28264 }
28265
28266 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
28267         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
28268         int64_t ret_ref = 0;
28269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28270         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28271         return ret_ref;
28272 }
28273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28274         LDKChannelHandshakeLimits arg_conv;
28275         arg_conv.inner = untag_ptr(arg);
28276         arg_conv.is_owned = ptr_is_owned(arg);
28277         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28278         arg_conv.is_owned = false;
28279         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
28280         return ret_conv;
28281 }
28282
28283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28284         LDKChannelHandshakeLimits orig_conv;
28285         orig_conv.inner = untag_ptr(orig);
28286         orig_conv.is_owned = ptr_is_owned(orig);
28287         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28288         orig_conv.is_owned = false;
28289         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
28290         int64_t ret_ref = 0;
28291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28292         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28293         return ret_ref;
28294 }
28295
28296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
28297         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
28298         int64_t ret_ref = 0;
28299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28300         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28301         return ret_ref;
28302 }
28303
28304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28305         LDKChannelConfig this_obj_conv;
28306         this_obj_conv.inner = untag_ptr(this_obj);
28307         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28309         ChannelConfig_free(this_obj_conv);
28310 }
28311
28312 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28313         LDKChannelConfig this_ptr_conv;
28314         this_ptr_conv.inner = untag_ptr(this_ptr);
28315         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28317         this_ptr_conv.is_owned = false;
28318         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
28319         return ret_conv;
28320 }
28321
28322 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) {
28323         LDKChannelConfig this_ptr_conv;
28324         this_ptr_conv.inner = untag_ptr(this_ptr);
28325         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28327         this_ptr_conv.is_owned = false;
28328         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
28329 }
28330
28331 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28332         LDKChannelConfig this_ptr_conv;
28333         this_ptr_conv.inner = untag_ptr(this_ptr);
28334         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28336         this_ptr_conv.is_owned = false;
28337         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
28338         return ret_conv;
28339 }
28340
28341 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) {
28342         LDKChannelConfig this_ptr_conv;
28343         this_ptr_conv.inner = untag_ptr(this_ptr);
28344         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28346         this_ptr_conv.is_owned = false;
28347         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
28348 }
28349
28350 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28351         LDKChannelConfig this_ptr_conv;
28352         this_ptr_conv.inner = untag_ptr(this_ptr);
28353         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28355         this_ptr_conv.is_owned = false;
28356         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
28357         return ret_conv;
28358 }
28359
28360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28361         LDKChannelConfig this_ptr_conv;
28362         this_ptr_conv.inner = untag_ptr(this_ptr);
28363         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28365         this_ptr_conv.is_owned = false;
28366         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
28367 }
28368
28369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28370         LDKChannelConfig this_ptr_conv;
28371         this_ptr_conv.inner = untag_ptr(this_ptr);
28372         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28374         this_ptr_conv.is_owned = false;
28375         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
28376         return ret_conv;
28377 }
28378
28379 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) {
28380         LDKChannelConfig this_ptr_conv;
28381         this_ptr_conv.inner = untag_ptr(this_ptr);
28382         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28384         this_ptr_conv.is_owned = false;
28385         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
28386 }
28387
28388 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) {
28389         LDKChannelConfig this_ptr_conv;
28390         this_ptr_conv.inner = untag_ptr(this_ptr);
28391         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28393         this_ptr_conv.is_owned = false;
28394         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
28395         return ret_conv;
28396 }
28397
28398 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) {
28399         LDKChannelConfig this_ptr_conv;
28400         this_ptr_conv.inner = untag_ptr(this_ptr);
28401         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28403         this_ptr_conv.is_owned = false;
28404         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
28405 }
28406
28407 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) {
28408         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);
28409         int64_t ret_ref = 0;
28410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28411         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28412         return ret_ref;
28413 }
28414
28415 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
28416         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
28417         int64_t ret_ref = 0;
28418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28419         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28420         return ret_ref;
28421 }
28422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28423         LDKChannelConfig arg_conv;
28424         arg_conv.inner = untag_ptr(arg);
28425         arg_conv.is_owned = ptr_is_owned(arg);
28426         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28427         arg_conv.is_owned = false;
28428         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
28429         return ret_conv;
28430 }
28431
28432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28433         LDKChannelConfig orig_conv;
28434         orig_conv.inner = untag_ptr(orig);
28435         orig_conv.is_owned = ptr_is_owned(orig);
28436         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28437         orig_conv.is_owned = false;
28438         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
28439         int64_t ret_ref = 0;
28440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28441         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28442         return ret_ref;
28443 }
28444
28445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28446         LDKChannelConfig a_conv;
28447         a_conv.inner = untag_ptr(a);
28448         a_conv.is_owned = ptr_is_owned(a);
28449         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28450         a_conv.is_owned = false;
28451         LDKChannelConfig b_conv;
28452         b_conv.inner = untag_ptr(b);
28453         b_conv.is_owned = ptr_is_owned(b);
28454         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28455         b_conv.is_owned = false;
28456         jboolean ret_conv = ChannelConfig_eq(&a_conv, &b_conv);
28457         return ret_conv;
28458 }
28459
28460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
28461         LDKChannelConfig ret_var = ChannelConfig_default();
28462         int64_t ret_ref = 0;
28463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28464         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28465         return ret_ref;
28466 }
28467
28468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
28469         LDKChannelConfig obj_conv;
28470         obj_conv.inner = untag_ptr(obj);
28471         obj_conv.is_owned = ptr_is_owned(obj);
28472         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28473         obj_conv.is_owned = false;
28474         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
28475         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28476         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28477         CVec_u8Z_free(ret_var);
28478         return ret_arr;
28479 }
28480
28481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28482         LDKu8slice ser_ref;
28483         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28484         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28485         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
28486         *ret_conv = ChannelConfig_read(ser_ref);
28487         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28488         return tag_ptr(ret_conv, true);
28489 }
28490
28491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28492         LDKUserConfig this_obj_conv;
28493         this_obj_conv.inner = untag_ptr(this_obj);
28494         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28496         UserConfig_free(this_obj_conv);
28497 }
28498
28499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28500         LDKUserConfig this_ptr_conv;
28501         this_ptr_conv.inner = untag_ptr(this_ptr);
28502         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28504         this_ptr_conv.is_owned = false;
28505         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
28506         int64_t ret_ref = 0;
28507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28509         return ret_ref;
28510 }
28511
28512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28513         LDKUserConfig this_ptr_conv;
28514         this_ptr_conv.inner = untag_ptr(this_ptr);
28515         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28517         this_ptr_conv.is_owned = false;
28518         LDKChannelHandshakeConfig val_conv;
28519         val_conv.inner = untag_ptr(val);
28520         val_conv.is_owned = ptr_is_owned(val);
28521         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28522         val_conv = ChannelHandshakeConfig_clone(&val_conv);
28523         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
28524 }
28525
28526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
28527         LDKUserConfig this_ptr_conv;
28528         this_ptr_conv.inner = untag_ptr(this_ptr);
28529         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28531         this_ptr_conv.is_owned = false;
28532         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
28533         int64_t ret_ref = 0;
28534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28535         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28536         return ret_ref;
28537 }
28538
28539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28540         LDKUserConfig this_ptr_conv;
28541         this_ptr_conv.inner = untag_ptr(this_ptr);
28542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28544         this_ptr_conv.is_owned = false;
28545         LDKChannelHandshakeLimits val_conv;
28546         val_conv.inner = untag_ptr(val);
28547         val_conv.is_owned = ptr_is_owned(val);
28548         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28549         val_conv = ChannelHandshakeLimits_clone(&val_conv);
28550         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
28551 }
28552
28553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28554         LDKUserConfig this_ptr_conv;
28555         this_ptr_conv.inner = untag_ptr(this_ptr);
28556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28558         this_ptr_conv.is_owned = false;
28559         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
28560         int64_t ret_ref = 0;
28561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28562         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28563         return ret_ref;
28564 }
28565
28566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28567         LDKUserConfig this_ptr_conv;
28568         this_ptr_conv.inner = untag_ptr(this_ptr);
28569         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28571         this_ptr_conv.is_owned = false;
28572         LDKChannelConfig val_conv;
28573         val_conv.inner = untag_ptr(val);
28574         val_conv.is_owned = ptr_is_owned(val);
28575         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28576         val_conv = ChannelConfig_clone(&val_conv);
28577         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
28578 }
28579
28580 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28581         LDKUserConfig this_ptr_conv;
28582         this_ptr_conv.inner = untag_ptr(this_ptr);
28583         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28585         this_ptr_conv.is_owned = false;
28586         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
28587         return ret_conv;
28588 }
28589
28590 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) {
28591         LDKUserConfig this_ptr_conv;
28592         this_ptr_conv.inner = untag_ptr(this_ptr);
28593         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28595         this_ptr_conv.is_owned = false;
28596         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
28597 }
28598
28599 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28600         LDKUserConfig this_ptr_conv;
28601         this_ptr_conv.inner = untag_ptr(this_ptr);
28602         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28604         this_ptr_conv.is_owned = false;
28605         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
28606         return ret_conv;
28607 }
28608
28609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28610         LDKUserConfig this_ptr_conv;
28611         this_ptr_conv.inner = untag_ptr(this_ptr);
28612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28614         this_ptr_conv.is_owned = false;
28615         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
28616 }
28617
28618 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28619         LDKUserConfig this_ptr_conv;
28620         this_ptr_conv.inner = untag_ptr(this_ptr);
28621         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28623         this_ptr_conv.is_owned = false;
28624         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
28625         return ret_conv;
28626 }
28627
28628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28629         LDKUserConfig this_ptr_conv;
28630         this_ptr_conv.inner = untag_ptr(this_ptr);
28631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28633         this_ptr_conv.is_owned = false;
28634         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
28635 }
28636
28637 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28638         LDKUserConfig this_ptr_conv;
28639         this_ptr_conv.inner = untag_ptr(this_ptr);
28640         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28642         this_ptr_conv.is_owned = false;
28643         jboolean ret_conv = UserConfig_get_accept_intercept_htlcs(&this_ptr_conv);
28644         return ret_conv;
28645 }
28646
28647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28648         LDKUserConfig this_ptr_conv;
28649         this_ptr_conv.inner = untag_ptr(this_ptr);
28650         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28652         this_ptr_conv.is_owned = false;
28653         UserConfig_set_accept_intercept_htlcs(&this_ptr_conv, val);
28654 }
28655
28656 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) {
28657         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
28658         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
28659         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
28660         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
28661         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
28662         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
28663         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
28664         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
28665         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
28666         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
28667         LDKChannelConfig channel_config_arg_conv;
28668         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
28669         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
28670         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
28671         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
28672         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);
28673         int64_t ret_ref = 0;
28674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28675         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28676         return ret_ref;
28677 }
28678
28679 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
28680         LDKUserConfig ret_var = UserConfig_clone(arg);
28681         int64_t ret_ref = 0;
28682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28683         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28684         return ret_ref;
28685 }
28686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28687         LDKUserConfig arg_conv;
28688         arg_conv.inner = untag_ptr(arg);
28689         arg_conv.is_owned = ptr_is_owned(arg);
28690         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28691         arg_conv.is_owned = false;
28692         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
28693         return ret_conv;
28694 }
28695
28696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28697         LDKUserConfig orig_conv;
28698         orig_conv.inner = untag_ptr(orig);
28699         orig_conv.is_owned = ptr_is_owned(orig);
28700         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28701         orig_conv.is_owned = false;
28702         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
28703         int64_t ret_ref = 0;
28704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28705         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28706         return ret_ref;
28707 }
28708
28709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
28710         LDKUserConfig ret_var = UserConfig_default();
28711         int64_t ret_ref = 0;
28712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28713         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28714         return ret_ref;
28715 }
28716
28717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28718         LDKBestBlock this_obj_conv;
28719         this_obj_conv.inner = untag_ptr(this_obj);
28720         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28722         BestBlock_free(this_obj_conv);
28723 }
28724
28725 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
28726         LDKBestBlock ret_var = BestBlock_clone(arg);
28727         int64_t ret_ref = 0;
28728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28729         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28730         return ret_ref;
28731 }
28732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28733         LDKBestBlock arg_conv;
28734         arg_conv.inner = untag_ptr(arg);
28735         arg_conv.is_owned = ptr_is_owned(arg);
28736         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28737         arg_conv.is_owned = false;
28738         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
28739         return ret_conv;
28740 }
28741
28742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28743         LDKBestBlock orig_conv;
28744         orig_conv.inner = untag_ptr(orig);
28745         orig_conv.is_owned = ptr_is_owned(orig);
28746         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28747         orig_conv.is_owned = false;
28748         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
28749         int64_t ret_ref = 0;
28750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28751         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28752         return ret_ref;
28753 }
28754
28755 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BestBlock_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28756         LDKBestBlock a_conv;
28757         a_conv.inner = untag_ptr(a);
28758         a_conv.is_owned = ptr_is_owned(a);
28759         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28760         a_conv.is_owned = false;
28761         LDKBestBlock b_conv;
28762         b_conv.inner = untag_ptr(b);
28763         b_conv.is_owned = ptr_is_owned(b);
28764         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28765         b_conv.is_owned = false;
28766         jboolean ret_conv = BestBlock_eq(&a_conv, &b_conv);
28767         return ret_conv;
28768 }
28769
28770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1network(JNIEnv *env, jclass clz, jclass network) {
28771         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
28772         LDKBestBlock ret_var = BestBlock_from_network(network_conv);
28773         int64_t ret_ref = 0;
28774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28775         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28776         return ret_ref;
28777 }
28778
28779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
28780         LDKThirtyTwoBytes block_hash_ref;
28781         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
28782         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
28783         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
28784         int64_t ret_ref = 0;
28785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28786         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28787         return ret_ref;
28788 }
28789
28790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
28791         LDKBestBlock this_arg_conv;
28792         this_arg_conv.inner = untag_ptr(this_arg);
28793         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28795         this_arg_conv.is_owned = false;
28796         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28797         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
28798         return ret_arr;
28799 }
28800
28801 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
28802         LDKBestBlock this_arg_conv;
28803         this_arg_conv.inner = untag_ptr(this_arg);
28804         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28806         this_arg_conv.is_owned = false;
28807         int32_t ret_conv = BestBlock_height(&this_arg_conv);
28808         return ret_conv;
28809 }
28810
28811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28812         if (!ptr_is_owned(this_ptr)) return;
28813         void* this_ptr_ptr = untag_ptr(this_ptr);
28814         CHECK_ACCESS(this_ptr_ptr);
28815         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
28816         FREE(untag_ptr(this_ptr));
28817         Listen_free(this_ptr_conv);
28818 }
28819
28820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28821         if (!ptr_is_owned(this_ptr)) return;
28822         void* this_ptr_ptr = untag_ptr(this_ptr);
28823         CHECK_ACCESS(this_ptr_ptr);
28824         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
28825         FREE(untag_ptr(this_ptr));
28826         Confirm_free(this_ptr_conv);
28827 }
28828
28829 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28830         LDKChannelMonitorUpdateStatus* orig_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(orig);
28831         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_clone(orig_conv));
28832         return ret_conv;
28833 }
28834
28835 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1completed(JNIEnv *env, jclass clz) {
28836         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_completed());
28837         return ret_conv;
28838 }
28839
28840 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1in_1progress(JNIEnv *env, jclass clz) {
28841         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_in_progress());
28842         return ret_conv;
28843 }
28844
28845 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1permanent_1failure(JNIEnv *env, jclass clz) {
28846         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_permanent_failure());
28847         return ret_conv;
28848 }
28849
28850 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28851         LDKChannelMonitorUpdateStatus* a_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(a);
28852         LDKChannelMonitorUpdateStatus* b_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(b);
28853         jboolean ret_conv = ChannelMonitorUpdateStatus_eq(a_conv, b_conv);
28854         return ret_conv;
28855 }
28856
28857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28858         if (!ptr_is_owned(this_ptr)) return;
28859         void* this_ptr_ptr = untag_ptr(this_ptr);
28860         CHECK_ACCESS(this_ptr_ptr);
28861         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
28862         FREE(untag_ptr(this_ptr));
28863         Watch_free(this_ptr_conv);
28864 }
28865
28866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28867         if (!ptr_is_owned(this_ptr)) return;
28868         void* this_ptr_ptr = untag_ptr(this_ptr);
28869         CHECK_ACCESS(this_ptr_ptr);
28870         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
28871         FREE(untag_ptr(this_ptr));
28872         Filter_free(this_ptr_conv);
28873 }
28874
28875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28876         LDKWatchedOutput this_obj_conv;
28877         this_obj_conv.inner = untag_ptr(this_obj);
28878         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28880         WatchedOutput_free(this_obj_conv);
28881 }
28882
28883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
28884         LDKWatchedOutput this_ptr_conv;
28885         this_ptr_conv.inner = untag_ptr(this_ptr);
28886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28888         this_ptr_conv.is_owned = false;
28889         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28890         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
28891         return ret_arr;
28892 }
28893
28894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28895         LDKWatchedOutput this_ptr_conv;
28896         this_ptr_conv.inner = untag_ptr(this_ptr);
28897         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28899         this_ptr_conv.is_owned = false;
28900         LDKThirtyTwoBytes val_ref;
28901         CHECK((*env)->GetArrayLength(env, val) == 32);
28902         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28903         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
28904 }
28905
28906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28907         LDKWatchedOutput this_ptr_conv;
28908         this_ptr_conv.inner = untag_ptr(this_ptr);
28909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28911         this_ptr_conv.is_owned = false;
28912         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
28913         int64_t ret_ref = 0;
28914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28915         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28916         return ret_ref;
28917 }
28918
28919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28920         LDKWatchedOutput this_ptr_conv;
28921         this_ptr_conv.inner = untag_ptr(this_ptr);
28922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28924         this_ptr_conv.is_owned = false;
28925         LDKOutPoint val_conv;
28926         val_conv.inner = untag_ptr(val);
28927         val_conv.is_owned = ptr_is_owned(val);
28928         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28929         val_conv = OutPoint_clone(&val_conv);
28930         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
28931 }
28932
28933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28934         LDKWatchedOutput this_ptr_conv;
28935         this_ptr_conv.inner = untag_ptr(this_ptr);
28936         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28938         this_ptr_conv.is_owned = false;
28939         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
28940         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28941         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28942         return ret_arr;
28943 }
28944
28945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28946         LDKWatchedOutput this_ptr_conv;
28947         this_ptr_conv.inner = untag_ptr(this_ptr);
28948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28950         this_ptr_conv.is_owned = false;
28951         LDKCVec_u8Z val_ref;
28952         val_ref.datalen = (*env)->GetArrayLength(env, val);
28953         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
28954         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
28955         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
28956 }
28957
28958 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) {
28959         LDKThirtyTwoBytes block_hash_arg_ref;
28960         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
28961         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
28962         LDKOutPoint outpoint_arg_conv;
28963         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
28964         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
28965         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28966         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28967         LDKCVec_u8Z script_pubkey_arg_ref;
28968         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
28969         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
28970         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
28971         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
28972         int64_t ret_ref = 0;
28973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28974         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28975         return ret_ref;
28976 }
28977
28978 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
28979         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
28980         int64_t ret_ref = 0;
28981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28982         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28983         return ret_ref;
28984 }
28985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28986         LDKWatchedOutput arg_conv;
28987         arg_conv.inner = untag_ptr(arg);
28988         arg_conv.is_owned = ptr_is_owned(arg);
28989         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28990         arg_conv.is_owned = false;
28991         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
28992         return ret_conv;
28993 }
28994
28995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28996         LDKWatchedOutput orig_conv;
28997         orig_conv.inner = untag_ptr(orig);
28998         orig_conv.is_owned = ptr_is_owned(orig);
28999         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29000         orig_conv.is_owned = false;
29001         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
29002         int64_t ret_ref = 0;
29003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29004         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29005         return ret_ref;
29006 }
29007
29008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29009         LDKWatchedOutput a_conv;
29010         a_conv.inner = untag_ptr(a);
29011         a_conv.is_owned = ptr_is_owned(a);
29012         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29013         a_conv.is_owned = false;
29014         LDKWatchedOutput b_conv;
29015         b_conv.inner = untag_ptr(b);
29016         b_conv.is_owned = ptr_is_owned(b);
29017         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29018         b_conv.is_owned = false;
29019         jboolean ret_conv = WatchedOutput_eq(&a_conv, &b_conv);
29020         return ret_conv;
29021 }
29022
29023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
29024         LDKWatchedOutput o_conv;
29025         o_conv.inner = untag_ptr(o);
29026         o_conv.is_owned = ptr_is_owned(o);
29027         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29028         o_conv.is_owned = false;
29029         int64_t ret_conv = WatchedOutput_hash(&o_conv);
29030         return ret_conv;
29031 }
29032
29033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29034         if (!ptr_is_owned(this_ptr)) return;
29035         void* this_ptr_ptr = untag_ptr(this_ptr);
29036         CHECK_ACCESS(this_ptr_ptr);
29037         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
29038         FREE(untag_ptr(this_ptr));
29039         BroadcasterInterface_free(this_ptr_conv);
29040 }
29041
29042 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29043         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
29044         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
29045         return ret_conv;
29046 }
29047
29048 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
29049         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
29050         return ret_conv;
29051 }
29052
29053 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
29054         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
29055         return ret_conv;
29056 }
29057
29058 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
29059         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
29060         return ret_conv;
29061 }
29062
29063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1hash(JNIEnv *env, jclass clz, int64_t o) {
29064         LDKConfirmationTarget* o_conv = (LDKConfirmationTarget*)untag_ptr(o);
29065         int64_t ret_conv = ConfirmationTarget_hash(o_conv);
29066         return ret_conv;
29067 }
29068
29069 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29070         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
29071         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
29072         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
29073         return ret_conv;
29074 }
29075
29076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29077         if (!ptr_is_owned(this_ptr)) return;
29078         void* this_ptr_ptr = untag_ptr(this_ptr);
29079         CHECK_ACCESS(this_ptr_ptr);
29080         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
29081         FREE(untag_ptr(this_ptr));
29082         FeeEstimator_free(this_ptr_conv);
29083 }
29084
29085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29086         LDKMonitorUpdateId this_obj_conv;
29087         this_obj_conv.inner = untag_ptr(this_obj);
29088         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29090         MonitorUpdateId_free(this_obj_conv);
29091 }
29092
29093 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
29094         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
29095         int64_t ret_ref = 0;
29096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29097         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29098         return ret_ref;
29099 }
29100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29101         LDKMonitorUpdateId arg_conv;
29102         arg_conv.inner = untag_ptr(arg);
29103         arg_conv.is_owned = ptr_is_owned(arg);
29104         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29105         arg_conv.is_owned = false;
29106         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
29107         return ret_conv;
29108 }
29109
29110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29111         LDKMonitorUpdateId orig_conv;
29112         orig_conv.inner = untag_ptr(orig);
29113         orig_conv.is_owned = ptr_is_owned(orig);
29114         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29115         orig_conv.is_owned = false;
29116         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
29117         int64_t ret_ref = 0;
29118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29119         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29120         return ret_ref;
29121 }
29122
29123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
29124         LDKMonitorUpdateId o_conv;
29125         o_conv.inner = untag_ptr(o);
29126         o_conv.is_owned = ptr_is_owned(o);
29127         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29128         o_conv.is_owned = false;
29129         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
29130         return ret_conv;
29131 }
29132
29133 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29134         LDKMonitorUpdateId a_conv;
29135         a_conv.inner = untag_ptr(a);
29136         a_conv.is_owned = ptr_is_owned(a);
29137         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29138         a_conv.is_owned = false;
29139         LDKMonitorUpdateId b_conv;
29140         b_conv.inner = untag_ptr(b);
29141         b_conv.is_owned = ptr_is_owned(b);
29142         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29143         b_conv.is_owned = false;
29144         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
29145         return ret_conv;
29146 }
29147
29148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29149         if (!ptr_is_owned(this_ptr)) return;
29150         void* this_ptr_ptr = untag_ptr(this_ptr);
29151         CHECK_ACCESS(this_ptr_ptr);
29152         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
29153         FREE(untag_ptr(this_ptr));
29154         Persist_free(this_ptr_conv);
29155 }
29156
29157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29158         LDKLockedChannelMonitor this_obj_conv;
29159         this_obj_conv.inner = untag_ptr(this_obj);
29160         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29162         LockedChannelMonitor_free(this_obj_conv);
29163 }
29164
29165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29166         LDKChainMonitor this_obj_conv;
29167         this_obj_conv.inner = untag_ptr(this_obj);
29168         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29170         ChainMonitor_free(this_obj_conv);
29171 }
29172
29173 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) {
29174         void* chain_source_ptr = untag_ptr(chain_source);
29175         CHECK_ACCESS(chain_source_ptr);
29176         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
29177         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
29178         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
29179                 // Manually implement clone for Java trait instances
29180                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
29181                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29182                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
29183                 }
29184         }
29185         void* broadcaster_ptr = untag_ptr(broadcaster);
29186         CHECK_ACCESS(broadcaster_ptr);
29187         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29188         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29189                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29190                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29191         }
29192         void* logger_ptr = untag_ptr(logger);
29193         CHECK_ACCESS(logger_ptr);
29194         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29195         if (logger_conv.free == LDKLogger_JCalls_free) {
29196                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29197                 LDKLogger_JCalls_cloned(&logger_conv);
29198         }
29199         void* feeest_ptr = untag_ptr(feeest);
29200         CHECK_ACCESS(feeest_ptr);
29201         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
29202         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
29203                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29204                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
29205         }
29206         void* persister_ptr = untag_ptr(persister);
29207         CHECK_ACCESS(persister_ptr);
29208         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
29209         if (persister_conv.free == LDKPersist_JCalls_free) {
29210                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29211                 LDKPersist_JCalls_cloned(&persister_conv);
29212         }
29213         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
29214         int64_t ret_ref = 0;
29215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29216         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29217         return ret_ref;
29218 }
29219
29220 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) {
29221         LDKChainMonitor this_arg_conv;
29222         this_arg_conv.inner = untag_ptr(this_arg);
29223         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29225         this_arg_conv.is_owned = false;
29226         LDKCVec_ChannelDetailsZ ignored_channels_constr;
29227         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
29228         if (ignored_channels_constr.datalen > 0)
29229                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29230         else
29231                 ignored_channels_constr.data = NULL;
29232         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
29233         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
29234                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
29235                 LDKChannelDetails ignored_channels_conv_16_conv;
29236                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
29237                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
29238                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
29239                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
29240                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
29241         }
29242         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
29243         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
29244         int64_tArray ret_arr = NULL;
29245         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29246         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29247         for (size_t j = 0; j < ret_var.datalen; j++) {
29248                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29249                 *ret_conv_9_copy = ret_var.data[j];
29250                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
29251                 ret_arr_ptr[j] = ret_conv_9_ref;
29252         }
29253         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29254         FREE(ret_var.data);
29255         return ret_arr;
29256 }
29257
29258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
29259         LDKChainMonitor this_arg_conv;
29260         this_arg_conv.inner = untag_ptr(this_arg);
29261         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29263         this_arg_conv.is_owned = false;
29264         LDKOutPoint funding_txo_conv;
29265         funding_txo_conv.inner = untag_ptr(funding_txo);
29266         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29267         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29268         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29269         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
29270         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
29271         return tag_ptr(ret_conv, true);
29272 }
29273
29274 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
29275         LDKChainMonitor this_arg_conv;
29276         this_arg_conv.inner = untag_ptr(this_arg);
29277         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29279         this_arg_conv.is_owned = false;
29280         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
29281         int64_tArray ret_arr = NULL;
29282         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29283         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29284         for (size_t k = 0; k < ret_var.datalen; k++) {
29285                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
29286                 int64_t ret_conv_10_ref = 0;
29287                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
29288                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
29289                 ret_arr_ptr[k] = ret_conv_10_ref;
29290         }
29291         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29292         FREE(ret_var.data);
29293         return ret_arr;
29294 }
29295
29296 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1pending_1monitor_1updates(JNIEnv *env, jclass clz, int64_t this_arg) {
29297         LDKChainMonitor this_arg_conv;
29298         this_arg_conv.inner = untag_ptr(this_arg);
29299         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29301         this_arg_conv.is_owned = false;
29302         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret_var = ChainMonitor_list_pending_monitor_updates(&this_arg_conv);
29303         int64_tArray ret_arr = NULL;
29304         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29305         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29306         for (size_t p = 0; p < ret_var.datalen; p++) {
29307                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv_41_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
29308                 *ret_conv_41_conv = ret_var.data[p];
29309                 ret_arr_ptr[p] = tag_ptr(ret_conv_41_conv, true);
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_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) {
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         LDKOutPoint funding_txo_conv;
29323         funding_txo_conv.inner = untag_ptr(funding_txo);
29324         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29325         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29326         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29327         LDKMonitorUpdateId completed_update_id_conv;
29328         completed_update_id_conv.inner = untag_ptr(completed_update_id);
29329         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
29330         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
29331         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
29332         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29333         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
29334         return tag_ptr(ret_conv, true);
29335 }
29336
29337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
29338         LDKChainMonitor this_arg_conv;
29339         this_arg_conv.inner = untag_ptr(this_arg);
29340         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29342         this_arg_conv.is_owned = false;
29343         LDKFuture ret_var = ChainMonitor_get_update_future(&this_arg_conv);
29344         int64_t ret_ref = 0;
29345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29346         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29347         return ret_ref;
29348 }
29349
29350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1rebroadcast_1pending_1claims(JNIEnv *env, jclass clz, int64_t this_arg) {
29351         LDKChainMonitor this_arg_conv;
29352         this_arg_conv.inner = untag_ptr(this_arg);
29353         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29355         this_arg_conv.is_owned = false;
29356         ChainMonitor_rebroadcast_pending_claims(&this_arg_conv);
29357 }
29358
29359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
29360         LDKChainMonitor this_arg_conv;
29361         this_arg_conv.inner = untag_ptr(this_arg);
29362         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29364         this_arg_conv.is_owned = false;
29365         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
29366         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
29367         return tag_ptr(ret_ret, true);
29368 }
29369
29370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(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         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
29377         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
29378         return tag_ptr(ret_ret, true);
29379 }
29380
29381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
29382         LDKChainMonitor this_arg_conv;
29383         this_arg_conv.inner = untag_ptr(this_arg);
29384         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29386         this_arg_conv.is_owned = false;
29387         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
29388         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
29389         return tag_ptr(ret_ret, true);
29390 }
29391
29392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29393         LDKChainMonitor this_arg_conv;
29394         this_arg_conv.inner = untag_ptr(this_arg);
29395         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29397         this_arg_conv.is_owned = false;
29398         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
29399         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
29400         return tag_ptr(ret_ret, true);
29401 }
29402
29403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29404         LDKChannelMonitorUpdate this_obj_conv;
29405         this_obj_conv.inner = untag_ptr(this_obj);
29406         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29408         ChannelMonitorUpdate_free(this_obj_conv);
29409 }
29410
29411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29412         LDKChannelMonitorUpdate this_ptr_conv;
29413         this_ptr_conv.inner = untag_ptr(this_ptr);
29414         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29416         this_ptr_conv.is_owned = false;
29417         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
29418         return ret_conv;
29419 }
29420
29421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29422         LDKChannelMonitorUpdate this_ptr_conv;
29423         this_ptr_conv.inner = untag_ptr(this_ptr);
29424         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29426         this_ptr_conv.is_owned = false;
29427         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
29428 }
29429
29430 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
29431         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
29432         int64_t ret_ref = 0;
29433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29434         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29435         return ret_ref;
29436 }
29437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29438         LDKChannelMonitorUpdate arg_conv;
29439         arg_conv.inner = untag_ptr(arg);
29440         arg_conv.is_owned = ptr_is_owned(arg);
29441         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29442         arg_conv.is_owned = false;
29443         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
29444         return ret_conv;
29445 }
29446
29447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29448         LDKChannelMonitorUpdate orig_conv;
29449         orig_conv.inner = untag_ptr(orig);
29450         orig_conv.is_owned = ptr_is_owned(orig);
29451         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29452         orig_conv.is_owned = false;
29453         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
29454         int64_t ret_ref = 0;
29455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29456         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29457         return ret_ref;
29458 }
29459
29460 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29461         LDKChannelMonitorUpdate a_conv;
29462         a_conv.inner = untag_ptr(a);
29463         a_conv.is_owned = ptr_is_owned(a);
29464         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29465         a_conv.is_owned = false;
29466         LDKChannelMonitorUpdate b_conv;
29467         b_conv.inner = untag_ptr(b);
29468         b_conv.is_owned = ptr_is_owned(b);
29469         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29470         b_conv.is_owned = false;
29471         jboolean ret_conv = ChannelMonitorUpdate_eq(&a_conv, &b_conv);
29472         return ret_conv;
29473 }
29474
29475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29476         LDKChannelMonitorUpdate obj_conv;
29477         obj_conv.inner = untag_ptr(obj);
29478         obj_conv.is_owned = ptr_is_owned(obj);
29479         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29480         obj_conv.is_owned = false;
29481         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
29482         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29483         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29484         CVec_u8Z_free(ret_var);
29485         return ret_arr;
29486 }
29487
29488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29489         LDKu8slice ser_ref;
29490         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29491         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29492         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
29493         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
29494         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29495         return tag_ptr(ret_conv, true);
29496 }
29497
29498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29499         if (!ptr_is_owned(this_ptr)) return;
29500         void* this_ptr_ptr = untag_ptr(this_ptr);
29501         CHECK_ACCESS(this_ptr_ptr);
29502         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
29503         FREE(untag_ptr(this_ptr));
29504         MonitorEvent_free(this_ptr_conv);
29505 }
29506
29507 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
29508         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29509         *ret_copy = MonitorEvent_clone(arg);
29510         int64_t ret_ref = tag_ptr(ret_copy, true);
29511         return ret_ref;
29512 }
29513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29514         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
29515         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
29516         return ret_conv;
29517 }
29518
29519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29520         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
29521         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29522         *ret_copy = MonitorEvent_clone(orig_conv);
29523         int64_t ret_ref = tag_ptr(ret_copy, true);
29524         return ret_ref;
29525 }
29526
29527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
29528         LDKHTLCUpdate a_conv;
29529         a_conv.inner = untag_ptr(a);
29530         a_conv.is_owned = ptr_is_owned(a);
29531         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29532         a_conv = HTLCUpdate_clone(&a_conv);
29533         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29534         *ret_copy = MonitorEvent_htlcevent(a_conv);
29535         int64_t ret_ref = tag_ptr(ret_copy, true);
29536         return ret_ref;
29537 }
29538
29539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
29540         LDKOutPoint a_conv;
29541         a_conv.inner = untag_ptr(a);
29542         a_conv.is_owned = ptr_is_owned(a);
29543         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29544         a_conv = OutPoint_clone(&a_conv);
29545         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29546         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
29547         int64_t ret_ref = tag_ptr(ret_copy, true);
29548         return ret_ref;
29549 }
29550
29551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
29552         LDKOutPoint funding_txo_conv;
29553         funding_txo_conv.inner = untag_ptr(funding_txo);
29554         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29555         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29556         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29557         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29558         *ret_copy = MonitorEvent_completed(funding_txo_conv, monitor_update_id);
29559         int64_t ret_ref = tag_ptr(ret_copy, true);
29560         return ret_ref;
29561 }
29562
29563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
29564         LDKOutPoint a_conv;
29565         a_conv.inner = untag_ptr(a);
29566         a_conv.is_owned = ptr_is_owned(a);
29567         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29568         a_conv = OutPoint_clone(&a_conv);
29569         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29570         *ret_copy = MonitorEvent_update_failed(a_conv);
29571         int64_t ret_ref = tag_ptr(ret_copy, true);
29572         return ret_ref;
29573 }
29574
29575 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29576         LDKMonitorEvent* a_conv = (LDKMonitorEvent*)untag_ptr(a);
29577         LDKMonitorEvent* b_conv = (LDKMonitorEvent*)untag_ptr(b);
29578         jboolean ret_conv = MonitorEvent_eq(a_conv, b_conv);
29579         return ret_conv;
29580 }
29581
29582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
29583         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
29584         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
29585         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29586         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29587         CVec_u8Z_free(ret_var);
29588         return ret_arr;
29589 }
29590
29591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29592         LDKu8slice ser_ref;
29593         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29594         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29595         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
29596         *ret_conv = MonitorEvent_read(ser_ref);
29597         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29598         return tag_ptr(ret_conv, true);
29599 }
29600
29601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29602         LDKHTLCUpdate this_obj_conv;
29603         this_obj_conv.inner = untag_ptr(this_obj);
29604         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29606         HTLCUpdate_free(this_obj_conv);
29607 }
29608
29609 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
29610         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
29611         int64_t ret_ref = 0;
29612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29613         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29614         return ret_ref;
29615 }
29616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29617         LDKHTLCUpdate arg_conv;
29618         arg_conv.inner = untag_ptr(arg);
29619         arg_conv.is_owned = ptr_is_owned(arg);
29620         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29621         arg_conv.is_owned = false;
29622         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
29623         return ret_conv;
29624 }
29625
29626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29627         LDKHTLCUpdate orig_conv;
29628         orig_conv.inner = untag_ptr(orig);
29629         orig_conv.is_owned = ptr_is_owned(orig);
29630         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29631         orig_conv.is_owned = false;
29632         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
29633         int64_t ret_ref = 0;
29634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29635         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29636         return ret_ref;
29637 }
29638
29639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29640         LDKHTLCUpdate a_conv;
29641         a_conv.inner = untag_ptr(a);
29642         a_conv.is_owned = ptr_is_owned(a);
29643         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29644         a_conv.is_owned = false;
29645         LDKHTLCUpdate b_conv;
29646         b_conv.inner = untag_ptr(b);
29647         b_conv.is_owned = ptr_is_owned(b);
29648         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29649         b_conv.is_owned = false;
29650         jboolean ret_conv = HTLCUpdate_eq(&a_conv, &b_conv);
29651         return ret_conv;
29652 }
29653
29654 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29655         LDKHTLCUpdate obj_conv;
29656         obj_conv.inner = untag_ptr(obj);
29657         obj_conv.is_owned = ptr_is_owned(obj);
29658         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29659         obj_conv.is_owned = false;
29660         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
29661         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29662         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29663         CVec_u8Z_free(ret_var);
29664         return ret_arr;
29665 }
29666
29667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29668         LDKu8slice ser_ref;
29669         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29670         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29671         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
29672         *ret_conv = HTLCUpdate_read(ser_ref);
29673         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29674         return tag_ptr(ret_conv, true);
29675 }
29676
29677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29678         if (!ptr_is_owned(this_ptr)) return;
29679         void* this_ptr_ptr = untag_ptr(this_ptr);
29680         CHECK_ACCESS(this_ptr_ptr);
29681         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
29682         FREE(untag_ptr(this_ptr));
29683         Balance_free(this_ptr_conv);
29684 }
29685
29686 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
29687         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29688         *ret_copy = Balance_clone(arg);
29689         int64_t ret_ref = tag_ptr(ret_copy, true);
29690         return ret_ref;
29691 }
29692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29693         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
29694         int64_t ret_conv = Balance_clone_ptr(arg_conv);
29695         return ret_conv;
29696 }
29697
29698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29699         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
29700         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29701         *ret_copy = Balance_clone(orig_conv);
29702         int64_t ret_ref = tag_ptr(ret_copy, true);
29703         return ret_ref;
29704 }
29705
29706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29707         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29708         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
29709         int64_t ret_ref = tag_ptr(ret_copy, true);
29710         return ret_ref;
29711 }
29712
29713 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) {
29714         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29715         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
29716         int64_t ret_ref = tag_ptr(ret_copy, true);
29717         return ret_ref;
29718 }
29719
29720 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) {
29721         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29722         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
29723         int64_t ret_ref = tag_ptr(ret_copy, true);
29724         return ret_ref;
29725 }
29726
29727 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) {
29728         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29729         *ret_copy = Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis, claimable_height);
29730         int64_t ret_ref = tag_ptr(ret_copy, true);
29731         return ret_ref;
29732 }
29733
29734 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) {
29735         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29736         *ret_copy = Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis, expiry_height);
29737         int64_t ret_ref = tag_ptr(ret_copy, true);
29738         return ret_ref;
29739 }
29740
29741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1counterparty_1revoked_1output_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29742         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29743         *ret_copy = Balance_counterparty_revoked_output_claimable(claimable_amount_satoshis);
29744         int64_t ret_ref = tag_ptr(ret_copy, true);
29745         return ret_ref;
29746 }
29747
29748 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29749         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
29750         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
29751         jboolean ret_conv = Balance_eq(a_conv, b_conv);
29752         return ret_conv;
29753 }
29754
29755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29756         LDKChannelMonitor this_obj_conv;
29757         this_obj_conv.inner = untag_ptr(this_obj);
29758         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29760         ChannelMonitor_free(this_obj_conv);
29761 }
29762
29763 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
29764         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
29765         int64_t ret_ref = 0;
29766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29767         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29768         return ret_ref;
29769 }
29770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29771         LDKChannelMonitor arg_conv;
29772         arg_conv.inner = untag_ptr(arg);
29773         arg_conv.is_owned = ptr_is_owned(arg);
29774         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29775         arg_conv.is_owned = false;
29776         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
29777         return ret_conv;
29778 }
29779
29780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29781         LDKChannelMonitor orig_conv;
29782         orig_conv.inner = untag_ptr(orig);
29783         orig_conv.is_owned = ptr_is_owned(orig);
29784         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29785         orig_conv.is_owned = false;
29786         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
29787         int64_t ret_ref = 0;
29788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29789         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29790         return ret_ref;
29791 }
29792
29793 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29794         LDKChannelMonitor obj_conv;
29795         obj_conv.inner = untag_ptr(obj);
29796         obj_conv.is_owned = ptr_is_owned(obj);
29797         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29798         obj_conv.is_owned = false;
29799         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
29800         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29801         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29802         CVec_u8Z_free(ret_var);
29803         return ret_arr;
29804 }
29805
29806 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) {
29807         LDKChannelMonitor this_arg_conv;
29808         this_arg_conv.inner = untag_ptr(this_arg);
29809         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29811         this_arg_conv.is_owned = false;
29812         LDKChannelMonitorUpdate updates_conv;
29813         updates_conv.inner = untag_ptr(updates);
29814         updates_conv.is_owned = ptr_is_owned(updates);
29815         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
29816         updates_conv.is_owned = false;
29817         void* broadcaster_ptr = untag_ptr(broadcaster);
29818         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
29819         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
29820         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29821         CHECK_ACCESS(fee_estimator_ptr);
29822         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29823         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29824                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29825                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29826         }
29827         void* logger_ptr = untag_ptr(logger);
29828         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29829         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29830         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
29831         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
29832         return tag_ptr(ret_conv, true);
29833 }
29834
29835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29836         LDKChannelMonitor this_arg_conv;
29837         this_arg_conv.inner = untag_ptr(this_arg);
29838         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29840         this_arg_conv.is_owned = false;
29841         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
29842         return ret_conv;
29843 }
29844
29845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
29846         LDKChannelMonitor this_arg_conv;
29847         this_arg_conv.inner = untag_ptr(this_arg);
29848         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29850         this_arg_conv.is_owned = false;
29851         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
29852         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
29853         return tag_ptr(ret_conv, true);
29854 }
29855
29856 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
29857         LDKChannelMonitor this_arg_conv;
29858         this_arg_conv.inner = untag_ptr(this_arg);
29859         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29861         this_arg_conv.is_owned = false;
29862         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
29863         int64_tArray ret_arr = NULL;
29864         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29865         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29866         for (size_t o = 0; o < ret_var.datalen; o++) {
29867                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
29868                 *ret_conv_40_conv = ret_var.data[o];
29869                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
29870         }
29871         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29872         FREE(ret_var.data);
29873         return ret_arr;
29874 }
29875
29876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
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         void* filter_ptr = untag_ptr(filter);
29883         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
29884         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
29885         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
29886 }
29887
29888 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
29889         LDKChannelMonitor this_arg_conv;
29890         this_arg_conv.inner = untag_ptr(this_arg);
29891         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29893         this_arg_conv.is_owned = false;
29894         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
29895         int64_tArray ret_arr = NULL;
29896         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29897         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29898         for (size_t o = 0; o < ret_var.datalen; o++) {
29899                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29900                 *ret_conv_14_copy = ret_var.data[o];
29901                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
29902                 ret_arr_ptr[o] = ret_conv_14_ref;
29903         }
29904         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29905         FREE(ret_var.data);
29906         return ret_arr;
29907 }
29908
29909 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
29910         LDKChannelMonitor this_arg_conv;
29911         this_arg_conv.inner = untag_ptr(this_arg);
29912         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29914         this_arg_conv.is_owned = false;
29915         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
29916         int64_tArray ret_arr = NULL;
29917         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29918         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29919         for (size_t h = 0; h < ret_var.datalen; h++) {
29920                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
29921                 *ret_conv_7_copy = ret_var.data[h];
29922                 int64_t ret_conv_7_ref = tag_ptr(ret_conv_7_copy, true);
29923                 ret_arr_ptr[h] = ret_conv_7_ref;
29924         }
29925         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29926         FREE(ret_var.data);
29927         return ret_arr;
29928 }
29929
29930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29931         LDKChannelMonitor this_arg_conv;
29932         this_arg_conv.inner = untag_ptr(this_arg);
29933         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29935         this_arg_conv.is_owned = false;
29936         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29937         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
29938         return ret_arr;
29939 }
29940
29941 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) {
29942         LDKChannelMonitor this_arg_conv;
29943         this_arg_conv.inner = untag_ptr(this_arg);
29944         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29946         this_arg_conv.is_owned = false;
29947         void* logger_ptr = untag_ptr(logger);
29948         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29949         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29950         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
29951         jobjectArray ret_arr = NULL;
29952         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
29953         ;
29954         for (size_t i = 0; i < ret_var.datalen; i++) {
29955                 LDKTransaction ret_conv_8_var = ret_var.data[i];
29956                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
29957                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
29958                 Transaction_free(ret_conv_8_var);
29959                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
29960         }
29961         
29962         FREE(ret_var.data);
29963         return ret_arr;
29964 }
29965
29966 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) {
29967         LDKChannelMonitor this_arg_conv;
29968         this_arg_conv.inner = untag_ptr(this_arg);
29969         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29971         this_arg_conv.is_owned = false;
29972         uint8_t header_arr[80];
29973         CHECK((*env)->GetArrayLength(env, header) == 80);
29974         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
29975         uint8_t (*header_ref)[80] = &header_arr;
29976         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
29977         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
29978         if (txdata_constr.datalen > 0)
29979                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
29980         else
29981                 txdata_constr.data = NULL;
29982         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
29983         for (size_t c = 0; c < txdata_constr.datalen; c++) {
29984                 int64_t txdata_conv_28 = txdata_vals[c];
29985                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
29986                 CHECK_ACCESS(txdata_conv_28_ptr);
29987                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
29988                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
29989                 txdata_constr.data[c] = txdata_conv_28_conv;
29990         }
29991         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
29992         void* broadcaster_ptr = untag_ptr(broadcaster);
29993         CHECK_ACCESS(broadcaster_ptr);
29994         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29995         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29996                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29997                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29998         }
29999         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30000         CHECK_ACCESS(fee_estimator_ptr);
30001         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30002         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30003                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30004                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30005         }
30006         void* logger_ptr = untag_ptr(logger);
30007         CHECK_ACCESS(logger_ptr);
30008         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30009         if (logger_conv.free == LDKLogger_JCalls_free) {
30010                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30011                 LDKLogger_JCalls_cloned(&logger_conv);
30012         }
30013         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);
30014         int64_tArray ret_arr = NULL;
30015         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30016         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30017         for (size_t n = 0; n < ret_var.datalen; n++) {
30018                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30019                 *ret_conv_39_conv = ret_var.data[n];
30020                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30021         }
30022         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30023         FREE(ret_var.data);
30024         return ret_arr;
30025 }
30026
30027 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) {
30028         LDKChannelMonitor this_arg_conv;
30029         this_arg_conv.inner = untag_ptr(this_arg);
30030         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30032         this_arg_conv.is_owned = false;
30033         uint8_t header_arr[80];
30034         CHECK((*env)->GetArrayLength(env, header) == 80);
30035         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30036         uint8_t (*header_ref)[80] = &header_arr;
30037         void* broadcaster_ptr = untag_ptr(broadcaster);
30038         CHECK_ACCESS(broadcaster_ptr);
30039         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30040         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30041                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30042                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30043         }
30044         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30045         CHECK_ACCESS(fee_estimator_ptr);
30046         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30047         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30048                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30049                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30050         }
30051         void* logger_ptr = untag_ptr(logger);
30052         CHECK_ACCESS(logger_ptr);
30053         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30054         if (logger_conv.free == LDKLogger_JCalls_free) {
30055                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30056                 LDKLogger_JCalls_cloned(&logger_conv);
30057         }
30058         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
30059 }
30060
30061 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) {
30062         LDKChannelMonitor this_arg_conv;
30063         this_arg_conv.inner = untag_ptr(this_arg);
30064         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30066         this_arg_conv.is_owned = false;
30067         uint8_t header_arr[80];
30068         CHECK((*env)->GetArrayLength(env, header) == 80);
30069         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30070         uint8_t (*header_ref)[80] = &header_arr;
30071         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
30072         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
30073         if (txdata_constr.datalen > 0)
30074                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
30075         else
30076                 txdata_constr.data = NULL;
30077         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
30078         for (size_t c = 0; c < txdata_constr.datalen; c++) {
30079                 int64_t txdata_conv_28 = txdata_vals[c];
30080                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
30081                 CHECK_ACCESS(txdata_conv_28_ptr);
30082                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
30083                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
30084                 txdata_constr.data[c] = txdata_conv_28_conv;
30085         }
30086         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
30087         void* broadcaster_ptr = untag_ptr(broadcaster);
30088         CHECK_ACCESS(broadcaster_ptr);
30089         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30090         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30091                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30092                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30093         }
30094         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30095         CHECK_ACCESS(fee_estimator_ptr);
30096         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30097         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30098                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30099                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30100         }
30101         void* logger_ptr = untag_ptr(logger);
30102         CHECK_ACCESS(logger_ptr);
30103         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30104         if (logger_conv.free == LDKLogger_JCalls_free) {
30105                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30106                 LDKLogger_JCalls_cloned(&logger_conv);
30107         }
30108         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);
30109         int64_tArray ret_arr = NULL;
30110         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30111         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30112         for (size_t n = 0; n < ret_var.datalen; n++) {
30113                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30114                 *ret_conv_39_conv = ret_var.data[n];
30115                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30116         }
30117         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30118         FREE(ret_var.data);
30119         return ret_arr;
30120 }
30121
30122 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) {
30123         LDKChannelMonitor this_arg_conv;
30124         this_arg_conv.inner = untag_ptr(this_arg);
30125         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30127         this_arg_conv.is_owned = false;
30128         uint8_t txid_arr[32];
30129         CHECK((*env)->GetArrayLength(env, txid) == 32);
30130         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
30131         uint8_t (*txid_ref)[32] = &txid_arr;
30132         void* broadcaster_ptr = untag_ptr(broadcaster);
30133         CHECK_ACCESS(broadcaster_ptr);
30134         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30135         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30136                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30137                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30138         }
30139         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30140         CHECK_ACCESS(fee_estimator_ptr);
30141         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30142         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30143                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30144                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30145         }
30146         void* logger_ptr = untag_ptr(logger);
30147         CHECK_ACCESS(logger_ptr);
30148         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30149         if (logger_conv.free == LDKLogger_JCalls_free) {
30150                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30151                 LDKLogger_JCalls_cloned(&logger_conv);
30152         }
30153         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
30154 }
30155
30156 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) {
30157         LDKChannelMonitor this_arg_conv;
30158         this_arg_conv.inner = untag_ptr(this_arg);
30159         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30161         this_arg_conv.is_owned = false;
30162         uint8_t header_arr[80];
30163         CHECK((*env)->GetArrayLength(env, header) == 80);
30164         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
30165         uint8_t (*header_ref)[80] = &header_arr;
30166         void* broadcaster_ptr = untag_ptr(broadcaster);
30167         CHECK_ACCESS(broadcaster_ptr);
30168         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30169         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30170                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30171                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30172         }
30173         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30174         CHECK_ACCESS(fee_estimator_ptr);
30175         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30176         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30177                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30178                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30179         }
30180         void* logger_ptr = untag_ptr(logger);
30181         CHECK_ACCESS(logger_ptr);
30182         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30183         if (logger_conv.free == LDKLogger_JCalls_free) {
30184                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30185                 LDKLogger_JCalls_cloned(&logger_conv);
30186         }
30187         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
30188         int64_tArray ret_arr = NULL;
30189         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30190         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30191         for (size_t n = 0; n < ret_var.datalen; n++) {
30192                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
30193                 *ret_conv_39_conv = ret_var.data[n];
30194                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
30195         }
30196         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30197         FREE(ret_var.data);
30198         return ret_arr;
30199 }
30200
30201 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
30202         LDKChannelMonitor this_arg_conv;
30203         this_arg_conv.inner = untag_ptr(this_arg);
30204         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30206         this_arg_conv.is_owned = false;
30207         LDKCVec_C2Tuple_TxidBlockHashZZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_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 z = 0; z < ret_var.datalen; z++) {
30212                 LDKC2Tuple_TxidBlockHashZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
30213                 *ret_conv_25_conv = ret_var.data[z];
30214                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_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_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(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         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
30228         int64_t ret_ref = 0;
30229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30230         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30231         return ret_ref;
30232 }
30233
30234 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) {
30235         LDKChannelMonitor this_arg_conv;
30236         this_arg_conv.inner = untag_ptr(this_arg);
30237         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30239         this_arg_conv.is_owned = false;
30240         void* broadcaster_ptr = untag_ptr(broadcaster);
30241         CHECK_ACCESS(broadcaster_ptr);
30242         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
30243         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30244                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30245                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
30246         }
30247         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30248         CHECK_ACCESS(fee_estimator_ptr);
30249         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30250         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30251                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30252                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30253         }
30254         void* logger_ptr = untag_ptr(logger);
30255         CHECK_ACCESS(logger_ptr);
30256         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30257         if (logger_conv.free == LDKLogger_JCalls_free) {
30258                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30259                 LDKLogger_JCalls_cloned(&logger_conv);
30260         }
30261         ChannelMonitor_rebroadcast_pending_claims(&this_arg_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
30262 }
30263
30264 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
30265         LDKChannelMonitor this_arg_conv;
30266         this_arg_conv.inner = untag_ptr(this_arg);
30267         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30269         this_arg_conv.is_owned = false;
30270         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
30271         int64_tArray ret_arr = NULL;
30272         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30273         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30274         for (size_t j = 0; j < ret_var.datalen; j++) {
30275                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
30276                 *ret_conv_9_copy = ret_var.data[j];
30277                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
30278                 ret_arr_ptr[j] = ret_conv_9_ref;
30279         }
30280         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30281         FREE(ret_var.data);
30282         return ret_arr;
30283 }
30284
30285 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) {
30286         LDKu8slice ser_ref;
30287         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30288         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30289         void* arg_a_ptr = untag_ptr(arg_a);
30290         if (ptr_is_owned(arg_a)) { CHECK_ACCESS(arg_a_ptr); }
30291         LDKEntropySource* arg_a_conv = (LDKEntropySource*)arg_a_ptr;
30292         void* arg_b_ptr = untag_ptr(arg_b);
30293         if (ptr_is_owned(arg_b)) { CHECK_ACCESS(arg_b_ptr); }
30294         LDKSignerProvider* arg_b_conv = (LDKSignerProvider*)arg_b_ptr;
30295         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
30296         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_a_conv, arg_b_conv);
30297         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30298         return tag_ptr(ret_conv, true);
30299 }
30300
30301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30302         LDKOutPoint this_obj_conv;
30303         this_obj_conv.inner = untag_ptr(this_obj);
30304         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30306         OutPoint_free(this_obj_conv);
30307 }
30308
30309 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
30310         LDKOutPoint this_ptr_conv;
30311         this_ptr_conv.inner = untag_ptr(this_ptr);
30312         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30314         this_ptr_conv.is_owned = false;
30315         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30316         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
30317         return ret_arr;
30318 }
30319
30320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30321         LDKOutPoint this_ptr_conv;
30322         this_ptr_conv.inner = untag_ptr(this_ptr);
30323         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30325         this_ptr_conv.is_owned = false;
30326         LDKThirtyTwoBytes val_ref;
30327         CHECK((*env)->GetArrayLength(env, val) == 32);
30328         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30329         OutPoint_set_txid(&this_ptr_conv, val_ref);
30330 }
30331
30332 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
30333         LDKOutPoint this_ptr_conv;
30334         this_ptr_conv.inner = untag_ptr(this_ptr);
30335         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30337         this_ptr_conv.is_owned = false;
30338         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
30339         return ret_conv;
30340 }
30341
30342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30343         LDKOutPoint this_ptr_conv;
30344         this_ptr_conv.inner = untag_ptr(this_ptr);
30345         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30347         this_ptr_conv.is_owned = false;
30348         OutPoint_set_index(&this_ptr_conv, val);
30349 }
30350
30351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
30352         LDKThirtyTwoBytes txid_arg_ref;
30353         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
30354         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
30355         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
30356         int64_t ret_ref = 0;
30357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30358         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30359         return ret_ref;
30360 }
30361
30362 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
30363         LDKOutPoint ret_var = OutPoint_clone(arg);
30364         int64_t ret_ref = 0;
30365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30366         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30367         return ret_ref;
30368 }
30369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30370         LDKOutPoint arg_conv;
30371         arg_conv.inner = untag_ptr(arg);
30372         arg_conv.is_owned = ptr_is_owned(arg);
30373         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30374         arg_conv.is_owned = false;
30375         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
30376         return ret_conv;
30377 }
30378
30379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30380         LDKOutPoint orig_conv;
30381         orig_conv.inner = untag_ptr(orig);
30382         orig_conv.is_owned = ptr_is_owned(orig);
30383         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30384         orig_conv.is_owned = false;
30385         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
30386         int64_t ret_ref = 0;
30387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30388         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30389         return ret_ref;
30390 }
30391
30392 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30393         LDKOutPoint a_conv;
30394         a_conv.inner = untag_ptr(a);
30395         a_conv.is_owned = ptr_is_owned(a);
30396         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30397         a_conv.is_owned = false;
30398         LDKOutPoint b_conv;
30399         b_conv.inner = untag_ptr(b);
30400         b_conv.is_owned = ptr_is_owned(b);
30401         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30402         b_conv.is_owned = false;
30403         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
30404         return ret_conv;
30405 }
30406
30407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
30408         LDKOutPoint o_conv;
30409         o_conv.inner = untag_ptr(o);
30410         o_conv.is_owned = ptr_is_owned(o);
30411         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
30412         o_conv.is_owned = false;
30413         int64_t ret_conv = OutPoint_hash(&o_conv);
30414         return ret_conv;
30415 }
30416
30417 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
30418         LDKOutPoint this_arg_conv;
30419         this_arg_conv.inner = untag_ptr(this_arg);
30420         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30422         this_arg_conv.is_owned = false;
30423         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30424         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
30425         return ret_arr;
30426 }
30427
30428 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
30429         LDKOutPoint obj_conv;
30430         obj_conv.inner = untag_ptr(obj);
30431         obj_conv.is_owned = ptr_is_owned(obj);
30432         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30433         obj_conv.is_owned = false;
30434         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
30435         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30436         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30437         CVec_u8Z_free(ret_var);
30438         return ret_arr;
30439 }
30440
30441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30442         LDKu8slice ser_ref;
30443         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30444         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30445         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
30446         *ret_conv = OutPoint_read(ser_ref);
30447         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30448         return tag_ptr(ret_conv, true);
30449 }
30450
30451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30452         LDKDelayedPaymentOutputDescriptor this_obj_conv;
30453         this_obj_conv.inner = untag_ptr(this_obj);
30454         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30456         DelayedPaymentOutputDescriptor_free(this_obj_conv);
30457 }
30458
30459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30460         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30461         this_ptr_conv.inner = untag_ptr(this_ptr);
30462         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30464         this_ptr_conv.is_owned = false;
30465         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30466         int64_t ret_ref = 0;
30467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30468         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30469         return ret_ref;
30470 }
30471
30472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30473         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30474         this_ptr_conv.inner = untag_ptr(this_ptr);
30475         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30477         this_ptr_conv.is_owned = false;
30478         LDKOutPoint val_conv;
30479         val_conv.inner = untag_ptr(val);
30480         val_conv.is_owned = ptr_is_owned(val);
30481         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30482         val_conv = OutPoint_clone(&val_conv);
30483         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30484 }
30485
30486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30487         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30488         this_ptr_conv.inner = untag_ptr(this_ptr);
30489         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30491         this_ptr_conv.is_owned = false;
30492         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30493         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
30494         return ret_arr;
30495 }
30496
30497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30498         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30499         this_ptr_conv.inner = untag_ptr(this_ptr);
30500         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30502         this_ptr_conv.is_owned = false;
30503         LDKPublicKey val_ref;
30504         CHECK((*env)->GetArrayLength(env, val) == 33);
30505         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30506         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
30507 }
30508
30509 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30510         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30511         this_ptr_conv.inner = untag_ptr(this_ptr);
30512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30514         this_ptr_conv.is_owned = false;
30515         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
30516         return ret_conv;
30517 }
30518
30519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30520         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30521         this_ptr_conv.inner = untag_ptr(this_ptr);
30522         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30524         this_ptr_conv.is_owned = false;
30525         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
30526 }
30527
30528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30529         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30530         this_ptr_conv.inner = untag_ptr(this_ptr);
30531         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30533         this_ptr_conv.is_owned = false;
30534         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30535         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
30536         return tag_ptr(ret_ref, true);
30537 }
30538
30539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_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         void* val_ptr = untag_ptr(val);
30546         CHECK_ACCESS(val_ptr);
30547         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30548         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30549         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30550 }
30551
30552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30553         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30554         this_ptr_conv.inner = untag_ptr(this_ptr);
30555         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30557         this_ptr_conv.is_owned = false;
30558         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30559         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
30560         return ret_arr;
30561 }
30562
30563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30564         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30565         this_ptr_conv.inner = untag_ptr(this_ptr);
30566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30568         this_ptr_conv.is_owned = false;
30569         LDKPublicKey val_ref;
30570         CHECK((*env)->GetArrayLength(env, val) == 33);
30571         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30572         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
30573 }
30574
30575 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30576         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30577         this_ptr_conv.inner = untag_ptr(this_ptr);
30578         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30580         this_ptr_conv.is_owned = false;
30581         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30582         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30583         return ret_arr;
30584 }
30585
30586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30587         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30588         this_ptr_conv.inner = untag_ptr(this_ptr);
30589         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30591         this_ptr_conv.is_owned = false;
30592         LDKThirtyTwoBytes val_ref;
30593         CHECK((*env)->GetArrayLength(env, val) == 32);
30594         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30595         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30596 }
30597
30598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30599         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30600         this_ptr_conv.inner = untag_ptr(this_ptr);
30601         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30603         this_ptr_conv.is_owned = false;
30604         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30605         return ret_conv;
30606 }
30607
30608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30609         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30610         this_ptr_conv.inner = untag_ptr(this_ptr);
30611         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30613         this_ptr_conv.is_owned = false;
30614         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30615 }
30616
30617 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) {
30618         LDKOutPoint outpoint_arg_conv;
30619         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30620         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30621         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30622         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30623         LDKPublicKey per_commitment_point_arg_ref;
30624         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
30625         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
30626         void* output_arg_ptr = untag_ptr(output_arg);
30627         CHECK_ACCESS(output_arg_ptr);
30628         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30629         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30630         LDKPublicKey revocation_pubkey_arg_ref;
30631         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
30632         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
30633         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30634         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30635         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30636         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);
30637         int64_t ret_ref = 0;
30638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30639         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30640         return ret_ref;
30641 }
30642
30643 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
30644         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
30645         int64_t ret_ref = 0;
30646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30647         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30648         return ret_ref;
30649 }
30650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30651         LDKDelayedPaymentOutputDescriptor arg_conv;
30652         arg_conv.inner = untag_ptr(arg);
30653         arg_conv.is_owned = ptr_is_owned(arg);
30654         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30655         arg_conv.is_owned = false;
30656         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
30657         return ret_conv;
30658 }
30659
30660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30661         LDKDelayedPaymentOutputDescriptor orig_conv;
30662         orig_conv.inner = untag_ptr(orig);
30663         orig_conv.is_owned = ptr_is_owned(orig);
30664         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30665         orig_conv.is_owned = false;
30666         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
30667         int64_t ret_ref = 0;
30668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30669         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30670         return ret_ref;
30671 }
30672
30673 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30674         LDKDelayedPaymentOutputDescriptor a_conv;
30675         a_conv.inner = untag_ptr(a);
30676         a_conv.is_owned = ptr_is_owned(a);
30677         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30678         a_conv.is_owned = false;
30679         LDKDelayedPaymentOutputDescriptor b_conv;
30680         b_conv.inner = untag_ptr(b);
30681         b_conv.is_owned = ptr_is_owned(b);
30682         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30683         b_conv.is_owned = false;
30684         jboolean ret_conv = DelayedPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30685         return ret_conv;
30686 }
30687
30688 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30689         LDKDelayedPaymentOutputDescriptor obj_conv;
30690         obj_conv.inner = untag_ptr(obj);
30691         obj_conv.is_owned = ptr_is_owned(obj);
30692         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30693         obj_conv.is_owned = false;
30694         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
30695         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30696         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30697         CVec_u8Z_free(ret_var);
30698         return ret_arr;
30699 }
30700
30701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30702         LDKu8slice ser_ref;
30703         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30704         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30705         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
30706         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
30707         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30708         return tag_ptr(ret_conv, true);
30709 }
30710
30711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30712         LDKStaticPaymentOutputDescriptor this_obj_conv;
30713         this_obj_conv.inner = untag_ptr(this_obj);
30714         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30716         StaticPaymentOutputDescriptor_free(this_obj_conv);
30717 }
30718
30719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30720         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30721         this_ptr_conv.inner = untag_ptr(this_ptr);
30722         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30724         this_ptr_conv.is_owned = false;
30725         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30726         int64_t ret_ref = 0;
30727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30728         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30729         return ret_ref;
30730 }
30731
30732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30733         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30734         this_ptr_conv.inner = untag_ptr(this_ptr);
30735         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30737         this_ptr_conv.is_owned = false;
30738         LDKOutPoint val_conv;
30739         val_conv.inner = untag_ptr(val);
30740         val_conv.is_owned = ptr_is_owned(val);
30741         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30742         val_conv = OutPoint_clone(&val_conv);
30743         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30744 }
30745
30746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30747         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30748         this_ptr_conv.inner = untag_ptr(this_ptr);
30749         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30751         this_ptr_conv.is_owned = false;
30752         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30753         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
30754         return tag_ptr(ret_ref, true);
30755 }
30756
30757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30758         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30759         this_ptr_conv.inner = untag_ptr(this_ptr);
30760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30762         this_ptr_conv.is_owned = false;
30763         void* val_ptr = untag_ptr(val);
30764         CHECK_ACCESS(val_ptr);
30765         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30766         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30767         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30768 }
30769
30770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30771         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30772         this_ptr_conv.inner = untag_ptr(this_ptr);
30773         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30775         this_ptr_conv.is_owned = false;
30776         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30777         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30778         return ret_arr;
30779 }
30780
30781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30782         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30783         this_ptr_conv.inner = untag_ptr(this_ptr);
30784         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30786         this_ptr_conv.is_owned = false;
30787         LDKThirtyTwoBytes val_ref;
30788         CHECK((*env)->GetArrayLength(env, val) == 32);
30789         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30790         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30791 }
30792
30793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30794         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30795         this_ptr_conv.inner = untag_ptr(this_ptr);
30796         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30798         this_ptr_conv.is_owned = false;
30799         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30800         return ret_conv;
30801 }
30802
30803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30804         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30805         this_ptr_conv.inner = untag_ptr(this_ptr);
30806         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30808         this_ptr_conv.is_owned = false;
30809         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30810 }
30811
30812 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) {
30813         LDKOutPoint outpoint_arg_conv;
30814         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30815         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30816         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30817         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30818         void* output_arg_ptr = untag_ptr(output_arg);
30819         CHECK_ACCESS(output_arg_ptr);
30820         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30821         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30822         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30823         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30824         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30825         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
30826         int64_t ret_ref = 0;
30827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30828         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30829         return ret_ref;
30830 }
30831
30832 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
30833         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
30834         int64_t ret_ref = 0;
30835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30836         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30837         return ret_ref;
30838 }
30839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30840         LDKStaticPaymentOutputDescriptor arg_conv;
30841         arg_conv.inner = untag_ptr(arg);
30842         arg_conv.is_owned = ptr_is_owned(arg);
30843         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30844         arg_conv.is_owned = false;
30845         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
30846         return ret_conv;
30847 }
30848
30849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30850         LDKStaticPaymentOutputDescriptor orig_conv;
30851         orig_conv.inner = untag_ptr(orig);
30852         orig_conv.is_owned = ptr_is_owned(orig);
30853         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30854         orig_conv.is_owned = false;
30855         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
30856         int64_t ret_ref = 0;
30857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30859         return ret_ref;
30860 }
30861
30862 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30863         LDKStaticPaymentOutputDescriptor a_conv;
30864         a_conv.inner = untag_ptr(a);
30865         a_conv.is_owned = ptr_is_owned(a);
30866         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30867         a_conv.is_owned = false;
30868         LDKStaticPaymentOutputDescriptor b_conv;
30869         b_conv.inner = untag_ptr(b);
30870         b_conv.is_owned = ptr_is_owned(b);
30871         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30872         b_conv.is_owned = false;
30873         jboolean ret_conv = StaticPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30874         return ret_conv;
30875 }
30876
30877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30878         LDKStaticPaymentOutputDescriptor obj_conv;
30879         obj_conv.inner = untag_ptr(obj);
30880         obj_conv.is_owned = ptr_is_owned(obj);
30881         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30882         obj_conv.is_owned = false;
30883         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
30884         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30885         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30886         CVec_u8Z_free(ret_var);
30887         return ret_arr;
30888 }
30889
30890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30891         LDKu8slice ser_ref;
30892         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30893         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30894         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
30895         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
30896         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30897         return tag_ptr(ret_conv, true);
30898 }
30899
30900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30901         if (!ptr_is_owned(this_ptr)) return;
30902         void* this_ptr_ptr = untag_ptr(this_ptr);
30903         CHECK_ACCESS(this_ptr_ptr);
30904         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
30905         FREE(untag_ptr(this_ptr));
30906         SpendableOutputDescriptor_free(this_ptr_conv);
30907 }
30908
30909 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
30910         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30911         *ret_copy = SpendableOutputDescriptor_clone(arg);
30912         int64_t ret_ref = tag_ptr(ret_copy, true);
30913         return ret_ref;
30914 }
30915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30916         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
30917         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
30918         return ret_conv;
30919 }
30920
30921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30922         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
30923         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30924         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
30925         int64_t ret_ref = tag_ptr(ret_copy, true);
30926         return ret_ref;
30927 }
30928
30929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
30930         LDKOutPoint outpoint_conv;
30931         outpoint_conv.inner = untag_ptr(outpoint);
30932         outpoint_conv.is_owned = ptr_is_owned(outpoint);
30933         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
30934         outpoint_conv = OutPoint_clone(&outpoint_conv);
30935         void* output_ptr = untag_ptr(output);
30936         CHECK_ACCESS(output_ptr);
30937         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
30938         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
30939         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30940         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
30941         int64_t ret_ref = tag_ptr(ret_copy, true);
30942         return ret_ref;
30943 }
30944
30945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30946         LDKDelayedPaymentOutputDescriptor a_conv;
30947         a_conv.inner = untag_ptr(a);
30948         a_conv.is_owned = ptr_is_owned(a);
30949         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30950         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
30951         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30952         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
30953         int64_t ret_ref = tag_ptr(ret_copy, true);
30954         return ret_ref;
30955 }
30956
30957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30958         LDKStaticPaymentOutputDescriptor a_conv;
30959         a_conv.inner = untag_ptr(a);
30960         a_conv.is_owned = ptr_is_owned(a);
30961         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30962         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
30963         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30964         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
30965         int64_t ret_ref = tag_ptr(ret_copy, true);
30966         return ret_ref;
30967 }
30968
30969 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30970         LDKSpendableOutputDescriptor* a_conv = (LDKSpendableOutputDescriptor*)untag_ptr(a);
30971         LDKSpendableOutputDescriptor* b_conv = (LDKSpendableOutputDescriptor*)untag_ptr(b);
30972         jboolean ret_conv = SpendableOutputDescriptor_eq(a_conv, b_conv);
30973         return ret_conv;
30974 }
30975
30976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30977         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
30978         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
30979         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30980         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30981         CVec_u8Z_free(ret_var);
30982         return ret_arr;
30983 }
30984
30985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30986         LDKu8slice ser_ref;
30987         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30988         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30989         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
30990         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
30991         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30992         return tag_ptr(ret_conv, true);
30993 }
30994
30995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30996         if (!ptr_is_owned(this_ptr)) return;
30997         void* this_ptr_ptr = untag_ptr(this_ptr);
30998         CHECK_ACCESS(this_ptr_ptr);
30999         LDKChannelSigner this_ptr_conv = *(LDKChannelSigner*)(this_ptr_ptr);
31000         FREE(untag_ptr(this_ptr));
31001         ChannelSigner_free(this_ptr_conv);
31002 }
31003
31004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EcdsaChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31005         if (!ptr_is_owned(this_ptr)) return;
31006         void* this_ptr_ptr = untag_ptr(this_ptr);
31007         CHECK_ACCESS(this_ptr_ptr);
31008         LDKEcdsaChannelSigner this_ptr_conv = *(LDKEcdsaChannelSigner*)(this_ptr_ptr);
31009         FREE(untag_ptr(this_ptr));
31010         EcdsaChannelSigner_free(this_ptr_conv);
31011 }
31012
31013 static inline uint64_t WriteableEcdsaChannelSigner_clone_ptr(LDKWriteableEcdsaChannelSigner *NONNULL_PTR arg) {
31014         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31015         *ret_ret = WriteableEcdsaChannelSigner_clone(arg);
31016         return tag_ptr(ret_ret, true);
31017 }
31018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31019         void* arg_ptr = untag_ptr(arg);
31020         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
31021         LDKWriteableEcdsaChannelSigner* arg_conv = (LDKWriteableEcdsaChannelSigner*)arg_ptr;
31022         int64_t ret_conv = WriteableEcdsaChannelSigner_clone_ptr(arg_conv);
31023         return ret_conv;
31024 }
31025
31026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31027         void* orig_ptr = untag_ptr(orig);
31028         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
31029         LDKWriteableEcdsaChannelSigner* orig_conv = (LDKWriteableEcdsaChannelSigner*)orig_ptr;
31030         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31031         *ret_ret = WriteableEcdsaChannelSigner_clone(orig_conv);
31032         return tag_ptr(ret_ret, true);
31033 }
31034
31035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableEcdsaChannelSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31036         if (!ptr_is_owned(this_ptr)) return;
31037         void* this_ptr_ptr = untag_ptr(this_ptr);
31038         CHECK_ACCESS(this_ptr_ptr);
31039         LDKWriteableEcdsaChannelSigner this_ptr_conv = *(LDKWriteableEcdsaChannelSigner*)(this_ptr_ptr);
31040         FREE(untag_ptr(this_ptr));
31041         WriteableEcdsaChannelSigner_free(this_ptr_conv);
31042 }
31043
31044 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31045         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
31046         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
31047         return ret_conv;
31048 }
31049
31050 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
31051         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
31052         return ret_conv;
31053 }
31054
31055 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
31056         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
31057         return ret_conv;
31058 }
31059
31060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EntropySource_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31061         if (!ptr_is_owned(this_ptr)) return;
31062         void* this_ptr_ptr = untag_ptr(this_ptr);
31063         CHECK_ACCESS(this_ptr_ptr);
31064         LDKEntropySource this_ptr_conv = *(LDKEntropySource*)(this_ptr_ptr);
31065         FREE(untag_ptr(this_ptr));
31066         EntropySource_free(this_ptr_conv);
31067 }
31068
31069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeSigner_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31070         if (!ptr_is_owned(this_ptr)) return;
31071         void* this_ptr_ptr = untag_ptr(this_ptr);
31072         CHECK_ACCESS(this_ptr_ptr);
31073         LDKNodeSigner this_ptr_conv = *(LDKNodeSigner*)(this_ptr_ptr);
31074         FREE(untag_ptr(this_ptr));
31075         NodeSigner_free(this_ptr_conv);
31076 }
31077
31078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignerProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31079         if (!ptr_is_owned(this_ptr)) return;
31080         void* this_ptr_ptr = untag_ptr(this_ptr);
31081         CHECK_ACCESS(this_ptr_ptr);
31082         LDKSignerProvider this_ptr_conv = *(LDKSignerProvider*)(this_ptr_ptr);
31083         FREE(untag_ptr(this_ptr));
31084         SignerProvider_free(this_ptr_conv);
31085 }
31086
31087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31088         LDKInMemorySigner this_obj_conv;
31089         this_obj_conv.inner = untag_ptr(this_obj);
31090         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31092         InMemorySigner_free(this_obj_conv);
31093 }
31094
31095 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31096         LDKInMemorySigner this_ptr_conv;
31097         this_ptr_conv.inner = untag_ptr(this_ptr);
31098         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31100         this_ptr_conv.is_owned = false;
31101         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31102         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
31103         return ret_arr;
31104 }
31105
31106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31107         LDKInMemorySigner this_ptr_conv;
31108         this_ptr_conv.inner = untag_ptr(this_ptr);
31109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31111         this_ptr_conv.is_owned = false;
31112         LDKSecretKey val_ref;
31113         CHECK((*env)->GetArrayLength(env, val) == 32);
31114         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31115         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
31116 }
31117
31118 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31119         LDKInMemorySigner this_ptr_conv;
31120         this_ptr_conv.inner = untag_ptr(this_ptr);
31121         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31123         this_ptr_conv.is_owned = false;
31124         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31125         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
31126         return ret_arr;
31127 }
31128
31129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31130         LDKInMemorySigner this_ptr_conv;
31131         this_ptr_conv.inner = untag_ptr(this_ptr);
31132         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31134         this_ptr_conv.is_owned = false;
31135         LDKSecretKey val_ref;
31136         CHECK((*env)->GetArrayLength(env, val) == 32);
31137         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31138         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
31139 }
31140
31141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31142         LDKInMemorySigner this_ptr_conv;
31143         this_ptr_conv.inner = untag_ptr(this_ptr);
31144         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31146         this_ptr_conv.is_owned = false;
31147         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31148         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
31149         return ret_arr;
31150 }
31151
31152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31153         LDKInMemorySigner this_ptr_conv;
31154         this_ptr_conv.inner = untag_ptr(this_ptr);
31155         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31157         this_ptr_conv.is_owned = false;
31158         LDKSecretKey val_ref;
31159         CHECK((*env)->GetArrayLength(env, val) == 32);
31160         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31161         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
31162 }
31163
31164 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31165         LDKInMemorySigner this_ptr_conv;
31166         this_ptr_conv.inner = untag_ptr(this_ptr);
31167         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31169         this_ptr_conv.is_owned = false;
31170         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31171         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
31172         return ret_arr;
31173 }
31174
31175 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) {
31176         LDKInMemorySigner this_ptr_conv;
31177         this_ptr_conv.inner = untag_ptr(this_ptr);
31178         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31180         this_ptr_conv.is_owned = false;
31181         LDKSecretKey val_ref;
31182         CHECK((*env)->GetArrayLength(env, val) == 32);
31183         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31184         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
31185 }
31186
31187 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31188         LDKInMemorySigner this_ptr_conv;
31189         this_ptr_conv.inner = untag_ptr(this_ptr);
31190         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31192         this_ptr_conv.is_owned = false;
31193         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31194         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
31195         return ret_arr;
31196 }
31197
31198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31199         LDKInMemorySigner this_ptr_conv;
31200         this_ptr_conv.inner = untag_ptr(this_ptr);
31201         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31203         this_ptr_conv.is_owned = false;
31204         LDKSecretKey val_ref;
31205         CHECK((*env)->GetArrayLength(env, val) == 32);
31206         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
31207         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
31208 }
31209
31210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
31211         LDKInMemorySigner this_ptr_conv;
31212         this_ptr_conv.inner = untag_ptr(this_ptr);
31213         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31215         this_ptr_conv.is_owned = false;
31216         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31217         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
31218         return ret_arr;
31219 }
31220
31221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31222         LDKInMemorySigner this_ptr_conv;
31223         this_ptr_conv.inner = untag_ptr(this_ptr);
31224         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31226         this_ptr_conv.is_owned = false;
31227         LDKThirtyTwoBytes val_ref;
31228         CHECK((*env)->GetArrayLength(env, val) == 32);
31229         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31230         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
31231 }
31232
31233 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
31234         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
31235         int64_t ret_ref = 0;
31236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31237         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31238         return ret_ref;
31239 }
31240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31241         LDKInMemorySigner arg_conv;
31242         arg_conv.inner = untag_ptr(arg);
31243         arg_conv.is_owned = ptr_is_owned(arg);
31244         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31245         arg_conv.is_owned = false;
31246         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
31247         return ret_conv;
31248 }
31249
31250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31251         LDKInMemorySigner orig_conv;
31252         orig_conv.inner = untag_ptr(orig);
31253         orig_conv.is_owned = ptr_is_owned(orig);
31254         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31255         orig_conv.is_owned = false;
31256         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
31257         int64_t ret_ref = 0;
31258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31260         return ret_ref;
31261 }
31262
31263 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) {
31264         LDKSecretKey funding_key_ref;
31265         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
31266         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
31267         LDKSecretKey revocation_base_key_ref;
31268         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
31269         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
31270         LDKSecretKey payment_key_ref;
31271         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
31272         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
31273         LDKSecretKey delayed_payment_base_key_ref;
31274         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
31275         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
31276         LDKSecretKey htlc_base_key_ref;
31277         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
31278         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
31279         LDKThirtyTwoBytes commitment_seed_ref;
31280         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
31281         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
31282         LDKThirtyTwoBytes channel_keys_id_ref;
31283         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
31284         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
31285         LDKThirtyTwoBytes rand_bytes_unique_start_ref;
31286         CHECK((*env)->GetArrayLength(env, rand_bytes_unique_start) == 32);
31287         (*env)->GetByteArrayRegion(env, rand_bytes_unique_start, 0, 32, rand_bytes_unique_start_ref.data);
31288         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);
31289         int64_t ret_ref = 0;
31290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31291         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31292         return ret_ref;
31293 }
31294
31295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
31296         LDKInMemorySigner this_arg_conv;
31297         this_arg_conv.inner = untag_ptr(this_arg);
31298         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31300         this_arg_conv.is_owned = false;
31301         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
31302         int64_t ret_ref = 0;
31303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31304         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31305         return ret_ref;
31306 }
31307
31308 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
31309         LDKInMemorySigner this_arg_conv;
31310         this_arg_conv.inner = untag_ptr(this_arg);
31311         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31313         this_arg_conv.is_owned = false;
31314         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
31315         return ret_conv;
31316 }
31317
31318 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
31319         LDKInMemorySigner this_arg_conv;
31320         this_arg_conv.inner = untag_ptr(this_arg);
31321         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31323         this_arg_conv.is_owned = false;
31324         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
31325         return ret_conv;
31326 }
31327
31328 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(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         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
31335         return ret_conv;
31336 }
31337
31338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(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         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
31345         int64_t ret_ref = 0;
31346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31347         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31348         return ret_ref;
31349 }
31350
31351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
31352         LDKInMemorySigner this_arg_conv;
31353         this_arg_conv.inner = untag_ptr(this_arg);
31354         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31356         this_arg_conv.is_owned = false;
31357         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
31358         int64_t ret_ref = 0;
31359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31360         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31361         return ret_ref;
31362 }
31363
31364 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
31365         LDKInMemorySigner this_arg_conv;
31366         this_arg_conv.inner = untag_ptr(this_arg);
31367         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31369         this_arg_conv.is_owned = false;
31370         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
31371         return ret_conv;
31372 }
31373
31374 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) {
31375         LDKInMemorySigner this_arg_conv;
31376         this_arg_conv.inner = untag_ptr(this_arg);
31377         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31379         this_arg_conv.is_owned = false;
31380         LDKTransaction spend_tx_ref;
31381         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
31382         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
31383         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31384         spend_tx_ref.data_is_owned = true;
31385         LDKStaticPaymentOutputDescriptor descriptor_conv;
31386         descriptor_conv.inner = untag_ptr(descriptor);
31387         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31388         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31389         descriptor_conv.is_owned = false;
31390         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31391         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31392         return tag_ptr(ret_conv, true);
31393 }
31394
31395 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) {
31396         LDKInMemorySigner this_arg_conv;
31397         this_arg_conv.inner = untag_ptr(this_arg);
31398         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31400         this_arg_conv.is_owned = false;
31401         LDKTransaction spend_tx_ref;
31402         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
31403         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
31404         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31405         spend_tx_ref.data_is_owned = true;
31406         LDKDelayedPaymentOutputDescriptor descriptor_conv;
31407         descriptor_conv.inner = untag_ptr(descriptor);
31408         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31409         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31410         descriptor_conv.is_owned = false;
31411         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31412         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31413         return tag_ptr(ret_conv, true);
31414 }
31415
31416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1EntropySource(JNIEnv *env, jclass clz, int64_t this_arg) {
31417         LDKInMemorySigner this_arg_conv;
31418         this_arg_conv.inner = untag_ptr(this_arg);
31419         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31421         this_arg_conv.is_owned = false;
31422         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31423         *ret_ret = InMemorySigner_as_EntropySource(&this_arg_conv);
31424         return tag_ptr(ret_ret, true);
31425 }
31426
31427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1ChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31428         LDKInMemorySigner this_arg_conv;
31429         this_arg_conv.inner = untag_ptr(this_arg);
31430         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31432         this_arg_conv.is_owned = false;
31433         LDKChannelSigner* ret_ret = MALLOC(sizeof(LDKChannelSigner), "LDKChannelSigner");
31434         *ret_ret = InMemorySigner_as_ChannelSigner(&this_arg_conv);
31435         return tag_ptr(ret_ret, true);
31436 }
31437
31438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1EcdsaChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31439         LDKInMemorySigner this_arg_conv;
31440         this_arg_conv.inner = untag_ptr(this_arg);
31441         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31443         this_arg_conv.is_owned = false;
31444         LDKEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKEcdsaChannelSigner), "LDKEcdsaChannelSigner");
31445         *ret_ret = InMemorySigner_as_EcdsaChannelSigner(&this_arg_conv);
31446         return tag_ptr(ret_ret, true);
31447 }
31448
31449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1WriteableEcdsaChannelSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31450         LDKInMemorySigner this_arg_conv;
31451         this_arg_conv.inner = untag_ptr(this_arg);
31452         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31454         this_arg_conv.is_owned = false;
31455         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
31456         *ret_ret = InMemorySigner_as_WriteableEcdsaChannelSigner(&this_arg_conv);
31457         return tag_ptr(ret_ret, true);
31458 }
31459
31460 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
31461         LDKInMemorySigner obj_conv;
31462         obj_conv.inner = untag_ptr(obj);
31463         obj_conv.is_owned = ptr_is_owned(obj);
31464         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31465         obj_conv.is_owned = false;
31466         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
31467         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31468         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31469         CVec_u8Z_free(ret_var);
31470         return ret_arr;
31471 }
31472
31473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
31474         LDKu8slice ser_ref;
31475         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31476         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31477         void* arg_ptr = untag_ptr(arg);
31478         CHECK_ACCESS(arg_ptr);
31479         LDKEntropySource arg_conv = *(LDKEntropySource*)(arg_ptr);
31480         if (arg_conv.free == LDKEntropySource_JCalls_free) {
31481                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31482                 LDKEntropySource_JCalls_cloned(&arg_conv);
31483         }
31484         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
31485         *ret_conv = InMemorySigner_read(ser_ref, arg_conv);
31486         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31487         return tag_ptr(ret_conv, true);
31488 }
31489
31490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31491         LDKKeysManager this_obj_conv;
31492         this_obj_conv.inner = untag_ptr(this_obj);
31493         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31495         KeysManager_free(this_obj_conv);
31496 }
31497
31498 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) {
31499         uint8_t seed_arr[32];
31500         CHECK((*env)->GetArrayLength(env, seed) == 32);
31501         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31502         uint8_t (*seed_ref)[32] = &seed_arr;
31503         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
31504         int64_t ret_ref = 0;
31505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31506         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31507         return ret_ref;
31508 }
31509
31510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysManager_1get_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31511         LDKKeysManager this_arg_conv;
31512         this_arg_conv.inner = untag_ptr(this_arg);
31513         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31515         this_arg_conv.is_owned = false;
31516         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31517         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, KeysManager_get_node_secret_key(&this_arg_conv).bytes);
31518         return ret_arr;
31519 }
31520
31521 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) {
31522         LDKKeysManager this_arg_conv;
31523         this_arg_conv.inner = untag_ptr(this_arg);
31524         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31526         this_arg_conv.is_owned = false;
31527         uint8_t params_arr[32];
31528         CHECK((*env)->GetArrayLength(env, params) == 32);
31529         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31530         uint8_t (*params_ref)[32] = &params_arr;
31531         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31532         int64_t ret_ref = 0;
31533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31534         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31535         return ret_ref;
31536 }
31537
31538 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) {
31539         LDKKeysManager this_arg_conv;
31540         this_arg_conv.inner = untag_ptr(this_arg);
31541         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31543         this_arg_conv.is_owned = false;
31544         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31545         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31546         if (descriptors_constr.datalen > 0)
31547                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31548         else
31549                 descriptors_constr.data = NULL;
31550         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31551         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31552                 int64_t descriptors_conv_27 = descriptors_vals[b];
31553                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31554                 CHECK_ACCESS(descriptors_conv_27_ptr);
31555                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31556                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31557                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31558         }
31559         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31560         LDKCVec_TxOutZ outputs_constr;
31561         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31562         if (outputs_constr.datalen > 0)
31563                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31564         else
31565                 outputs_constr.data = NULL;
31566         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31567         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31568                 int64_t outputs_conv_7 = outputs_vals[h];
31569                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31570                 CHECK_ACCESS(outputs_conv_7_ptr);
31571                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31572                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31573                 outputs_constr.data[h] = outputs_conv_7_conv;
31574         }
31575         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31576         LDKCVec_u8Z change_destination_script_ref;
31577         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31578         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31579         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31580         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31581         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31582         return tag_ptr(ret_conv, true);
31583 }
31584
31585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1EntropySource(JNIEnv *env, jclass clz, int64_t this_arg) {
31586         LDKKeysManager this_arg_conv;
31587         this_arg_conv.inner = untag_ptr(this_arg);
31588         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31590         this_arg_conv.is_owned = false;
31591         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31592         *ret_ret = KeysManager_as_EntropySource(&this_arg_conv);
31593         return tag_ptr(ret_ret, true);
31594 }
31595
31596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1NodeSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31597         LDKKeysManager this_arg_conv;
31598         this_arg_conv.inner = untag_ptr(this_arg);
31599         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31601         this_arg_conv.is_owned = false;
31602         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
31603         *ret_ret = KeysManager_as_NodeSigner(&this_arg_conv);
31604         return tag_ptr(ret_ret, true);
31605 }
31606
31607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1SignerProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31608         LDKKeysManager this_arg_conv;
31609         this_arg_conv.inner = untag_ptr(this_arg);
31610         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31612         this_arg_conv.is_owned = false;
31613         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
31614         *ret_ret = KeysManager_as_SignerProvider(&this_arg_conv);
31615         return tag_ptr(ret_ret, true);
31616 }
31617
31618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31619         LDKPhantomKeysManager this_obj_conv;
31620         this_obj_conv.inner = untag_ptr(this_obj);
31621         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31623         PhantomKeysManager_free(this_obj_conv);
31624 }
31625
31626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1EntropySource(JNIEnv *env, jclass clz, int64_t this_arg) {
31627         LDKPhantomKeysManager this_arg_conv;
31628         this_arg_conv.inner = untag_ptr(this_arg);
31629         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31631         this_arg_conv.is_owned = false;
31632         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
31633         *ret_ret = PhantomKeysManager_as_EntropySource(&this_arg_conv);
31634         return tag_ptr(ret_ret, true);
31635 }
31636
31637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1NodeSigner(JNIEnv *env, jclass clz, int64_t this_arg) {
31638         LDKPhantomKeysManager this_arg_conv;
31639         this_arg_conv.inner = untag_ptr(this_arg);
31640         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31642         this_arg_conv.is_owned = false;
31643         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
31644         *ret_ret = PhantomKeysManager_as_NodeSigner(&this_arg_conv);
31645         return tag_ptr(ret_ret, true);
31646 }
31647
31648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1SignerProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31649         LDKPhantomKeysManager this_arg_conv;
31650         this_arg_conv.inner = untag_ptr(this_arg);
31651         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31653         this_arg_conv.is_owned = false;
31654         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
31655         *ret_ret = PhantomKeysManager_as_SignerProvider(&this_arg_conv);
31656         return tag_ptr(ret_ret, true);
31657 }
31658
31659 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) {
31660         uint8_t seed_arr[32];
31661         CHECK((*env)->GetArrayLength(env, seed) == 32);
31662         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31663         uint8_t (*seed_ref)[32] = &seed_arr;
31664         uint8_t cross_node_seed_arr[32];
31665         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
31666         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
31667         uint8_t (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
31668         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
31669         int64_t ret_ref = 0;
31670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31671         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31672         return ret_ref;
31673 }
31674
31675 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) {
31676         LDKPhantomKeysManager this_arg_conv;
31677         this_arg_conv.inner = untag_ptr(this_arg);
31678         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31680         this_arg_conv.is_owned = false;
31681         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31682         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31683         if (descriptors_constr.datalen > 0)
31684                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31685         else
31686                 descriptors_constr.data = NULL;
31687         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31688         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31689                 int64_t descriptors_conv_27 = descriptors_vals[b];
31690                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31691                 CHECK_ACCESS(descriptors_conv_27_ptr);
31692                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31693                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31694                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31695         }
31696         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31697         LDKCVec_TxOutZ outputs_constr;
31698         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31699         if (outputs_constr.datalen > 0)
31700                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31701         else
31702                 outputs_constr.data = NULL;
31703         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31704         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31705                 int64_t outputs_conv_7 = outputs_vals[h];
31706                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31707                 CHECK_ACCESS(outputs_conv_7_ptr);
31708                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31709                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31710                 outputs_constr.data[h] = outputs_conv_7_conv;
31711         }
31712         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31713         LDKCVec_u8Z change_destination_script_ref;
31714         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31715         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31716         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31717         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31718         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31719         return tag_ptr(ret_conv, true);
31720 }
31721
31722 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) {
31723         LDKPhantomKeysManager this_arg_conv;
31724         this_arg_conv.inner = untag_ptr(this_arg);
31725         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31727         this_arg_conv.is_owned = false;
31728         uint8_t params_arr[32];
31729         CHECK((*env)->GetArrayLength(env, params) == 32);
31730         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31731         uint8_t (*params_ref)[32] = &params_arr;
31732         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31733         int64_t ret_ref = 0;
31734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31735         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31736         return ret_ref;
31737 }
31738
31739 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1get_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31740         LDKPhantomKeysManager this_arg_conv;
31741         this_arg_conv.inner = untag_ptr(this_arg);
31742         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31744         this_arg_conv.is_owned = false;
31745         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31746         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, PhantomKeysManager_get_node_secret_key(&this_arg_conv).bytes);
31747         return ret_arr;
31748 }
31749
31750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1get_1phantom_1node_1secret_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
31751         LDKPhantomKeysManager this_arg_conv;
31752         this_arg_conv.inner = untag_ptr(this_arg);
31753         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31755         this_arg_conv.is_owned = false;
31756         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31757         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, PhantomKeysManager_get_phantom_node_secret_key(&this_arg_conv).bytes);
31758         return ret_arr;
31759 }
31760
31761 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31762         LDKFailureCode* orig_conv = (LDKFailureCode*)untag_ptr(orig);
31763         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_clone(orig_conv));
31764         return ret_conv;
31765 }
31766
31767 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1temporary_1node_1failure(JNIEnv *env, jclass clz) {
31768         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_temporary_node_failure());
31769         return ret_conv;
31770 }
31771
31772 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1required_1node_1feature_1missing(JNIEnv *env, jclass clz) {
31773         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_required_node_feature_missing());
31774         return ret_conv;
31775 }
31776
31777 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_FailureCode_1incorrect_1or_1unknown_1payment_1details(JNIEnv *env, jclass clz) {
31778         jclass ret_conv = LDKFailureCode_to_java(env, FailureCode_incorrect_or_unknown_payment_details());
31779         return ret_conv;
31780 }
31781
31782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31783         LDKChannelManager this_obj_conv;
31784         this_obj_conv.inner = untag_ptr(this_obj);
31785         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31787         ChannelManager_free(this_obj_conv);
31788 }
31789
31790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31791         LDKChainParameters this_obj_conv;
31792         this_obj_conv.inner = untag_ptr(this_obj);
31793         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31795         ChainParameters_free(this_obj_conv);
31796 }
31797
31798 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
31799         LDKChainParameters this_ptr_conv;
31800         this_ptr_conv.inner = untag_ptr(this_ptr);
31801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31803         this_ptr_conv.is_owned = false;
31804         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
31805         return ret_conv;
31806 }
31807
31808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
31809         LDKChainParameters this_ptr_conv;
31810         this_ptr_conv.inner = untag_ptr(this_ptr);
31811         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31813         this_ptr_conv.is_owned = false;
31814         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
31815         ChainParameters_set_network(&this_ptr_conv, val_conv);
31816 }
31817
31818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(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         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
31825         int64_t ret_ref = 0;
31826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31827         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31828         return ret_ref;
31829 }
31830
31831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31832         LDKChainParameters this_ptr_conv;
31833         this_ptr_conv.inner = untag_ptr(this_ptr);
31834         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31836         this_ptr_conv.is_owned = false;
31837         LDKBestBlock val_conv;
31838         val_conv.inner = untag_ptr(val);
31839         val_conv.is_owned = ptr_is_owned(val);
31840         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31841         val_conv = BestBlock_clone(&val_conv);
31842         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
31843 }
31844
31845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
31846         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
31847         LDKBestBlock best_block_arg_conv;
31848         best_block_arg_conv.inner = untag_ptr(best_block_arg);
31849         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
31850         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
31851         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
31852         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
31853         int64_t ret_ref = 0;
31854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31855         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31856         return ret_ref;
31857 }
31858
31859 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
31860         LDKChainParameters ret_var = ChainParameters_clone(arg);
31861         int64_t ret_ref = 0;
31862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31863         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31864         return ret_ref;
31865 }
31866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31867         LDKChainParameters arg_conv;
31868         arg_conv.inner = untag_ptr(arg);
31869         arg_conv.is_owned = ptr_is_owned(arg);
31870         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31871         arg_conv.is_owned = false;
31872         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
31873         return ret_conv;
31874 }
31875
31876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31877         LDKChainParameters orig_conv;
31878         orig_conv.inner = untag_ptr(orig);
31879         orig_conv.is_owned = ptr_is_owned(orig);
31880         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31881         orig_conv.is_owned = false;
31882         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
31883         int64_t ret_ref = 0;
31884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31885         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31886         return ret_ref;
31887 }
31888
31889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31890         LDKCounterpartyForwardingInfo this_obj_conv;
31891         this_obj_conv.inner = untag_ptr(this_obj);
31892         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31894         CounterpartyForwardingInfo_free(this_obj_conv);
31895 }
31896
31897 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31898         LDKCounterpartyForwardingInfo this_ptr_conv;
31899         this_ptr_conv.inner = untag_ptr(this_ptr);
31900         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31902         this_ptr_conv.is_owned = false;
31903         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
31904         return ret_conv;
31905 }
31906
31907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31908         LDKCounterpartyForwardingInfo this_ptr_conv;
31909         this_ptr_conv.inner = untag_ptr(this_ptr);
31910         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31912         this_ptr_conv.is_owned = false;
31913         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
31914 }
31915
31916 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
31917         LDKCounterpartyForwardingInfo this_ptr_conv;
31918         this_ptr_conv.inner = untag_ptr(this_ptr);
31919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31921         this_ptr_conv.is_owned = false;
31922         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
31923         return ret_conv;
31924 }
31925
31926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31927         LDKCounterpartyForwardingInfo this_ptr_conv;
31928         this_ptr_conv.inner = untag_ptr(this_ptr);
31929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31931         this_ptr_conv.is_owned = false;
31932         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
31933 }
31934
31935 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
31936         LDKCounterpartyForwardingInfo this_ptr_conv;
31937         this_ptr_conv.inner = untag_ptr(this_ptr);
31938         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31940         this_ptr_conv.is_owned = false;
31941         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
31942         return ret_conv;
31943 }
31944
31945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31946         LDKCounterpartyForwardingInfo this_ptr_conv;
31947         this_ptr_conv.inner = untag_ptr(this_ptr);
31948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31950         this_ptr_conv.is_owned = false;
31951         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
31952 }
31953
31954 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) {
31955         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
31956         int64_t ret_ref = 0;
31957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31958         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31959         return ret_ref;
31960 }
31961
31962 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
31963         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
31964         int64_t ret_ref = 0;
31965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31967         return ret_ref;
31968 }
31969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31970         LDKCounterpartyForwardingInfo arg_conv;
31971         arg_conv.inner = untag_ptr(arg);
31972         arg_conv.is_owned = ptr_is_owned(arg);
31973         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31974         arg_conv.is_owned = false;
31975         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
31976         return ret_conv;
31977 }
31978
31979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31980         LDKCounterpartyForwardingInfo orig_conv;
31981         orig_conv.inner = untag_ptr(orig);
31982         orig_conv.is_owned = ptr_is_owned(orig);
31983         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31984         orig_conv.is_owned = false;
31985         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
31986         int64_t ret_ref = 0;
31987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31989         return ret_ref;
31990 }
31991
31992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31993         LDKChannelCounterparty this_obj_conv;
31994         this_obj_conv.inner = untag_ptr(this_obj);
31995         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31997         ChannelCounterparty_free(this_obj_conv);
31998 }
31999
32000 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32001         LDKChannelCounterparty this_ptr_conv;
32002         this_ptr_conv.inner = untag_ptr(this_ptr);
32003         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32005         this_ptr_conv.is_owned = false;
32006         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32007         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
32008         return ret_arr;
32009 }
32010
32011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32012         LDKChannelCounterparty this_ptr_conv;
32013         this_ptr_conv.inner = untag_ptr(this_ptr);
32014         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32016         this_ptr_conv.is_owned = false;
32017         LDKPublicKey val_ref;
32018         CHECK((*env)->GetArrayLength(env, val) == 33);
32019         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32020         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
32021 }
32022
32023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
32024         LDKChannelCounterparty this_ptr_conv;
32025         this_ptr_conv.inner = untag_ptr(this_ptr);
32026         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32028         this_ptr_conv.is_owned = false;
32029         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
32030         int64_t ret_ref = 0;
32031         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32032         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32033         return ret_ref;
32034 }
32035
32036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32037         LDKChannelCounterparty this_ptr_conv;
32038         this_ptr_conv.inner = untag_ptr(this_ptr);
32039         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32041         this_ptr_conv.is_owned = false;
32042         LDKInitFeatures val_conv;
32043         val_conv.inner = untag_ptr(val);
32044         val_conv.is_owned = ptr_is_owned(val);
32045         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32046         val_conv = InitFeatures_clone(&val_conv);
32047         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
32048 }
32049
32050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
32051         LDKChannelCounterparty this_ptr_conv;
32052         this_ptr_conv.inner = untag_ptr(this_ptr);
32053         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32055         this_ptr_conv.is_owned = false;
32056         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
32057         return ret_conv;
32058 }
32059
32060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32061         LDKChannelCounterparty this_ptr_conv;
32062         this_ptr_conv.inner = untag_ptr(this_ptr);
32063         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32065         this_ptr_conv.is_owned = false;
32066         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
32067 }
32068
32069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
32070         LDKChannelCounterparty this_ptr_conv;
32071         this_ptr_conv.inner = untag_ptr(this_ptr);
32072         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32074         this_ptr_conv.is_owned = false;
32075         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
32076         int64_t ret_ref = 0;
32077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32078         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32079         return ret_ref;
32080 }
32081
32082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32083         LDKChannelCounterparty this_ptr_conv;
32084         this_ptr_conv.inner = untag_ptr(this_ptr);
32085         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32087         this_ptr_conv.is_owned = false;
32088         LDKCounterpartyForwardingInfo val_conv;
32089         val_conv.inner = untag_ptr(val);
32090         val_conv.is_owned = ptr_is_owned(val);
32091         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32092         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
32093         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
32094 }
32095
32096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32097         LDKChannelCounterparty this_ptr_conv;
32098         this_ptr_conv.inner = untag_ptr(this_ptr);
32099         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32101         this_ptr_conv.is_owned = false;
32102         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32103         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
32104         int64_t ret_ref = tag_ptr(ret_copy, true);
32105         return ret_ref;
32106 }
32107
32108 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) {
32109         LDKChannelCounterparty this_ptr_conv;
32110         this_ptr_conv.inner = untag_ptr(this_ptr);
32111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32113         this_ptr_conv.is_owned = false;
32114         void* val_ptr = untag_ptr(val);
32115         CHECK_ACCESS(val_ptr);
32116         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32117         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32118         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
32119 }
32120
32121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32122         LDKChannelCounterparty this_ptr_conv;
32123         this_ptr_conv.inner = untag_ptr(this_ptr);
32124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32126         this_ptr_conv.is_owned = false;
32127         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32128         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
32129         int64_t ret_ref = tag_ptr(ret_copy, true);
32130         return ret_ref;
32131 }
32132
32133 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) {
32134         LDKChannelCounterparty this_ptr_conv;
32135         this_ptr_conv.inner = untag_ptr(this_ptr);
32136         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32138         this_ptr_conv.is_owned = false;
32139         void* val_ptr = untag_ptr(val);
32140         CHECK_ACCESS(val_ptr);
32141         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32142         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32143         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
32144 }
32145
32146 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) {
32147         LDKPublicKey node_id_arg_ref;
32148         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
32149         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
32150         LDKInitFeatures features_arg_conv;
32151         features_arg_conv.inner = untag_ptr(features_arg);
32152         features_arg_conv.is_owned = ptr_is_owned(features_arg);
32153         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
32154         features_arg_conv = InitFeatures_clone(&features_arg_conv);
32155         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
32156         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
32157         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
32158         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
32159         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
32160         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
32161         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
32162         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
32163         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
32164         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
32165         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
32166         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
32167         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
32168         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);
32169         int64_t ret_ref = 0;
32170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32171         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32172         return ret_ref;
32173 }
32174
32175 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
32176         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
32177         int64_t ret_ref = 0;
32178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32179         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32180         return ret_ref;
32181 }
32182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32183         LDKChannelCounterparty arg_conv;
32184         arg_conv.inner = untag_ptr(arg);
32185         arg_conv.is_owned = ptr_is_owned(arg);
32186         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32187         arg_conv.is_owned = false;
32188         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
32189         return ret_conv;
32190 }
32191
32192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32193         LDKChannelCounterparty orig_conv;
32194         orig_conv.inner = untag_ptr(orig);
32195         orig_conv.is_owned = ptr_is_owned(orig);
32196         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32197         orig_conv.is_owned = false;
32198         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
32199         int64_t ret_ref = 0;
32200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32201         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32202         return ret_ref;
32203 }
32204
32205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32206         LDKChannelDetails this_obj_conv;
32207         this_obj_conv.inner = untag_ptr(this_obj);
32208         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32210         ChannelDetails_free(this_obj_conv);
32211 }
32212
32213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32214         LDKChannelDetails this_ptr_conv;
32215         this_ptr_conv.inner = untag_ptr(this_ptr);
32216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32218         this_ptr_conv.is_owned = false;
32219         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
32221         return ret_arr;
32222 }
32223
32224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32225         LDKChannelDetails this_ptr_conv;
32226         this_ptr_conv.inner = untag_ptr(this_ptr);
32227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32229         this_ptr_conv.is_owned = false;
32230         LDKThirtyTwoBytes val_ref;
32231         CHECK((*env)->GetArrayLength(env, val) == 32);
32232         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32233         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
32234 }
32235
32236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
32237         LDKChannelDetails this_ptr_conv;
32238         this_ptr_conv.inner = untag_ptr(this_ptr);
32239         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32241         this_ptr_conv.is_owned = false;
32242         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
32243         int64_t ret_ref = 0;
32244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32245         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32246         return ret_ref;
32247 }
32248
32249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32250         LDKChannelDetails this_ptr_conv;
32251         this_ptr_conv.inner = untag_ptr(this_ptr);
32252         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32254         this_ptr_conv.is_owned = false;
32255         LDKChannelCounterparty val_conv;
32256         val_conv.inner = untag_ptr(val);
32257         val_conv.is_owned = ptr_is_owned(val);
32258         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32259         val_conv = ChannelCounterparty_clone(&val_conv);
32260         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
32261 }
32262
32263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
32264         LDKChannelDetails this_ptr_conv;
32265         this_ptr_conv.inner = untag_ptr(this_ptr);
32266         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32268         this_ptr_conv.is_owned = false;
32269         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
32270         int64_t ret_ref = 0;
32271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32272         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32273         return ret_ref;
32274 }
32275
32276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32277         LDKChannelDetails this_ptr_conv;
32278         this_ptr_conv.inner = untag_ptr(this_ptr);
32279         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32281         this_ptr_conv.is_owned = false;
32282         LDKOutPoint val_conv;
32283         val_conv.inner = untag_ptr(val);
32284         val_conv.is_owned = ptr_is_owned(val);
32285         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32286         val_conv = OutPoint_clone(&val_conv);
32287         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
32288 }
32289
32290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
32291         LDKChannelDetails this_ptr_conv;
32292         this_ptr_conv.inner = untag_ptr(this_ptr);
32293         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32295         this_ptr_conv.is_owned = false;
32296         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
32297         int64_t ret_ref = 0;
32298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32299         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32300         return ret_ref;
32301 }
32302
32303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32304         LDKChannelDetails this_ptr_conv;
32305         this_ptr_conv.inner = untag_ptr(this_ptr);
32306         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32308         this_ptr_conv.is_owned = false;
32309         LDKChannelTypeFeatures val_conv;
32310         val_conv.inner = untag_ptr(val);
32311         val_conv.is_owned = ptr_is_owned(val);
32312         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32313         val_conv = ChannelTypeFeatures_clone(&val_conv);
32314         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
32315 }
32316
32317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32318         LDKChannelDetails this_ptr_conv;
32319         this_ptr_conv.inner = untag_ptr(this_ptr);
32320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32322         this_ptr_conv.is_owned = false;
32323         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32324         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
32325         int64_t ret_ref = tag_ptr(ret_copy, true);
32326         return ret_ref;
32327 }
32328
32329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32330         LDKChannelDetails this_ptr_conv;
32331         this_ptr_conv.inner = untag_ptr(this_ptr);
32332         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32334         this_ptr_conv.is_owned = false;
32335         void* val_ptr = untag_ptr(val);
32336         CHECK_ACCESS(val_ptr);
32337         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32338         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32339         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
32340 }
32341
32342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32343         LDKChannelDetails this_ptr_conv;
32344         this_ptr_conv.inner = untag_ptr(this_ptr);
32345         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32347         this_ptr_conv.is_owned = false;
32348         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32349         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
32350         int64_t ret_ref = tag_ptr(ret_copy, true);
32351         return ret_ref;
32352 }
32353
32354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32355         LDKChannelDetails this_ptr_conv;
32356         this_ptr_conv.inner = untag_ptr(this_ptr);
32357         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32359         this_ptr_conv.is_owned = false;
32360         void* val_ptr = untag_ptr(val);
32361         CHECK_ACCESS(val_ptr);
32362         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32363         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32364         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
32365 }
32366
32367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32368         LDKChannelDetails this_ptr_conv;
32369         this_ptr_conv.inner = untag_ptr(this_ptr);
32370         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32372         this_ptr_conv.is_owned = false;
32373         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32374         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
32375         int64_t ret_ref = tag_ptr(ret_copy, true);
32376         return ret_ref;
32377 }
32378
32379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32380         LDKChannelDetails this_ptr_conv;
32381         this_ptr_conv.inner = untag_ptr(this_ptr);
32382         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32384         this_ptr_conv.is_owned = false;
32385         void* val_ptr = untag_ptr(val);
32386         CHECK_ACCESS(val_ptr);
32387         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32388         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32389         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
32390 }
32391
32392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32393         LDKChannelDetails this_ptr_conv;
32394         this_ptr_conv.inner = untag_ptr(this_ptr);
32395         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32397         this_ptr_conv.is_owned = false;
32398         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
32399         return ret_conv;
32400 }
32401
32402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32403         LDKChannelDetails this_ptr_conv;
32404         this_ptr_conv.inner = untag_ptr(this_ptr);
32405         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32407         this_ptr_conv.is_owned = false;
32408         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
32409 }
32410
32411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
32412         LDKChannelDetails this_ptr_conv;
32413         this_ptr_conv.inner = untag_ptr(this_ptr);
32414         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32416         this_ptr_conv.is_owned = false;
32417         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32418         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
32419         int64_t ret_ref = tag_ptr(ret_copy, true);
32420         return ret_ref;
32421 }
32422
32423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32424         LDKChannelDetails this_ptr_conv;
32425         this_ptr_conv.inner = untag_ptr(this_ptr);
32426         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32428         this_ptr_conv.is_owned = false;
32429         void* val_ptr = untag_ptr(val);
32430         CHECK_ACCESS(val_ptr);
32431         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32432         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32433         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
32434 }
32435
32436 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32437         LDKChannelDetails this_ptr_conv;
32438         this_ptr_conv.inner = untag_ptr(this_ptr);
32439         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32441         this_ptr_conv.is_owned = false;
32442         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
32443         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, ChannelDetails_get_user_channel_id(&this_ptr_conv).le_bytes);
32444         return ret_arr;
32445 }
32446
32447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32448         LDKChannelDetails this_ptr_conv;
32449         this_ptr_conv.inner = untag_ptr(this_ptr);
32450         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32452         this_ptr_conv.is_owned = false;
32453         LDKU128 val_ref;
32454         CHECK((*env)->GetArrayLength(env, val) == 16);
32455         (*env)->GetByteArrayRegion(env, val, 0, 16, val_ref.le_bytes);
32456         ChannelDetails_set_user_channel_id(&this_ptr_conv, val_ref);
32457 }
32458
32459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1feerate_1sat_1per_11000_1weight(JNIEnv *env, jclass clz, int64_t this_ptr) {
32460         LDKChannelDetails this_ptr_conv;
32461         this_ptr_conv.inner = untag_ptr(this_ptr);
32462         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32464         this_ptr_conv.is_owned = false;
32465         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32466         *ret_copy = ChannelDetails_get_feerate_sat_per_1000_weight(&this_ptr_conv);
32467         int64_t ret_ref = tag_ptr(ret_copy, true);
32468         return ret_ref;
32469 }
32470
32471 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) {
32472         LDKChannelDetails this_ptr_conv;
32473         this_ptr_conv.inner = untag_ptr(this_ptr);
32474         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32476         this_ptr_conv.is_owned = false;
32477         void* val_ptr = untag_ptr(val);
32478         CHECK_ACCESS(val_ptr);
32479         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32480         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32481         ChannelDetails_set_feerate_sat_per_1000_weight(&this_ptr_conv, val_conv);
32482 }
32483
32484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32485         LDKChannelDetails this_ptr_conv;
32486         this_ptr_conv.inner = untag_ptr(this_ptr);
32487         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32489         this_ptr_conv.is_owned = false;
32490         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
32491         return ret_conv;
32492 }
32493
32494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32495         LDKChannelDetails this_ptr_conv;
32496         this_ptr_conv.inner = untag_ptr(this_ptr);
32497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32499         this_ptr_conv.is_owned = false;
32500         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
32501 }
32502
32503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32504         LDKChannelDetails this_ptr_conv;
32505         this_ptr_conv.inner = untag_ptr(this_ptr);
32506         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32508         this_ptr_conv.is_owned = false;
32509         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
32510         return ret_conv;
32511 }
32512
32513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32514         LDKChannelDetails this_ptr_conv;
32515         this_ptr_conv.inner = untag_ptr(this_ptr);
32516         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32518         this_ptr_conv.is_owned = false;
32519         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
32520 }
32521
32522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32523         LDKChannelDetails this_ptr_conv;
32524         this_ptr_conv.inner = untag_ptr(this_ptr);
32525         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32527         this_ptr_conv.is_owned = false;
32528         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
32529         return ret_conv;
32530 }
32531
32532 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) {
32533         LDKChannelDetails this_ptr_conv;
32534         this_ptr_conv.inner = untag_ptr(this_ptr);
32535         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32537         this_ptr_conv.is_owned = false;
32538         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
32539 }
32540
32541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32542         LDKChannelDetails this_ptr_conv;
32543         this_ptr_conv.inner = untag_ptr(this_ptr);
32544         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32546         this_ptr_conv.is_owned = false;
32547         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
32548         return ret_conv;
32549 }
32550
32551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32552         LDKChannelDetails this_ptr_conv;
32553         this_ptr_conv.inner = untag_ptr(this_ptr);
32554         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32556         this_ptr_conv.is_owned = false;
32557         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
32558 }
32559
32560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
32561         LDKChannelDetails this_ptr_conv;
32562         this_ptr_conv.inner = untag_ptr(this_ptr);
32563         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32565         this_ptr_conv.is_owned = false;
32566         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32567         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
32568         int64_t ret_ref = tag_ptr(ret_copy, true);
32569         return ret_ref;
32570 }
32571
32572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32573         LDKChannelDetails this_ptr_conv;
32574         this_ptr_conv.inner = untag_ptr(this_ptr);
32575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32577         this_ptr_conv.is_owned = false;
32578         void* val_ptr = untag_ptr(val);
32579         CHECK_ACCESS(val_ptr);
32580         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32581         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32582         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
32583 }
32584
32585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr) {
32586         LDKChannelDetails this_ptr_conv;
32587         this_ptr_conv.inner = untag_ptr(this_ptr);
32588         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32590         this_ptr_conv.is_owned = false;
32591         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32592         *ret_copy = ChannelDetails_get_confirmations(&this_ptr_conv);
32593         int64_t ret_ref = tag_ptr(ret_copy, true);
32594         return ret_ref;
32595 }
32596
32597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32598         LDKChannelDetails this_ptr_conv;
32599         this_ptr_conv.inner = untag_ptr(this_ptr);
32600         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32602         this_ptr_conv.is_owned = false;
32603         void* val_ptr = untag_ptr(val);
32604         CHECK_ACCESS(val_ptr);
32605         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32606         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32607         ChannelDetails_set_confirmations(&this_ptr_conv, val_conv);
32608 }
32609
32610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32611         LDKChannelDetails this_ptr_conv;
32612         this_ptr_conv.inner = untag_ptr(this_ptr);
32613         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32615         this_ptr_conv.is_owned = false;
32616         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
32617         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
32618         int64_t ret_ref = tag_ptr(ret_copy, true);
32619         return ret_ref;
32620 }
32621
32622 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) {
32623         LDKChannelDetails this_ptr_conv;
32624         this_ptr_conv.inner = untag_ptr(this_ptr);
32625         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32627         this_ptr_conv.is_owned = false;
32628         void* val_ptr = untag_ptr(val);
32629         CHECK_ACCESS(val_ptr);
32630         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
32631         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
32632         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
32633 }
32634
32635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
32636         LDKChannelDetails this_ptr_conv;
32637         this_ptr_conv.inner = untag_ptr(this_ptr);
32638         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32640         this_ptr_conv.is_owned = false;
32641         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
32642         return ret_conv;
32643 }
32644
32645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32646         LDKChannelDetails this_ptr_conv;
32647         this_ptr_conv.inner = untag_ptr(this_ptr);
32648         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32650         this_ptr_conv.is_owned = false;
32651         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
32652 }
32653
32654 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
32655         LDKChannelDetails this_ptr_conv;
32656         this_ptr_conv.inner = untag_ptr(this_ptr);
32657         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32659         this_ptr_conv.is_owned = false;
32660         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
32661         return ret_conv;
32662 }
32663
32664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32665         LDKChannelDetails this_ptr_conv;
32666         this_ptr_conv.inner = untag_ptr(this_ptr);
32667         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32669         this_ptr_conv.is_owned = false;
32670         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
32671 }
32672
32673 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
32674         LDKChannelDetails this_ptr_conv;
32675         this_ptr_conv.inner = untag_ptr(this_ptr);
32676         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32678         this_ptr_conv.is_owned = false;
32679         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
32680         return ret_conv;
32681 }
32682
32683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32684         LDKChannelDetails this_ptr_conv;
32685         this_ptr_conv.inner = untag_ptr(this_ptr);
32686         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32688         this_ptr_conv.is_owned = false;
32689         ChannelDetails_set_is_usable(&this_ptr_conv, val);
32690 }
32691
32692 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
32693         LDKChannelDetails this_ptr_conv;
32694         this_ptr_conv.inner = untag_ptr(this_ptr);
32695         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32697         this_ptr_conv.is_owned = false;
32698         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
32699         return ret_conv;
32700 }
32701
32702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32703         LDKChannelDetails this_ptr_conv;
32704         this_ptr_conv.inner = untag_ptr(this_ptr);
32705         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32707         this_ptr_conv.is_owned = false;
32708         ChannelDetails_set_is_public(&this_ptr_conv, val);
32709 }
32710
32711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32712         LDKChannelDetails this_ptr_conv;
32713         this_ptr_conv.inner = untag_ptr(this_ptr);
32714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32716         this_ptr_conv.is_owned = false;
32717         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32718         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
32719         int64_t ret_ref = tag_ptr(ret_copy, true);
32720         return ret_ref;
32721 }
32722
32723 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) {
32724         LDKChannelDetails this_ptr_conv;
32725         this_ptr_conv.inner = untag_ptr(this_ptr);
32726         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32728         this_ptr_conv.is_owned = false;
32729         void* val_ptr = untag_ptr(val);
32730         CHECK_ACCESS(val_ptr);
32731         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32732         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32733         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
32734 }
32735
32736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32737         LDKChannelDetails this_ptr_conv;
32738         this_ptr_conv.inner = untag_ptr(this_ptr);
32739         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32741         this_ptr_conv.is_owned = false;
32742         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32743         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
32744         int64_t ret_ref = tag_ptr(ret_copy, true);
32745         return ret_ref;
32746 }
32747
32748 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) {
32749         LDKChannelDetails this_ptr_conv;
32750         this_ptr_conv.inner = untag_ptr(this_ptr);
32751         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32753         this_ptr_conv.is_owned = false;
32754         void* val_ptr = untag_ptr(val);
32755         CHECK_ACCESS(val_ptr);
32756         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32757         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32758         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
32759 }
32760
32761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
32762         LDKChannelDetails this_ptr_conv;
32763         this_ptr_conv.inner = untag_ptr(this_ptr);
32764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32766         this_ptr_conv.is_owned = false;
32767         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
32768         int64_t ret_ref = 0;
32769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32770         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32771         return ret_ref;
32772 }
32773
32774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32775         LDKChannelDetails this_ptr_conv;
32776         this_ptr_conv.inner = untag_ptr(this_ptr);
32777         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32779         this_ptr_conv.is_owned = false;
32780         LDKChannelConfig val_conv;
32781         val_conv.inner = untag_ptr(val);
32782         val_conv.is_owned = ptr_is_owned(val);
32783         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32784         val_conv = ChannelConfig_clone(&val_conv);
32785         ChannelDetails_set_config(&this_ptr_conv, val_conv);
32786 }
32787
32788 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) {
32789         LDKThirtyTwoBytes channel_id_arg_ref;
32790         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32791         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32792         LDKChannelCounterparty counterparty_arg_conv;
32793         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
32794         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
32795         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
32796         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
32797         LDKOutPoint funding_txo_arg_conv;
32798         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
32799         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
32800         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
32801         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
32802         LDKChannelTypeFeatures channel_type_arg_conv;
32803         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
32804         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
32805         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
32806         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
32807         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
32808         CHECK_ACCESS(short_channel_id_arg_ptr);
32809         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
32810         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
32811         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
32812         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
32813         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
32814         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
32815         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
32816         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
32817         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
32818         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
32819         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
32820         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
32821         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
32822         LDKU128 user_channel_id_arg_ref;
32823         CHECK((*env)->GetArrayLength(env, user_channel_id_arg) == 16);
32824         (*env)->GetByteArrayRegion(env, user_channel_id_arg, 0, 16, user_channel_id_arg_ref.le_bytes);
32825         void* feerate_sat_per_1000_weight_arg_ptr = untag_ptr(feerate_sat_per_1000_weight_arg);
32826         CHECK_ACCESS(feerate_sat_per_1000_weight_arg_ptr);
32827         LDKCOption_u32Z feerate_sat_per_1000_weight_arg_conv = *(LDKCOption_u32Z*)(feerate_sat_per_1000_weight_arg_ptr);
32828         feerate_sat_per_1000_weight_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(feerate_sat_per_1000_weight_arg));
32829         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
32830         CHECK_ACCESS(confirmations_required_arg_ptr);
32831         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
32832         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
32833         void* confirmations_arg_ptr = untag_ptr(confirmations_arg);
32834         CHECK_ACCESS(confirmations_arg_ptr);
32835         LDKCOption_u32Z confirmations_arg_conv = *(LDKCOption_u32Z*)(confirmations_arg_ptr);
32836         confirmations_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_arg));
32837         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
32838         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
32839         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
32840         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
32841         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
32842         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
32843         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
32844         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
32845         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
32846         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
32847         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
32848         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
32849         LDKChannelConfig config_arg_conv;
32850         config_arg_conv.inner = untag_ptr(config_arg);
32851         config_arg_conv.is_owned = ptr_is_owned(config_arg);
32852         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
32853         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
32854         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);
32855         int64_t ret_ref = 0;
32856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32857         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32858         return ret_ref;
32859 }
32860
32861 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
32862         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
32863         int64_t ret_ref = 0;
32864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32865         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32866         return ret_ref;
32867 }
32868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32869         LDKChannelDetails arg_conv;
32870         arg_conv.inner = untag_ptr(arg);
32871         arg_conv.is_owned = ptr_is_owned(arg);
32872         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32873         arg_conv.is_owned = false;
32874         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
32875         return ret_conv;
32876 }
32877
32878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32879         LDKChannelDetails orig_conv;
32880         orig_conv.inner = untag_ptr(orig);
32881         orig_conv.is_owned = ptr_is_owned(orig);
32882         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32883         orig_conv.is_owned = false;
32884         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
32885         int64_t ret_ref = 0;
32886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32887         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32888         return ret_ref;
32889 }
32890
32891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32892         LDKChannelDetails this_arg_conv;
32893         this_arg_conv.inner = untag_ptr(this_arg);
32894         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32896         this_arg_conv.is_owned = false;
32897         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32898         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
32899         int64_t ret_ref = tag_ptr(ret_copy, true);
32900         return ret_ref;
32901 }
32902
32903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32904         LDKChannelDetails this_arg_conv;
32905         this_arg_conv.inner = untag_ptr(this_arg);
32906         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32908         this_arg_conv.is_owned = false;
32909         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32910         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
32911         int64_t ret_ref = tag_ptr(ret_copy, true);
32912         return ret_ref;
32913 }
32914
32915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32916         if (!ptr_is_owned(this_ptr)) return;
32917         void* this_ptr_ptr = untag_ptr(this_ptr);
32918         CHECK_ACCESS(this_ptr_ptr);
32919         LDKRecentPaymentDetails this_ptr_conv = *(LDKRecentPaymentDetails*)(this_ptr_ptr);
32920         FREE(untag_ptr(this_ptr));
32921         RecentPaymentDetails_free(this_ptr_conv);
32922 }
32923
32924 static inline uint64_t RecentPaymentDetails_clone_ptr(LDKRecentPaymentDetails *NONNULL_PTR arg) {
32925         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32926         *ret_copy = RecentPaymentDetails_clone(arg);
32927         int64_t ret_ref = tag_ptr(ret_copy, true);
32928         return ret_ref;
32929 }
32930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32931         LDKRecentPaymentDetails* arg_conv = (LDKRecentPaymentDetails*)untag_ptr(arg);
32932         int64_t ret_conv = RecentPaymentDetails_clone_ptr(arg_conv);
32933         return ret_conv;
32934 }
32935
32936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32937         LDKRecentPaymentDetails* orig_conv = (LDKRecentPaymentDetails*)untag_ptr(orig);
32938         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32939         *ret_copy = RecentPaymentDetails_clone(orig_conv);
32940         int64_t ret_ref = tag_ptr(ret_copy, true);
32941         return ret_ref;
32942 }
32943
32944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1pending(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t total_msat) {
32945         LDKThirtyTwoBytes payment_hash_ref;
32946         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32947         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32948         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32949         *ret_copy = RecentPaymentDetails_pending(payment_hash_ref, total_msat);
32950         int64_t ret_ref = tag_ptr(ret_copy, true);
32951         return ret_ref;
32952 }
32953
32954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecentPaymentDetails_1fulfilled(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
32955         LDKThirtyTwoBytes payment_hash_ref;
32956         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32957         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32958         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
32959         *ret_copy = RecentPaymentDetails_fulfilled(payment_hash_ref);
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_1abandoned(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
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_abandoned(payment_hash_ref);
32970         int64_t ret_ref = tag_ptr(ret_copy, true);
32971         return ret_ref;
32972 }
32973
32974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32975         LDKPhantomRouteHints this_obj_conv;
32976         this_obj_conv.inner = untag_ptr(this_obj);
32977         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32979         PhantomRouteHints_free(this_obj_conv);
32980 }
32981
32982 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
32983         LDKPhantomRouteHints this_ptr_conv;
32984         this_ptr_conv.inner = untag_ptr(this_ptr);
32985         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32987         this_ptr_conv.is_owned = false;
32988         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
32989         int64_tArray ret_arr = NULL;
32990         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
32991         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
32992         for (size_t q = 0; q < ret_var.datalen; q++) {
32993                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
32994                 int64_t ret_conv_16_ref = 0;
32995                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
32996                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
32997                 ret_arr_ptr[q] = ret_conv_16_ref;
32998         }
32999         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33000         FREE(ret_var.data);
33001         return ret_arr;
33002 }
33003
33004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
33005         LDKPhantomRouteHints this_ptr_conv;
33006         this_ptr_conv.inner = untag_ptr(this_ptr);
33007         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33009         this_ptr_conv.is_owned = false;
33010         LDKCVec_ChannelDetailsZ val_constr;
33011         val_constr.datalen = (*env)->GetArrayLength(env, val);
33012         if (val_constr.datalen > 0)
33013                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
33014         else
33015                 val_constr.data = NULL;
33016         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
33017         for (size_t q = 0; q < val_constr.datalen; q++) {
33018                 int64_t val_conv_16 = val_vals[q];
33019                 LDKChannelDetails val_conv_16_conv;
33020                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
33021                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
33022                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
33023                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
33024                 val_constr.data[q] = val_conv_16_conv;
33025         }
33026         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
33027         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
33028 }
33029
33030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
33031         LDKPhantomRouteHints this_ptr_conv;
33032         this_ptr_conv.inner = untag_ptr(this_ptr);
33033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33035         this_ptr_conv.is_owned = false;
33036         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
33037         return ret_conv;
33038 }
33039
33040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33041         LDKPhantomRouteHints this_ptr_conv;
33042         this_ptr_conv.inner = untag_ptr(this_ptr);
33043         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33045         this_ptr_conv.is_owned = false;
33046         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
33047 }
33048
33049 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33050         LDKPhantomRouteHints this_ptr_conv;
33051         this_ptr_conv.inner = untag_ptr(this_ptr);
33052         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33054         this_ptr_conv.is_owned = false;
33055         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33056         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
33057         return ret_arr;
33058 }
33059
33060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKPublicKey val_ref;
33067         CHECK((*env)->GetArrayLength(env, val) == 33);
33068         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33069         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
33070 }
33071
33072 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) {
33073         LDKCVec_ChannelDetailsZ channels_arg_constr;
33074         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
33075         if (channels_arg_constr.datalen > 0)
33076                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
33077         else
33078                 channels_arg_constr.data = NULL;
33079         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
33080         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
33081                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
33082                 LDKChannelDetails channels_arg_conv_16_conv;
33083                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
33084                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
33085                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
33086                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
33087                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
33088         }
33089         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
33090         LDKPublicKey real_node_pubkey_arg_ref;
33091         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
33092         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
33093         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
33094         int64_t ret_ref = 0;
33095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33096         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33097         return ret_ref;
33098 }
33099
33100 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
33101         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
33102         int64_t ret_ref = 0;
33103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33104         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33105         return ret_ref;
33106 }
33107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33108         LDKPhantomRouteHints arg_conv;
33109         arg_conv.inner = untag_ptr(arg);
33110         arg_conv.is_owned = ptr_is_owned(arg);
33111         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33112         arg_conv.is_owned = false;
33113         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
33114         return ret_conv;
33115 }
33116
33117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33118         LDKPhantomRouteHints orig_conv;
33119         orig_conv.inner = untag_ptr(orig);
33120         orig_conv.is_owned = ptr_is_owned(orig);
33121         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33122         orig_conv.is_owned = false;
33123         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
33124         int64_t ret_ref = 0;
33125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33126         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33127         return ret_ref;
33128 }
33129
33130 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) {
33131         void* fee_est_ptr = untag_ptr(fee_est);
33132         CHECK_ACCESS(fee_est_ptr);
33133         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
33134         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
33135                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33136                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
33137         }
33138         void* chain_monitor_ptr = untag_ptr(chain_monitor);
33139         CHECK_ACCESS(chain_monitor_ptr);
33140         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
33141         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
33142                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33143                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
33144         }
33145         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
33146         CHECK_ACCESS(tx_broadcaster_ptr);
33147         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
33148         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33149                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33150                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
33151         }
33152         void* router_ptr = untag_ptr(router);
33153         CHECK_ACCESS(router_ptr);
33154         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
33155         if (router_conv.free == LDKRouter_JCalls_free) {
33156                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33157                 LDKRouter_JCalls_cloned(&router_conv);
33158         }
33159         void* logger_ptr = untag_ptr(logger);
33160         CHECK_ACCESS(logger_ptr);
33161         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33162         if (logger_conv.free == LDKLogger_JCalls_free) {
33163                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33164                 LDKLogger_JCalls_cloned(&logger_conv);
33165         }
33166         void* entropy_source_ptr = untag_ptr(entropy_source);
33167         CHECK_ACCESS(entropy_source_ptr);
33168         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
33169         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
33170                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33171                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
33172         }
33173         void* node_signer_ptr = untag_ptr(node_signer);
33174         CHECK_ACCESS(node_signer_ptr);
33175         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
33176         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
33177                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33178                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
33179         }
33180         void* signer_provider_ptr = untag_ptr(signer_provider);
33181         CHECK_ACCESS(signer_provider_ptr);
33182         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
33183         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
33184                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33185                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
33186         }
33187         LDKUserConfig config_conv;
33188         config_conv.inner = untag_ptr(config);
33189         config_conv.is_owned = ptr_is_owned(config);
33190         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
33191         config_conv = UserConfig_clone(&config_conv);
33192         LDKChainParameters params_conv;
33193         params_conv.inner = untag_ptr(params);
33194         params_conv.is_owned = ptr_is_owned(params);
33195         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
33196         params_conv = ChainParameters_clone(&params_conv);
33197         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);
33198         int64_t ret_ref = 0;
33199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33200         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33201         return ret_ref;
33202 }
33203
33204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
33205         LDKChannelManager this_arg_conv;
33206         this_arg_conv.inner = untag_ptr(this_arg);
33207         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33209         this_arg_conv.is_owned = false;
33210         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
33211         int64_t ret_ref = 0;
33212         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33213         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33214         return ret_ref;
33215 }
33216
33217 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) {
33218         LDKChannelManager this_arg_conv;
33219         this_arg_conv.inner = untag_ptr(this_arg);
33220         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33222         this_arg_conv.is_owned = false;
33223         LDKPublicKey their_network_key_ref;
33224         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
33225         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
33226         LDKU128 user_channel_id_ref;
33227         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33228         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33229         LDKUserConfig override_config_conv;
33230         override_config_conv.inner = untag_ptr(override_config);
33231         override_config_conv.is_owned = ptr_is_owned(override_config);
33232         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
33233         override_config_conv = UserConfig_clone(&override_config_conv);
33234         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
33235         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id_ref, override_config_conv);
33236         return tag_ptr(ret_conv, true);
33237 }
33238
33239 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
33240         LDKChannelManager this_arg_conv;
33241         this_arg_conv.inner = untag_ptr(this_arg);
33242         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33244         this_arg_conv.is_owned = false;
33245         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
33246         int64_tArray ret_arr = NULL;
33247         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33248         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33249         for (size_t q = 0; q < ret_var.datalen; q++) {
33250                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33251                 int64_t ret_conv_16_ref = 0;
33252                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33253                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33254                 ret_arr_ptr[q] = ret_conv_16_ref;
33255         }
33256         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33257         FREE(ret_var.data);
33258         return ret_arr;
33259 }
33260
33261 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
33262         LDKChannelManager this_arg_conv;
33263         this_arg_conv.inner = untag_ptr(this_arg);
33264         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33266         this_arg_conv.is_owned = false;
33267         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
33268         int64_tArray ret_arr = NULL;
33269         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33270         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33271         for (size_t q = 0; q < ret_var.datalen; q++) {
33272                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33273                 int64_t ret_conv_16_ref = 0;
33274                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33275                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33276                 ret_arr_ptr[q] = ret_conv_16_ref;
33277         }
33278         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33279         FREE(ret_var.data);
33280         return ret_arr;
33281 }
33282
33283 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels_1with_1counterparty(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray counterparty_node_id) {
33284         LDKChannelManager this_arg_conv;
33285         this_arg_conv.inner = untag_ptr(this_arg);
33286         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33288         this_arg_conv.is_owned = false;
33289         LDKPublicKey counterparty_node_id_ref;
33290         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33291         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33292         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels_with_counterparty(&this_arg_conv, counterparty_node_id_ref);
33293         int64_tArray ret_arr = NULL;
33294         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33295         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33296         for (size_t q = 0; q < ret_var.datalen; q++) {
33297                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
33298                 int64_t ret_conv_16_ref = 0;
33299                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33300                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
33301                 ret_arr_ptr[q] = ret_conv_16_ref;
33302         }
33303         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33304         FREE(ret_var.data);
33305         return ret_arr;
33306 }
33307
33308 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1recent_1payments(JNIEnv *env, jclass clz, int64_t this_arg) {
33309         LDKChannelManager this_arg_conv;
33310         this_arg_conv.inner = untag_ptr(this_arg);
33311         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33313         this_arg_conv.is_owned = false;
33314         LDKCVec_RecentPaymentDetailsZ ret_var = ChannelManager_list_recent_payments(&this_arg_conv);
33315         int64_tArray ret_arr = NULL;
33316         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
33317         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
33318         for (size_t w = 0; w < ret_var.datalen; w++) {
33319                 LDKRecentPaymentDetails *ret_conv_22_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
33320                 *ret_conv_22_copy = ret_var.data[w];
33321                 int64_t ret_conv_22_ref = tag_ptr(ret_conv_22_copy, true);
33322                 ret_arr_ptr[w] = ret_conv_22_ref;
33323         }
33324         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
33325         FREE(ret_var.data);
33326         return ret_arr;
33327 }
33328
33329 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) {
33330         LDKChannelManager this_arg_conv;
33331         this_arg_conv.inner = untag_ptr(this_arg);
33332         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33334         this_arg_conv.is_owned = false;
33335         uint8_t channel_id_arr[32];
33336         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33337         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33338         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33339         LDKPublicKey counterparty_node_id_ref;
33340         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33341         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33342         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33343         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33344         return tag_ptr(ret_conv, true);
33345 }
33346
33347 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) {
33348         LDKChannelManager this_arg_conv;
33349         this_arg_conv.inner = untag_ptr(this_arg);
33350         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33352         this_arg_conv.is_owned = false;
33353         uint8_t channel_id_arr[32];
33354         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33355         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33356         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33357         LDKPublicKey counterparty_node_id_ref;
33358         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33359         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33360         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33361         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
33362         return tag_ptr(ret_conv, true);
33363 }
33364
33365 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) {
33366         LDKChannelManager this_arg_conv;
33367         this_arg_conv.inner = untag_ptr(this_arg);
33368         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33370         this_arg_conv.is_owned = false;
33371         uint8_t channel_id_arr[32];
33372         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33373         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33374         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33375         LDKPublicKey counterparty_node_id_ref;
33376         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33377         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33378         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33379         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33380         return tag_ptr(ret_conv, true);
33381 }
33382
33383 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) {
33384         LDKChannelManager this_arg_conv;
33385         this_arg_conv.inner = untag_ptr(this_arg);
33386         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33388         this_arg_conv.is_owned = false;
33389         uint8_t channel_id_arr[32];
33390         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
33391         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
33392         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
33393         LDKPublicKey counterparty_node_id_ref;
33394         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33395         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33396         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33397         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
33398         return tag_ptr(ret_conv, true);
33399 }
33400
33401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
33402         LDKChannelManager this_arg_conv;
33403         this_arg_conv.inner = untag_ptr(this_arg);
33404         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33406         this_arg_conv.is_owned = false;
33407         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
33408 }
33409
33410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
33411         LDKChannelManager this_arg_conv;
33412         this_arg_conv.inner = untag_ptr(this_arg);
33413         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33415         this_arg_conv.is_owned = false;
33416         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
33417 }
33418
33419 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) {
33420         LDKChannelManager this_arg_conv;
33421         this_arg_conv.inner = untag_ptr(this_arg);
33422         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33424         this_arg_conv.is_owned = false;
33425         LDKRoute route_conv;
33426         route_conv.inner = untag_ptr(route);
33427         route_conv.is_owned = ptr_is_owned(route);
33428         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
33429         route_conv.is_owned = false;
33430         LDKThirtyTwoBytes payment_hash_ref;
33431         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33432         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33433         LDKRecipientOnionFields recipient_onion_conv;
33434         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33435         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33436         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33437         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33438         LDKThirtyTwoBytes payment_id_ref;
33439         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33440         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33441         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
33442         *ret_conv = ChannelManager_send_payment_with_route(&this_arg_conv, &route_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref);
33443         return tag_ptr(ret_conv, true);
33444 }
33445
33446 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) {
33447         LDKChannelManager this_arg_conv;
33448         this_arg_conv.inner = untag_ptr(this_arg);
33449         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33451         this_arg_conv.is_owned = false;
33452         LDKThirtyTwoBytes payment_hash_ref;
33453         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33454         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33455         LDKRecipientOnionFields recipient_onion_conv;
33456         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33457         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33458         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33459         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33460         LDKThirtyTwoBytes payment_id_ref;
33461         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33462         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33463         LDKRouteParameters route_params_conv;
33464         route_params_conv.inner = untag_ptr(route_params);
33465         route_params_conv.is_owned = ptr_is_owned(route_params);
33466         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
33467         route_params_conv = RouteParameters_clone(&route_params_conv);
33468         void* retry_strategy_ptr = untag_ptr(retry_strategy);
33469         CHECK_ACCESS(retry_strategy_ptr);
33470         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
33471         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
33472         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
33473         *ret_conv = ChannelManager_send_payment(&this_arg_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref, route_params_conv, retry_strategy_conv);
33474         return tag_ptr(ret_conv, true);
33475 }
33476
33477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
33478         LDKChannelManager this_arg_conv;
33479         this_arg_conv.inner = untag_ptr(this_arg);
33480         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33482         this_arg_conv.is_owned = false;
33483         LDKThirtyTwoBytes payment_id_ref;
33484         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33485         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33486         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
33487 }
33488
33489 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) {
33490         LDKChannelManager this_arg_conv;
33491         this_arg_conv.inner = untag_ptr(this_arg);
33492         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33494         this_arg_conv.is_owned = false;
33495         LDKRoute route_conv;
33496         route_conv.inner = untag_ptr(route);
33497         route_conv.is_owned = ptr_is_owned(route);
33498         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
33499         route_conv.is_owned = false;
33500         LDKThirtyTwoBytes payment_preimage_ref;
33501         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33502         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33503         LDKRecipientOnionFields recipient_onion_conv;
33504         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33505         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33506         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33507         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33508         LDKThirtyTwoBytes payment_id_ref;
33509         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33510         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33511         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
33512         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref, recipient_onion_conv, payment_id_ref);
33513         return tag_ptr(ret_conv, true);
33514 }
33515
33516 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) {
33517         LDKChannelManager this_arg_conv;
33518         this_arg_conv.inner = untag_ptr(this_arg);
33519         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33521         this_arg_conv.is_owned = false;
33522         LDKThirtyTwoBytes payment_preimage_ref;
33523         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33524         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33525         LDKRecipientOnionFields recipient_onion_conv;
33526         recipient_onion_conv.inner = untag_ptr(recipient_onion);
33527         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
33528         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
33529         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
33530         LDKThirtyTwoBytes payment_id_ref;
33531         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
33532         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
33533         LDKRouteParameters route_params_conv;
33534         route_params_conv.inner = untag_ptr(route_params);
33535         route_params_conv.is_owned = ptr_is_owned(route_params);
33536         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
33537         route_params_conv = RouteParameters_clone(&route_params_conv);
33538         void* retry_strategy_ptr = untag_ptr(retry_strategy);
33539         CHECK_ACCESS(retry_strategy_ptr);
33540         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
33541         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
33542         LDKCResult_PaymentHashRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashRetryableSendFailureZ), "LDKCResult_PaymentHashRetryableSendFailureZ");
33543         *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);
33544         return tag_ptr(ret_conv, true);
33545 }
33546
33547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_t path) {
33548         LDKChannelManager this_arg_conv;
33549         this_arg_conv.inner = untag_ptr(this_arg);
33550         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33552         this_arg_conv.is_owned = false;
33553         LDKPath path_conv;
33554         path_conv.inner = untag_ptr(path);
33555         path_conv.is_owned = ptr_is_owned(path);
33556         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
33557         path_conv = Path_clone(&path_conv);
33558         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
33559         *ret_conv = ChannelManager_send_probe(&this_arg_conv, path_conv);
33560         return tag_ptr(ret_conv, true);
33561 }
33562
33563 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) {
33564         LDKChannelManager this_arg_conv;
33565         this_arg_conv.inner = untag_ptr(this_arg);
33566         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33568         this_arg_conv.is_owned = false;
33569         uint8_t temporary_channel_id_arr[32];
33570         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33571         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33572         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33573         LDKPublicKey counterparty_node_id_ref;
33574         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33575         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33576         LDKTransaction funding_transaction_ref;
33577         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
33578         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
33579         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
33580         funding_transaction_ref.data_is_owned = true;
33581         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33582         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
33583         return tag_ptr(ret_conv, true);
33584 }
33585
33586 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) {
33587         LDKChannelManager this_arg_conv;
33588         this_arg_conv.inner = untag_ptr(this_arg);
33589         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33591         this_arg_conv.is_owned = false;
33592         LDKPublicKey counterparty_node_id_ref;
33593         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33594         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33595         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
33596         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
33597         if (channel_ids_constr.datalen > 0)
33598                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
33599         else
33600                 channel_ids_constr.data = NULL;
33601         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
33602                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
33603                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
33604                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
33605                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
33606                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
33607         }
33608         LDKChannelConfig config_conv;
33609         config_conv.inner = untag_ptr(config);
33610         config_conv.is_owned = ptr_is_owned(config);
33611         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
33612         config_conv.is_owned = false;
33613         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33614         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
33615         return tag_ptr(ret_conv, true);
33616 }
33617
33618 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) {
33619         LDKChannelManager this_arg_conv;
33620         this_arg_conv.inner = untag_ptr(this_arg);
33621         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33623         this_arg_conv.is_owned = false;
33624         LDKThirtyTwoBytes intercept_id_ref;
33625         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33626         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33627         uint8_t next_hop_channel_id_arr[32];
33628         CHECK((*env)->GetArrayLength(env, next_hop_channel_id) == 32);
33629         (*env)->GetByteArrayRegion(env, next_hop_channel_id, 0, 32, next_hop_channel_id_arr);
33630         uint8_t (*next_hop_channel_id_ref)[32] = &next_hop_channel_id_arr;
33631         LDKPublicKey next_node_id_ref;
33632         CHECK((*env)->GetArrayLength(env, next_node_id) == 33);
33633         (*env)->GetByteArrayRegion(env, next_node_id, 0, 33, next_node_id_ref.compressed_form);
33634         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33635         *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);
33636         return tag_ptr(ret_conv, true);
33637 }
33638
33639 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) {
33640         LDKChannelManager this_arg_conv;
33641         this_arg_conv.inner = untag_ptr(this_arg);
33642         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33644         this_arg_conv.is_owned = false;
33645         LDKThirtyTwoBytes intercept_id_ref;
33646         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33647         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33648         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33649         *ret_conv = ChannelManager_fail_intercepted_htlc(&this_arg_conv, intercept_id_ref);
33650         return tag_ptr(ret_conv, true);
33651 }
33652
33653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
33654         LDKChannelManager this_arg_conv;
33655         this_arg_conv.inner = untag_ptr(this_arg);
33656         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33658         this_arg_conv.is_owned = false;
33659         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
33660 }
33661
33662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
33663         LDKChannelManager this_arg_conv;
33664         this_arg_conv.inner = untag_ptr(this_arg);
33665         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33667         this_arg_conv.is_owned = false;
33668         ChannelManager_timer_tick_occurred(&this_arg_conv);
33669 }
33670
33671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
33672         LDKChannelManager this_arg_conv;
33673         this_arg_conv.inner = untag_ptr(this_arg);
33674         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33676         this_arg_conv.is_owned = false;
33677         uint8_t payment_hash_arr[32];
33678         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33679         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
33680         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
33681         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
33682 }
33683
33684 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) {
33685         LDKChannelManager this_arg_conv;
33686         this_arg_conv.inner = untag_ptr(this_arg);
33687         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33689         this_arg_conv.is_owned = false;
33690         uint8_t payment_hash_arr[32];
33691         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33692         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
33693         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
33694         LDKFailureCode failure_code_conv = LDKFailureCode_from_java(env, failure_code);
33695         ChannelManager_fail_htlc_backwards_with_reason(&this_arg_conv, payment_hash_ref, failure_code_conv);
33696 }
33697
33698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
33699         LDKChannelManager this_arg_conv;
33700         this_arg_conv.inner = untag_ptr(this_arg);
33701         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33703         this_arg_conv.is_owned = false;
33704         LDKThirtyTwoBytes payment_preimage_ref;
33705         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33706         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33707         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
33708 }
33709
33710 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
33711         LDKChannelManager this_arg_conv;
33712         this_arg_conv.inner = untag_ptr(this_arg);
33713         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33715         this_arg_conv.is_owned = false;
33716         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33717         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
33718         return ret_arr;
33719 }
33720
33721 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) {
33722         LDKChannelManager this_arg_conv;
33723         this_arg_conv.inner = untag_ptr(this_arg);
33724         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33726         this_arg_conv.is_owned = false;
33727         uint8_t temporary_channel_id_arr[32];
33728         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33729         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33730         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33731         LDKPublicKey counterparty_node_id_ref;
33732         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33733         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33734         LDKU128 user_channel_id_ref;
33735         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33736         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33737         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33738         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id_ref);
33739         return tag_ptr(ret_conv, true);
33740 }
33741
33742 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) {
33743         LDKChannelManager this_arg_conv;
33744         this_arg_conv.inner = untag_ptr(this_arg);
33745         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33747         this_arg_conv.is_owned = false;
33748         uint8_t temporary_channel_id_arr[32];
33749         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33750         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33751         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33752         LDKPublicKey counterparty_node_id_ref;
33753         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33754         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33755         LDKU128 user_channel_id_ref;
33756         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33757         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33758         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33759         *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);
33760         return tag_ptr(ret_conv, true);
33761 }
33762
33763 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) {
33764         LDKChannelManager this_arg_conv;
33765         this_arg_conv.inner = untag_ptr(this_arg);
33766         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33768         this_arg_conv.is_owned = false;
33769         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33770         CHECK_ACCESS(min_value_msat_ptr);
33771         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33772         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33773         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
33774         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
33775         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
33776         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
33777         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
33778         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
33779         return tag_ptr(ret_conv, true);
33780 }
33781
33782 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) {
33783         LDKChannelManager this_arg_conv;
33784         this_arg_conv.inner = untag_ptr(this_arg);
33785         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33787         this_arg_conv.is_owned = false;
33788         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33789         CHECK_ACCESS(min_value_msat_ptr);
33790         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33791         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33792         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
33793         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
33794         return tag_ptr(ret_conv, true);
33795 }
33796
33797 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) {
33798         LDKChannelManager this_arg_conv;
33799         this_arg_conv.inner = untag_ptr(this_arg);
33800         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33802         this_arg_conv.is_owned = false;
33803         LDKThirtyTwoBytes payment_hash_ref;
33804         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33805         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33806         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33807         CHECK_ACCESS(min_value_msat_ptr);
33808         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33809         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33810         void* min_final_cltv_expiry_ptr = untag_ptr(min_final_cltv_expiry);
33811         CHECK_ACCESS(min_final_cltv_expiry_ptr);
33812         LDKCOption_u16Z min_final_cltv_expiry_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_ptr);
33813         min_final_cltv_expiry_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry));
33814         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
33815         *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);
33816         return tag_ptr(ret_conv, true);
33817 }
33818
33819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inbound_1payment_1for_1hash_1legacy(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int64_t min_value_msat, int32_t invoice_expiry_delta_secs) {
33820         LDKChannelManager this_arg_conv;
33821         this_arg_conv.inner = untag_ptr(this_arg);
33822         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33824         this_arg_conv.is_owned = false;
33825         LDKThirtyTwoBytes payment_hash_ref;
33826         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33827         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33828         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33829         CHECK_ACCESS(min_value_msat_ptr);
33830         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33831         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33832         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
33833         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
33834         return tag_ptr(ret_conv, true);
33835 }
33836
33837 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) {
33838         LDKChannelManager this_arg_conv;
33839         this_arg_conv.inner = untag_ptr(this_arg);
33840         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33842         this_arg_conv.is_owned = false;
33843         LDKThirtyTwoBytes payment_hash_ref;
33844         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33845         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33846         LDKThirtyTwoBytes payment_secret_ref;
33847         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
33848         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
33849         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
33850         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
33851         return tag_ptr(ret_conv, true);
33852 }
33853
33854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33855         LDKChannelManager this_arg_conv;
33856         this_arg_conv.inner = untag_ptr(this_arg);
33857         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33859         this_arg_conv.is_owned = false;
33860         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
33861         return ret_conv;
33862 }
33863
33864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
33865         LDKChannelManager this_arg_conv;
33866         this_arg_conv.inner = untag_ptr(this_arg);
33867         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33869         this_arg_conv.is_owned = false;
33870         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
33871         int64_t ret_ref = 0;
33872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33873         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33874         return ret_ref;
33875 }
33876
33877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1intercept_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33878         LDKChannelManager this_arg_conv;
33879         this_arg_conv.inner = untag_ptr(this_arg);
33880         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33882         this_arg_conv.is_owned = false;
33883         int64_t ret_conv = ChannelManager_get_intercept_scid(&this_arg_conv);
33884         return ret_conv;
33885 }
33886
33887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1compute_1inflight_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg) {
33888         LDKChannelManager this_arg_conv;
33889         this_arg_conv.inner = untag_ptr(this_arg);
33890         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33892         this_arg_conv.is_owned = false;
33893         LDKInFlightHtlcs ret_var = ChannelManager_compute_inflight_htlcs(&this_arg_conv);
33894         int64_t ret_ref = 0;
33895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33896         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33897         return ret_ref;
33898 }
33899
33900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33901         LDKChannelManager this_arg_conv;
33902         this_arg_conv.inner = untag_ptr(this_arg);
33903         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33905         this_arg_conv.is_owned = false;
33906         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33907         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
33908         return tag_ptr(ret_ret, true);
33909 }
33910
33911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33912         LDKChannelManager this_arg_conv;
33913         this_arg_conv.inner = untag_ptr(this_arg);
33914         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33916         this_arg_conv.is_owned = false;
33917         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
33918         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
33919         return tag_ptr(ret_ret, true);
33920 }
33921
33922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
33923         LDKChannelManager this_arg_conv;
33924         this_arg_conv.inner = untag_ptr(this_arg);
33925         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33927         this_arg_conv.is_owned = false;
33928         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
33929         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
33930         return tag_ptr(ret_ret, true);
33931 }
33932
33933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
33934         LDKChannelManager this_arg_conv;
33935         this_arg_conv.inner = untag_ptr(this_arg);
33936         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33938         this_arg_conv.is_owned = false;
33939         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
33940         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
33941         return tag_ptr(ret_ret, true);
33942 }
33943
33944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1persistable_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
33945         LDKChannelManager this_arg_conv;
33946         this_arg_conv.inner = untag_ptr(this_arg);
33947         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33949         this_arg_conv.is_owned = false;
33950         LDKFuture ret_var = ChannelManager_get_persistable_update_future(&this_arg_conv);
33951         int64_t ret_ref = 0;
33952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33953         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33954         return ret_ref;
33955 }
33956
33957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
33958         LDKChannelManager this_arg_conv;
33959         this_arg_conv.inner = untag_ptr(this_arg);
33960         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33962         this_arg_conv.is_owned = false;
33963         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
33964         int64_t ret_ref = 0;
33965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33967         return ret_ref;
33968 }
33969
33970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
33971         LDKChannelManager this_arg_conv;
33972         this_arg_conv.inner = untag_ptr(this_arg);
33973         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33975         this_arg_conv.is_owned = false;
33976         LDKNodeFeatures ret_var = ChannelManager_node_features(&this_arg_conv);
33977         int64_t ret_ref = 0;
33978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33979         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33980         return ret_ref;
33981 }
33982
33983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
33984         LDKChannelManager this_arg_conv;
33985         this_arg_conv.inner = untag_ptr(this_arg);
33986         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33988         this_arg_conv.is_owned = false;
33989         LDKChannelFeatures ret_var = ChannelManager_channel_features(&this_arg_conv);
33990         int64_t ret_ref = 0;
33991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33992         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33993         return ret_ref;
33994 }
33995
33996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1channel_1type_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
33997         LDKChannelManager this_arg_conv;
33998         this_arg_conv.inner = untag_ptr(this_arg);
33999         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34001         this_arg_conv.is_owned = false;
34002         LDKChannelTypeFeatures ret_var = ChannelManager_channel_type_features(&this_arg_conv);
34003         int64_t ret_ref = 0;
34004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34005         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34006         return ret_ref;
34007 }
34008
34009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
34010         LDKChannelManager this_arg_conv;
34011         this_arg_conv.inner = untag_ptr(this_arg);
34012         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34014         this_arg_conv.is_owned = false;
34015         LDKInitFeatures ret_var = ChannelManager_init_features(&this_arg_conv);
34016         int64_t ret_ref = 0;
34017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34019         return ret_ref;
34020 }
34021
34022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
34023         LDKChannelManager this_arg_conv;
34024         this_arg_conv.inner = untag_ptr(this_arg);
34025         this_arg_conv.is_owned = ptr_is_owned(this_arg);
34026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34027         this_arg_conv.is_owned = false;
34028         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
34029         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
34030         return tag_ptr(ret_ret, true);
34031 }
34032
34033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1init_1features(JNIEnv *env, jclass clz, int64_t _config) {
34034         LDKUserConfig _config_conv;
34035         _config_conv.inner = untag_ptr(_config);
34036         _config_conv.is_owned = ptr_is_owned(_config);
34037         CHECK_INNER_FIELD_ACCESS_OR_NULL(_config_conv);
34038         _config_conv.is_owned = false;
34039         LDKInitFeatures ret_var = provided_init_features(&_config_conv);
34040         int64_t ret_ref = 0;
34041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34042         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34043         return ret_ref;
34044 }
34045
34046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
34047         LDKCounterpartyForwardingInfo obj_conv;
34048         obj_conv.inner = untag_ptr(obj);
34049         obj_conv.is_owned = ptr_is_owned(obj);
34050         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34051         obj_conv.is_owned = false;
34052         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
34053         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34054         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34055         CVec_u8Z_free(ret_var);
34056         return ret_arr;
34057 }
34058
34059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34060         LDKu8slice ser_ref;
34061         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34062         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34063         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
34064         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
34065         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34066         return tag_ptr(ret_conv, true);
34067 }
34068
34069 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
34070         LDKChannelCounterparty obj_conv;
34071         obj_conv.inner = untag_ptr(obj);
34072         obj_conv.is_owned = ptr_is_owned(obj);
34073         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34074         obj_conv.is_owned = false;
34075         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
34076         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34077         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34078         CVec_u8Z_free(ret_var);
34079         return ret_arr;
34080 }
34081
34082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34083         LDKu8slice ser_ref;
34084         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34085         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34086         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
34087         *ret_conv = ChannelCounterparty_read(ser_ref);
34088         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34089         return tag_ptr(ret_conv, true);
34090 }
34091
34092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
34093         LDKChannelDetails obj_conv;
34094         obj_conv.inner = untag_ptr(obj);
34095         obj_conv.is_owned = ptr_is_owned(obj);
34096         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34097         obj_conv.is_owned = false;
34098         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
34099         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34100         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34101         CVec_u8Z_free(ret_var);
34102         return ret_arr;
34103 }
34104
34105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34106         LDKu8slice ser_ref;
34107         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34108         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34109         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
34110         *ret_conv = ChannelDetails_read(ser_ref);
34111         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34112         return tag_ptr(ret_conv, true);
34113 }
34114
34115 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
34116         LDKPhantomRouteHints obj_conv;
34117         obj_conv.inner = untag_ptr(obj);
34118         obj_conv.is_owned = ptr_is_owned(obj);
34119         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34120         obj_conv.is_owned = false;
34121         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
34122         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34123         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34124         CVec_u8Z_free(ret_var);
34125         return ret_arr;
34126 }
34127
34128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34129         LDKu8slice ser_ref;
34130         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34131         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34132         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
34133         *ret_conv = PhantomRouteHints_read(ser_ref);
34134         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34135         return tag_ptr(ret_conv, true);
34136 }
34137
34138 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
34139         LDKChannelManager obj_conv;
34140         obj_conv.inner = untag_ptr(obj);
34141         obj_conv.is_owned = ptr_is_owned(obj);
34142         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34143         obj_conv.is_owned = false;
34144         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
34145         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34146         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34147         CVec_u8Z_free(ret_var);
34148         return ret_arr;
34149 }
34150
34151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34152         LDKChannelManagerReadArgs this_obj_conv;
34153         this_obj_conv.inner = untag_ptr(this_obj);
34154         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34156         ChannelManagerReadArgs_free(this_obj_conv);
34157 }
34158
34159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1entropy_1source(JNIEnv *env, jclass clz, int64_t this_ptr) {
34160         LDKChannelManagerReadArgs this_ptr_conv;
34161         this_ptr_conv.inner = untag_ptr(this_ptr);
34162         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34164         this_ptr_conv.is_owned = false;
34165         // WARNING: This object doesn't live past this scope, needs clone!
34166         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_entropy_source(&this_ptr_conv), false);
34167         return ret_ret;
34168 }
34169
34170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1entropy_1source(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34171         LDKChannelManagerReadArgs this_ptr_conv;
34172         this_ptr_conv.inner = untag_ptr(this_ptr);
34173         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34175         this_ptr_conv.is_owned = false;
34176         void* val_ptr = untag_ptr(val);
34177         CHECK_ACCESS(val_ptr);
34178         LDKEntropySource val_conv = *(LDKEntropySource*)(val_ptr);
34179         if (val_conv.free == LDKEntropySource_JCalls_free) {
34180                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34181                 LDKEntropySource_JCalls_cloned(&val_conv);
34182         }
34183         ChannelManagerReadArgs_set_entropy_source(&this_ptr_conv, val_conv);
34184 }
34185
34186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1node_1signer(JNIEnv *env, jclass clz, int64_t this_ptr) {
34187         LDKChannelManagerReadArgs this_ptr_conv;
34188         this_ptr_conv.inner = untag_ptr(this_ptr);
34189         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34191         this_ptr_conv.is_owned = false;
34192         // WARNING: This object doesn't live past this scope, needs clone!
34193         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_node_signer(&this_ptr_conv), false);
34194         return ret_ret;
34195 }
34196
34197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1node_1signer(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34198         LDKChannelManagerReadArgs this_ptr_conv;
34199         this_ptr_conv.inner = untag_ptr(this_ptr);
34200         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34202         this_ptr_conv.is_owned = false;
34203         void* val_ptr = untag_ptr(val);
34204         CHECK_ACCESS(val_ptr);
34205         LDKNodeSigner val_conv = *(LDKNodeSigner*)(val_ptr);
34206         if (val_conv.free == LDKNodeSigner_JCalls_free) {
34207                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34208                 LDKNodeSigner_JCalls_cloned(&val_conv);
34209         }
34210         ChannelManagerReadArgs_set_node_signer(&this_ptr_conv, val_conv);
34211 }
34212
34213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1signer_1provider(JNIEnv *env, jclass clz, int64_t this_ptr) {
34214         LDKChannelManagerReadArgs this_ptr_conv;
34215         this_ptr_conv.inner = untag_ptr(this_ptr);
34216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34218         this_ptr_conv.is_owned = false;
34219         // WARNING: This object doesn't live past this scope, needs clone!
34220         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_signer_provider(&this_ptr_conv), false);
34221         return ret_ret;
34222 }
34223
34224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1signer_1provider(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34225         LDKChannelManagerReadArgs this_ptr_conv;
34226         this_ptr_conv.inner = untag_ptr(this_ptr);
34227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34229         this_ptr_conv.is_owned = false;
34230         void* val_ptr = untag_ptr(val);
34231         CHECK_ACCESS(val_ptr);
34232         LDKSignerProvider val_conv = *(LDKSignerProvider*)(val_ptr);
34233         if (val_conv.free == LDKSignerProvider_JCalls_free) {
34234                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34235                 LDKSignerProvider_JCalls_cloned(&val_conv);
34236         }
34237         ChannelManagerReadArgs_set_signer_provider(&this_ptr_conv, val_conv);
34238 }
34239
34240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
34241         LDKChannelManagerReadArgs this_ptr_conv;
34242         this_ptr_conv.inner = untag_ptr(this_ptr);
34243         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34245         this_ptr_conv.is_owned = false;
34246         // WARNING: This object doesn't live past this scope, needs clone!
34247         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
34248         return ret_ret;
34249 }
34250
34251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34252         LDKChannelManagerReadArgs this_ptr_conv;
34253         this_ptr_conv.inner = untag_ptr(this_ptr);
34254         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34256         this_ptr_conv.is_owned = false;
34257         void* val_ptr = untag_ptr(val);
34258         CHECK_ACCESS(val_ptr);
34259         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
34260         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
34261                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34262                 LDKFeeEstimator_JCalls_cloned(&val_conv);
34263         }
34264         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
34265 }
34266
34267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
34268         LDKChannelManagerReadArgs this_ptr_conv;
34269         this_ptr_conv.inner = untag_ptr(this_ptr);
34270         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34272         this_ptr_conv.is_owned = false;
34273         // WARNING: This object doesn't live past this scope, needs clone!
34274         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
34275         return ret_ret;
34276 }
34277
34278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34279         LDKChannelManagerReadArgs this_ptr_conv;
34280         this_ptr_conv.inner = untag_ptr(this_ptr);
34281         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34283         this_ptr_conv.is_owned = false;
34284         void* val_ptr = untag_ptr(val);
34285         CHECK_ACCESS(val_ptr);
34286         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
34287         if (val_conv.free == LDKWatch_JCalls_free) {
34288                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34289                 LDKWatch_JCalls_cloned(&val_conv);
34290         }
34291         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
34292 }
34293
34294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
34295         LDKChannelManagerReadArgs this_ptr_conv;
34296         this_ptr_conv.inner = untag_ptr(this_ptr);
34297         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34299         this_ptr_conv.is_owned = false;
34300         // WARNING: This object doesn't live past this scope, needs clone!
34301         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
34302         return ret_ret;
34303 }
34304
34305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34306         LDKChannelManagerReadArgs this_ptr_conv;
34307         this_ptr_conv.inner = untag_ptr(this_ptr);
34308         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34310         this_ptr_conv.is_owned = false;
34311         void* val_ptr = untag_ptr(val);
34312         CHECK_ACCESS(val_ptr);
34313         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
34314         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
34315                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34316                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
34317         }
34318         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
34319 }
34320
34321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1router(JNIEnv *env, jclass clz, int64_t this_ptr) {
34322         LDKChannelManagerReadArgs this_ptr_conv;
34323         this_ptr_conv.inner = untag_ptr(this_ptr);
34324         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34326         this_ptr_conv.is_owned = false;
34327         // WARNING: This object doesn't live past this scope, needs clone!
34328         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_router(&this_ptr_conv), false);
34329         return ret_ret;
34330 }
34331
34332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1router(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34333         LDKChannelManagerReadArgs this_ptr_conv;
34334         this_ptr_conv.inner = untag_ptr(this_ptr);
34335         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34337         this_ptr_conv.is_owned = false;
34338         void* val_ptr = untag_ptr(val);
34339         CHECK_ACCESS(val_ptr);
34340         LDKRouter val_conv = *(LDKRouter*)(val_ptr);
34341         if (val_conv.free == LDKRouter_JCalls_free) {
34342                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34343                 LDKRouter_JCalls_cloned(&val_conv);
34344         }
34345         ChannelManagerReadArgs_set_router(&this_ptr_conv, val_conv);
34346 }
34347
34348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
34349         LDKChannelManagerReadArgs this_ptr_conv;
34350         this_ptr_conv.inner = untag_ptr(this_ptr);
34351         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34353         this_ptr_conv.is_owned = false;
34354         // WARNING: This object doesn't live past this scope, needs clone!
34355         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
34356         return ret_ret;
34357 }
34358
34359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34360         LDKChannelManagerReadArgs this_ptr_conv;
34361         this_ptr_conv.inner = untag_ptr(this_ptr);
34362         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34364         this_ptr_conv.is_owned = false;
34365         void* val_ptr = untag_ptr(val);
34366         CHECK_ACCESS(val_ptr);
34367         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
34368         if (val_conv.free == LDKLogger_JCalls_free) {
34369                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34370                 LDKLogger_JCalls_cloned(&val_conv);
34371         }
34372         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
34373 }
34374
34375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
34376         LDKChannelManagerReadArgs this_ptr_conv;
34377         this_ptr_conv.inner = untag_ptr(this_ptr);
34378         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34380         this_ptr_conv.is_owned = false;
34381         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
34382         int64_t ret_ref = 0;
34383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34384         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34385         return ret_ref;
34386 }
34387
34388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34389         LDKChannelManagerReadArgs this_ptr_conv;
34390         this_ptr_conv.inner = untag_ptr(this_ptr);
34391         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34393         this_ptr_conv.is_owned = false;
34394         LDKUserConfig val_conv;
34395         val_conv.inner = untag_ptr(val);
34396         val_conv.is_owned = ptr_is_owned(val);
34397         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34398         val_conv = UserConfig_clone(&val_conv);
34399         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
34400 }
34401
34402 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) {
34403         void* entropy_source_ptr = untag_ptr(entropy_source);
34404         CHECK_ACCESS(entropy_source_ptr);
34405         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
34406         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
34407                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34408                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
34409         }
34410         void* node_signer_ptr = untag_ptr(node_signer);
34411         CHECK_ACCESS(node_signer_ptr);
34412         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
34413         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
34414                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34415                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
34416         }
34417         void* signer_provider_ptr = untag_ptr(signer_provider);
34418         CHECK_ACCESS(signer_provider_ptr);
34419         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
34420         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
34421                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34422                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
34423         }
34424         void* fee_estimator_ptr = untag_ptr(fee_estimator);
34425         CHECK_ACCESS(fee_estimator_ptr);
34426         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
34427         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
34428                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34429                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
34430         }
34431         void* chain_monitor_ptr = untag_ptr(chain_monitor);
34432         CHECK_ACCESS(chain_monitor_ptr);
34433         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
34434         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
34435                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34436                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
34437         }
34438         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
34439         CHECK_ACCESS(tx_broadcaster_ptr);
34440         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
34441         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
34442                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34443                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
34444         }
34445         void* router_ptr = untag_ptr(router);
34446         CHECK_ACCESS(router_ptr);
34447         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
34448         if (router_conv.free == LDKRouter_JCalls_free) {
34449                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34450                 LDKRouter_JCalls_cloned(&router_conv);
34451         }
34452         void* logger_ptr = untag_ptr(logger);
34453         CHECK_ACCESS(logger_ptr);
34454         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34455         if (logger_conv.free == LDKLogger_JCalls_free) {
34456                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34457                 LDKLogger_JCalls_cloned(&logger_conv);
34458         }
34459         LDKUserConfig default_config_conv;
34460         default_config_conv.inner = untag_ptr(default_config);
34461         default_config_conv.is_owned = ptr_is_owned(default_config);
34462         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
34463         default_config_conv = UserConfig_clone(&default_config_conv);
34464         LDKCVec_ChannelMonitorZ channel_monitors_constr;
34465         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
34466         if (channel_monitors_constr.datalen > 0)
34467                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
34468         else
34469                 channel_monitors_constr.data = NULL;
34470         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
34471         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
34472                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
34473                 LDKChannelMonitor channel_monitors_conv_16_conv;
34474                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
34475                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
34476                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
34477                 channel_monitors_conv_16_conv.is_owned = false;
34478                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
34479         }
34480         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
34481         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);
34482         int64_t ret_ref = 0;
34483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34484         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34485         return ret_ref;
34486 }
34487
34488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
34489         LDKu8slice ser_ref;
34490         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34491         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34492         LDKChannelManagerReadArgs arg_conv;
34493         arg_conv.inner = untag_ptr(arg);
34494         arg_conv.is_owned = ptr_is_owned(arg);
34495         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34496         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
34497         
34498         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
34499         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
34500         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34501         return tag_ptr(ret_conv, true);
34502 }
34503
34504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34505         LDKExpandedKey this_obj_conv;
34506         this_obj_conv.inner = untag_ptr(this_obj);
34507         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34509         ExpandedKey_free(this_obj_conv);
34510 }
34511
34512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
34513         uint8_t key_material_arr[32];
34514         CHECK((*env)->GetArrayLength(env, key_material) == 32);
34515         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
34516         uint8_t (*key_material_ref)[32] = &key_material_arr;
34517         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
34518         int64_t ret_ref = 0;
34519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34520         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34521         return ret_ref;
34522 }
34523
34524 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) {
34525         LDKExpandedKey keys_conv;
34526         keys_conv.inner = untag_ptr(keys);
34527         keys_conv.is_owned = ptr_is_owned(keys);
34528         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
34529         keys_conv.is_owned = false;
34530         void* min_value_msat_ptr = untag_ptr(min_value_msat);
34531         CHECK_ACCESS(min_value_msat_ptr);
34532         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
34533         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
34534         void* entropy_source_ptr = untag_ptr(entropy_source);
34535         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
34536         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
34537         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
34538         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
34539         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
34540         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
34541         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
34542         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, entropy_source_conv, current_time, min_final_cltv_expiry_delta_conv);
34543         return tag_ptr(ret_conv, true);
34544 }
34545
34546 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) {
34547         LDKExpandedKey keys_conv;
34548         keys_conv.inner = untag_ptr(keys);
34549         keys_conv.is_owned = ptr_is_owned(keys);
34550         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
34551         keys_conv.is_owned = false;
34552         void* min_value_msat_ptr = untag_ptr(min_value_msat);
34553         CHECK_ACCESS(min_value_msat_ptr);
34554         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
34555         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
34556         LDKThirtyTwoBytes payment_hash_ref;
34557         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
34558         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
34559         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
34560         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
34561         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
34562         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
34563         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
34564         *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);
34565         return tag_ptr(ret_conv, true);
34566 }
34567
34568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34569         if (!ptr_is_owned(this_ptr)) return;
34570         void* this_ptr_ptr = untag_ptr(this_ptr);
34571         CHECK_ACCESS(this_ptr_ptr);
34572         LDKDecodeError this_ptr_conv = *(LDKDecodeError*)(this_ptr_ptr);
34573         FREE(untag_ptr(this_ptr));
34574         DecodeError_free(this_ptr_conv);
34575 }
34576
34577 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
34578         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34579         *ret_copy = DecodeError_clone(arg);
34580         int64_t ret_ref = tag_ptr(ret_copy, true);
34581         return ret_ref;
34582 }
34583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34584         LDKDecodeError* arg_conv = (LDKDecodeError*)untag_ptr(arg);
34585         int64_t ret_conv = DecodeError_clone_ptr(arg_conv);
34586         return ret_conv;
34587 }
34588
34589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34590         LDKDecodeError* orig_conv = (LDKDecodeError*)untag_ptr(orig);
34591         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34592         *ret_copy = DecodeError_clone(orig_conv);
34593         int64_t ret_ref = tag_ptr(ret_copy, true);
34594         return ret_ref;
34595 }
34596
34597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1version(JNIEnv *env, jclass clz) {
34598         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34599         *ret_copy = DecodeError_unknown_version();
34600         int64_t ret_ref = tag_ptr(ret_copy, true);
34601         return ret_ref;
34602 }
34603
34604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1required_1feature(JNIEnv *env, jclass clz) {
34605         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34606         *ret_copy = DecodeError_unknown_required_feature();
34607         int64_t ret_ref = tag_ptr(ret_copy, true);
34608         return ret_ref;
34609 }
34610
34611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1invalid_1value(JNIEnv *env, jclass clz) {
34612         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34613         *ret_copy = DecodeError_invalid_value();
34614         int64_t ret_ref = tag_ptr(ret_copy, true);
34615         return ret_ref;
34616 }
34617
34618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1short_1read(JNIEnv *env, jclass clz) {
34619         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34620         *ret_copy = DecodeError_short_read();
34621         int64_t ret_ref = tag_ptr(ret_copy, true);
34622         return ret_ref;
34623 }
34624
34625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1bad_1length_1descriptor(JNIEnv *env, jclass clz) {
34626         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34627         *ret_copy = DecodeError_bad_length_descriptor();
34628         int64_t ret_ref = tag_ptr(ret_copy, true);
34629         return ret_ref;
34630 }
34631
34632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1io(JNIEnv *env, jclass clz, jclass a) {
34633         LDKIOError a_conv = LDKIOError_from_java(env, a);
34634         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34635         *ret_copy = DecodeError_io(a_conv);
34636         int64_t ret_ref = tag_ptr(ret_copy, true);
34637         return ret_ref;
34638 }
34639
34640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unsupported_1compression(JNIEnv *env, jclass clz) {
34641         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
34642         *ret_copy = DecodeError_unsupported_compression();
34643         int64_t ret_ref = tag_ptr(ret_copy, true);
34644         return ret_ref;
34645 }
34646
34647 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DecodeError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34648         LDKDecodeError* a_conv = (LDKDecodeError*)untag_ptr(a);
34649         LDKDecodeError* b_conv = (LDKDecodeError*)untag_ptr(b);
34650         jboolean ret_conv = DecodeError_eq(a_conv, b_conv);
34651         return ret_conv;
34652 }
34653
34654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34655         LDKInit this_obj_conv;
34656         this_obj_conv.inner = untag_ptr(this_obj);
34657         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34659         Init_free(this_obj_conv);
34660 }
34661
34662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
34663         LDKInit this_ptr_conv;
34664         this_ptr_conv.inner = untag_ptr(this_ptr);
34665         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34667         this_ptr_conv.is_owned = false;
34668         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
34669         int64_t ret_ref = 0;
34670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34671         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34672         return ret_ref;
34673 }
34674
34675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34676         LDKInit this_ptr_conv;
34677         this_ptr_conv.inner = untag_ptr(this_ptr);
34678         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34680         this_ptr_conv.is_owned = false;
34681         LDKInitFeatures val_conv;
34682         val_conv.inner = untag_ptr(val);
34683         val_conv.is_owned = ptr_is_owned(val);
34684         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34685         val_conv = InitFeatures_clone(&val_conv);
34686         Init_set_features(&this_ptr_conv, val_conv);
34687 }
34688
34689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
34690         LDKInit this_ptr_conv;
34691         this_ptr_conv.inner = untag_ptr(this_ptr);
34692         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34694         this_ptr_conv.is_owned = false;
34695         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
34696         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
34697         int64_t ret_ref = tag_ptr(ret_copy, true);
34698         return ret_ref;
34699 }
34700
34701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34702         LDKInit this_ptr_conv;
34703         this_ptr_conv.inner = untag_ptr(this_ptr);
34704         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34706         this_ptr_conv.is_owned = false;
34707         void* val_ptr = untag_ptr(val);
34708         CHECK_ACCESS(val_ptr);
34709         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
34710         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(val));
34711         Init_set_remote_network_address(&this_ptr_conv, val_conv);
34712 }
34713
34714 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) {
34715         LDKInitFeatures features_arg_conv;
34716         features_arg_conv.inner = untag_ptr(features_arg);
34717         features_arg_conv.is_owned = ptr_is_owned(features_arg);
34718         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
34719         features_arg_conv = InitFeatures_clone(&features_arg_conv);
34720         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
34721         CHECK_ACCESS(remote_network_address_arg_ptr);
34722         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
34723         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
34724         int64_t ret_ref = 0;
34725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34726         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34727         return ret_ref;
34728 }
34729
34730 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
34731         LDKInit ret_var = Init_clone(arg);
34732         int64_t ret_ref = 0;
34733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34735         return ret_ref;
34736 }
34737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34738         LDKInit arg_conv;
34739         arg_conv.inner = untag_ptr(arg);
34740         arg_conv.is_owned = ptr_is_owned(arg);
34741         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34742         arg_conv.is_owned = false;
34743         int64_t ret_conv = Init_clone_ptr(&arg_conv);
34744         return ret_conv;
34745 }
34746
34747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34748         LDKInit orig_conv;
34749         orig_conv.inner = untag_ptr(orig);
34750         orig_conv.is_owned = ptr_is_owned(orig);
34751         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34752         orig_conv.is_owned = false;
34753         LDKInit ret_var = Init_clone(&orig_conv);
34754         int64_t ret_ref = 0;
34755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34756         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34757         return ret_ref;
34758 }
34759
34760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Init_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34761         LDKInit a_conv;
34762         a_conv.inner = untag_ptr(a);
34763         a_conv.is_owned = ptr_is_owned(a);
34764         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34765         a_conv.is_owned = false;
34766         LDKInit b_conv;
34767         b_conv.inner = untag_ptr(b);
34768         b_conv.is_owned = ptr_is_owned(b);
34769         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34770         b_conv.is_owned = false;
34771         jboolean ret_conv = Init_eq(&a_conv, &b_conv);
34772         return ret_conv;
34773 }
34774
34775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34776         LDKErrorMessage this_obj_conv;
34777         this_obj_conv.inner = untag_ptr(this_obj);
34778         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34780         ErrorMessage_free(this_obj_conv);
34781 }
34782
34783 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34784         LDKErrorMessage this_ptr_conv;
34785         this_ptr_conv.inner = untag_ptr(this_ptr);
34786         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34788         this_ptr_conv.is_owned = false;
34789         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34790         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
34791         return ret_arr;
34792 }
34793
34794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34795         LDKErrorMessage this_ptr_conv;
34796         this_ptr_conv.inner = untag_ptr(this_ptr);
34797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34799         this_ptr_conv.is_owned = false;
34800         LDKThirtyTwoBytes val_ref;
34801         CHECK((*env)->GetArrayLength(env, val) == 32);
34802         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34803         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
34804 }
34805
34806 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34807         LDKErrorMessage this_ptr_conv;
34808         this_ptr_conv.inner = untag_ptr(this_ptr);
34809         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34811         this_ptr_conv.is_owned = false;
34812         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
34813         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34814         Str_free(ret_str);
34815         return ret_conv;
34816 }
34817
34818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34819         LDKErrorMessage this_ptr_conv;
34820         this_ptr_conv.inner = untag_ptr(this_ptr);
34821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34823         this_ptr_conv.is_owned = false;
34824         LDKStr val_conv = java_to_owned_str(env, val);
34825         ErrorMessage_set_data(&this_ptr_conv, val_conv);
34826 }
34827
34828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34829         LDKThirtyTwoBytes channel_id_arg_ref;
34830         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34831         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34832         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34833         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
34834         int64_t ret_ref = 0;
34835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34836         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34837         return ret_ref;
34838 }
34839
34840 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
34841         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
34842         int64_t ret_ref = 0;
34843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34844         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34845         return ret_ref;
34846 }
34847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34848         LDKErrorMessage arg_conv;
34849         arg_conv.inner = untag_ptr(arg);
34850         arg_conv.is_owned = ptr_is_owned(arg);
34851         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34852         arg_conv.is_owned = false;
34853         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
34854         return ret_conv;
34855 }
34856
34857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34858         LDKErrorMessage orig_conv;
34859         orig_conv.inner = untag_ptr(orig);
34860         orig_conv.is_owned = ptr_is_owned(orig);
34861         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34862         orig_conv.is_owned = false;
34863         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
34864         int64_t ret_ref = 0;
34865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34866         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34867         return ret_ref;
34868 }
34869
34870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34871         LDKErrorMessage a_conv;
34872         a_conv.inner = untag_ptr(a);
34873         a_conv.is_owned = ptr_is_owned(a);
34874         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34875         a_conv.is_owned = false;
34876         LDKErrorMessage b_conv;
34877         b_conv.inner = untag_ptr(b);
34878         b_conv.is_owned = ptr_is_owned(b);
34879         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34880         b_conv.is_owned = false;
34881         jboolean ret_conv = ErrorMessage_eq(&a_conv, &b_conv);
34882         return ret_conv;
34883 }
34884
34885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34886         LDKWarningMessage this_obj_conv;
34887         this_obj_conv.inner = untag_ptr(this_obj);
34888         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34890         WarningMessage_free(this_obj_conv);
34891 }
34892
34893 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34894         LDKWarningMessage this_ptr_conv;
34895         this_ptr_conv.inner = untag_ptr(this_ptr);
34896         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34898         this_ptr_conv.is_owned = false;
34899         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34900         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
34901         return ret_arr;
34902 }
34903
34904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34905         LDKWarningMessage this_ptr_conv;
34906         this_ptr_conv.inner = untag_ptr(this_ptr);
34907         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34909         this_ptr_conv.is_owned = false;
34910         LDKThirtyTwoBytes val_ref;
34911         CHECK((*env)->GetArrayLength(env, val) == 32);
34912         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34913         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
34914 }
34915
34916 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34917         LDKWarningMessage this_ptr_conv;
34918         this_ptr_conv.inner = untag_ptr(this_ptr);
34919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34921         this_ptr_conv.is_owned = false;
34922         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
34923         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34924         Str_free(ret_str);
34925         return ret_conv;
34926 }
34927
34928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34929         LDKWarningMessage this_ptr_conv;
34930         this_ptr_conv.inner = untag_ptr(this_ptr);
34931         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34933         this_ptr_conv.is_owned = false;
34934         LDKStr val_conv = java_to_owned_str(env, val);
34935         WarningMessage_set_data(&this_ptr_conv, val_conv);
34936 }
34937
34938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34939         LDKThirtyTwoBytes channel_id_arg_ref;
34940         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34941         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34942         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34943         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
34944         int64_t ret_ref = 0;
34945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34946         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34947         return ret_ref;
34948 }
34949
34950 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
34951         LDKWarningMessage ret_var = WarningMessage_clone(arg);
34952         int64_t ret_ref = 0;
34953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34954         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34955         return ret_ref;
34956 }
34957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34958         LDKWarningMessage arg_conv;
34959         arg_conv.inner = untag_ptr(arg);
34960         arg_conv.is_owned = ptr_is_owned(arg);
34961         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34962         arg_conv.is_owned = false;
34963         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
34964         return ret_conv;
34965 }
34966
34967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34968         LDKWarningMessage orig_conv;
34969         orig_conv.inner = untag_ptr(orig);
34970         orig_conv.is_owned = ptr_is_owned(orig);
34971         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34972         orig_conv.is_owned = false;
34973         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
34974         int64_t ret_ref = 0;
34975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34976         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34977         return ret_ref;
34978 }
34979
34980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WarningMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34981         LDKWarningMessage a_conv;
34982         a_conv.inner = untag_ptr(a);
34983         a_conv.is_owned = ptr_is_owned(a);
34984         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34985         a_conv.is_owned = false;
34986         LDKWarningMessage b_conv;
34987         b_conv.inner = untag_ptr(b);
34988         b_conv.is_owned = ptr_is_owned(b);
34989         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34990         b_conv.is_owned = false;
34991         jboolean ret_conv = WarningMessage_eq(&a_conv, &b_conv);
34992         return ret_conv;
34993 }
34994
34995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34996         LDKPing this_obj_conv;
34997         this_obj_conv.inner = untag_ptr(this_obj);
34998         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35000         Ping_free(this_obj_conv);
35001 }
35002
35003 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
35004         LDKPing this_ptr_conv;
35005         this_ptr_conv.inner = untag_ptr(this_ptr);
35006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35008         this_ptr_conv.is_owned = false;
35009         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
35010         return ret_conv;
35011 }
35012
35013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35014         LDKPing this_ptr_conv;
35015         this_ptr_conv.inner = untag_ptr(this_ptr);
35016         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35018         this_ptr_conv.is_owned = false;
35019         Ping_set_ponglen(&this_ptr_conv, val);
35020 }
35021
35022 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
35023         LDKPing this_ptr_conv;
35024         this_ptr_conv.inner = untag_ptr(this_ptr);
35025         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35027         this_ptr_conv.is_owned = false;
35028         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
35029         return ret_conv;
35030 }
35031
35032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35033         LDKPing this_ptr_conv;
35034         this_ptr_conv.inner = untag_ptr(this_ptr);
35035         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35037         this_ptr_conv.is_owned = false;
35038         Ping_set_byteslen(&this_ptr_conv, val);
35039 }
35040
35041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
35042         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
35043         int64_t ret_ref = 0;
35044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35045         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35046         return ret_ref;
35047 }
35048
35049 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
35050         LDKPing ret_var = Ping_clone(arg);
35051         int64_t ret_ref = 0;
35052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35053         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35054         return ret_ref;
35055 }
35056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35057         LDKPing arg_conv;
35058         arg_conv.inner = untag_ptr(arg);
35059         arg_conv.is_owned = ptr_is_owned(arg);
35060         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35061         arg_conv.is_owned = false;
35062         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
35063         return ret_conv;
35064 }
35065
35066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35067         LDKPing orig_conv;
35068         orig_conv.inner = untag_ptr(orig);
35069         orig_conv.is_owned = ptr_is_owned(orig);
35070         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35071         orig_conv.is_owned = false;
35072         LDKPing ret_var = Ping_clone(&orig_conv);
35073         int64_t ret_ref = 0;
35074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35075         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35076         return ret_ref;
35077 }
35078
35079 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Ping_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35080         LDKPing a_conv;
35081         a_conv.inner = untag_ptr(a);
35082         a_conv.is_owned = ptr_is_owned(a);
35083         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35084         a_conv.is_owned = false;
35085         LDKPing b_conv;
35086         b_conv.inner = untag_ptr(b);
35087         b_conv.is_owned = ptr_is_owned(b);
35088         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35089         b_conv.is_owned = false;
35090         jboolean ret_conv = Ping_eq(&a_conv, &b_conv);
35091         return ret_conv;
35092 }
35093
35094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35095         LDKPong this_obj_conv;
35096         this_obj_conv.inner = untag_ptr(this_obj);
35097         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35099         Pong_free(this_obj_conv);
35100 }
35101
35102 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
35103         LDKPong this_ptr_conv;
35104         this_ptr_conv.inner = untag_ptr(this_ptr);
35105         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35107         this_ptr_conv.is_owned = false;
35108         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
35109         return ret_conv;
35110 }
35111
35112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35113         LDKPong this_ptr_conv;
35114         this_ptr_conv.inner = untag_ptr(this_ptr);
35115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35117         this_ptr_conv.is_owned = false;
35118         Pong_set_byteslen(&this_ptr_conv, val);
35119 }
35120
35121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
35122         LDKPong ret_var = Pong_new(byteslen_arg);
35123         int64_t ret_ref = 0;
35124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35125         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35126         return ret_ref;
35127 }
35128
35129 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
35130         LDKPong ret_var = Pong_clone(arg);
35131         int64_t ret_ref = 0;
35132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35133         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35134         return ret_ref;
35135 }
35136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35137         LDKPong arg_conv;
35138         arg_conv.inner = untag_ptr(arg);
35139         arg_conv.is_owned = ptr_is_owned(arg);
35140         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35141         arg_conv.is_owned = false;
35142         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
35143         return ret_conv;
35144 }
35145
35146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35147         LDKPong orig_conv;
35148         orig_conv.inner = untag_ptr(orig);
35149         orig_conv.is_owned = ptr_is_owned(orig);
35150         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35151         orig_conv.is_owned = false;
35152         LDKPong ret_var = Pong_clone(&orig_conv);
35153         int64_t ret_ref = 0;
35154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35155         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35156         return ret_ref;
35157 }
35158
35159 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Pong_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35160         LDKPong a_conv;
35161         a_conv.inner = untag_ptr(a);
35162         a_conv.is_owned = ptr_is_owned(a);
35163         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35164         a_conv.is_owned = false;
35165         LDKPong b_conv;
35166         b_conv.inner = untag_ptr(b);
35167         b_conv.is_owned = ptr_is_owned(b);
35168         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35169         b_conv.is_owned = false;
35170         jboolean ret_conv = Pong_eq(&a_conv, &b_conv);
35171         return ret_conv;
35172 }
35173
35174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35175         LDKOpenChannel this_obj_conv;
35176         this_obj_conv.inner = untag_ptr(this_obj);
35177         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35179         OpenChannel_free(this_obj_conv);
35180 }
35181
35182 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35183         LDKOpenChannel this_ptr_conv;
35184         this_ptr_conv.inner = untag_ptr(this_ptr);
35185         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35187         this_ptr_conv.is_owned = false;
35188         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35189         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
35190         return ret_arr;
35191 }
35192
35193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35194         LDKOpenChannel this_ptr_conv;
35195         this_ptr_conv.inner = untag_ptr(this_ptr);
35196         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35198         this_ptr_conv.is_owned = false;
35199         LDKThirtyTwoBytes val_ref;
35200         CHECK((*env)->GetArrayLength(env, val) == 32);
35201         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35202         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
35203 }
35204
35205 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35206         LDKOpenChannel this_ptr_conv;
35207         this_ptr_conv.inner = untag_ptr(this_ptr);
35208         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35210         this_ptr_conv.is_owned = false;
35211         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35212         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
35213         return ret_arr;
35214 }
35215
35216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35217         LDKOpenChannel this_ptr_conv;
35218         this_ptr_conv.inner = untag_ptr(this_ptr);
35219         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35221         this_ptr_conv.is_owned = false;
35222         LDKThirtyTwoBytes val_ref;
35223         CHECK((*env)->GetArrayLength(env, val) == 32);
35224         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35225         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
35226 }
35227
35228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35229         LDKOpenChannel this_ptr_conv;
35230         this_ptr_conv.inner = untag_ptr(this_ptr);
35231         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35233         this_ptr_conv.is_owned = false;
35234         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
35235         return ret_conv;
35236 }
35237
35238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35239         LDKOpenChannel this_ptr_conv;
35240         this_ptr_conv.inner = untag_ptr(this_ptr);
35241         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35243         this_ptr_conv.is_owned = false;
35244         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
35245 }
35246
35247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35248         LDKOpenChannel this_ptr_conv;
35249         this_ptr_conv.inner = untag_ptr(this_ptr);
35250         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35252         this_ptr_conv.is_owned = false;
35253         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
35254         return ret_conv;
35255 }
35256
35257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35258         LDKOpenChannel this_ptr_conv;
35259         this_ptr_conv.inner = untag_ptr(this_ptr);
35260         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35262         this_ptr_conv.is_owned = false;
35263         OpenChannel_set_push_msat(&this_ptr_conv, val);
35264 }
35265
35266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35267         LDKOpenChannel this_ptr_conv;
35268         this_ptr_conv.inner = untag_ptr(this_ptr);
35269         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35271         this_ptr_conv.is_owned = false;
35272         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
35273         return ret_conv;
35274 }
35275
35276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35277         LDKOpenChannel this_ptr_conv;
35278         this_ptr_conv.inner = untag_ptr(this_ptr);
35279         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35281         this_ptr_conv.is_owned = false;
35282         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
35283 }
35284
35285 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) {
35286         LDKOpenChannel this_ptr_conv;
35287         this_ptr_conv.inner = untag_ptr(this_ptr);
35288         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35290         this_ptr_conv.is_owned = false;
35291         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
35292         return ret_conv;
35293 }
35294
35295 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) {
35296         LDKOpenChannel this_ptr_conv;
35297         this_ptr_conv.inner = untag_ptr(this_ptr);
35298         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35300         this_ptr_conv.is_owned = false;
35301         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
35302 }
35303
35304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35305         LDKOpenChannel this_ptr_conv;
35306         this_ptr_conv.inner = untag_ptr(this_ptr);
35307         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35309         this_ptr_conv.is_owned = false;
35310         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
35311         return ret_conv;
35312 }
35313
35314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35315         LDKOpenChannel this_ptr_conv;
35316         this_ptr_conv.inner = untag_ptr(this_ptr);
35317         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35319         this_ptr_conv.is_owned = false;
35320         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
35321 }
35322
35323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35324         LDKOpenChannel this_ptr_conv;
35325         this_ptr_conv.inner = untag_ptr(this_ptr);
35326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35328         this_ptr_conv.is_owned = false;
35329         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
35330         return ret_conv;
35331 }
35332
35333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35334         LDKOpenChannel this_ptr_conv;
35335         this_ptr_conv.inner = untag_ptr(this_ptr);
35336         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35338         this_ptr_conv.is_owned = false;
35339         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
35340 }
35341
35342 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
35343         LDKOpenChannel this_ptr_conv;
35344         this_ptr_conv.inner = untag_ptr(this_ptr);
35345         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35347         this_ptr_conv.is_owned = false;
35348         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
35349         return ret_conv;
35350 }
35351
35352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35353         LDKOpenChannel this_ptr_conv;
35354         this_ptr_conv.inner = untag_ptr(this_ptr);
35355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35357         this_ptr_conv.is_owned = false;
35358         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
35359 }
35360
35361 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
35362         LDKOpenChannel this_ptr_conv;
35363         this_ptr_conv.inner = untag_ptr(this_ptr);
35364         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35366         this_ptr_conv.is_owned = false;
35367         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
35368         return ret_conv;
35369 }
35370
35371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35372         LDKOpenChannel this_ptr_conv;
35373         this_ptr_conv.inner = untag_ptr(this_ptr);
35374         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35376         this_ptr_conv.is_owned = false;
35377         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
35378 }
35379
35380 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35381         LDKOpenChannel this_ptr_conv;
35382         this_ptr_conv.inner = untag_ptr(this_ptr);
35383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35385         this_ptr_conv.is_owned = false;
35386         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
35387         return ret_conv;
35388 }
35389
35390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35391         LDKOpenChannel this_ptr_conv;
35392         this_ptr_conv.inner = untag_ptr(this_ptr);
35393         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35395         this_ptr_conv.is_owned = false;
35396         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
35397 }
35398
35399 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35400         LDKOpenChannel this_ptr_conv;
35401         this_ptr_conv.inner = untag_ptr(this_ptr);
35402         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35404         this_ptr_conv.is_owned = false;
35405         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35406         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
35407         return ret_arr;
35408 }
35409
35410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKPublicKey val_ref;
35417         CHECK((*env)->GetArrayLength(env, val) == 33);
35418         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35419         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
35420 }
35421
35422 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35423         LDKOpenChannel this_ptr_conv;
35424         this_ptr_conv.inner = untag_ptr(this_ptr);
35425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35427         this_ptr_conv.is_owned = false;
35428         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35429         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
35430         return ret_arr;
35431 }
35432
35433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35434         LDKOpenChannel this_ptr_conv;
35435         this_ptr_conv.inner = untag_ptr(this_ptr);
35436         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35438         this_ptr_conv.is_owned = false;
35439         LDKPublicKey val_ref;
35440         CHECK((*env)->GetArrayLength(env, val) == 33);
35441         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35442         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
35443 }
35444
35445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35446         LDKOpenChannel this_ptr_conv;
35447         this_ptr_conv.inner = untag_ptr(this_ptr);
35448         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35450         this_ptr_conv.is_owned = false;
35451         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35452         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
35453         return ret_arr;
35454 }
35455
35456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35457         LDKOpenChannel this_ptr_conv;
35458         this_ptr_conv.inner = untag_ptr(this_ptr);
35459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35461         this_ptr_conv.is_owned = false;
35462         LDKPublicKey val_ref;
35463         CHECK((*env)->GetArrayLength(env, val) == 33);
35464         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35465         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
35466 }
35467
35468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35469         LDKOpenChannel this_ptr_conv;
35470         this_ptr_conv.inner = untag_ptr(this_ptr);
35471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35473         this_ptr_conv.is_owned = false;
35474         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35475         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
35476         return ret_arr;
35477 }
35478
35479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35480         LDKOpenChannel this_ptr_conv;
35481         this_ptr_conv.inner = untag_ptr(this_ptr);
35482         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35484         this_ptr_conv.is_owned = false;
35485         LDKPublicKey val_ref;
35486         CHECK((*env)->GetArrayLength(env, val) == 33);
35487         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35488         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35489 }
35490
35491 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35492         LDKOpenChannel this_ptr_conv;
35493         this_ptr_conv.inner = untag_ptr(this_ptr);
35494         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35496         this_ptr_conv.is_owned = false;
35497         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35498         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
35499         return ret_arr;
35500 }
35501
35502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35503         LDKOpenChannel this_ptr_conv;
35504         this_ptr_conv.inner = untag_ptr(this_ptr);
35505         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35507         this_ptr_conv.is_owned = false;
35508         LDKPublicKey val_ref;
35509         CHECK((*env)->GetArrayLength(env, val) == 33);
35510         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35511         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
35512 }
35513
35514 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35515         LDKOpenChannel this_ptr_conv;
35516         this_ptr_conv.inner = untag_ptr(this_ptr);
35517         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35519         this_ptr_conv.is_owned = false;
35520         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35521         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
35522         return ret_arr;
35523 }
35524
35525 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) {
35526         LDKOpenChannel this_ptr_conv;
35527         this_ptr_conv.inner = untag_ptr(this_ptr);
35528         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35530         this_ptr_conv.is_owned = false;
35531         LDKPublicKey val_ref;
35532         CHECK((*env)->GetArrayLength(env, val) == 33);
35533         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35534         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
35535 }
35536
35537 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
35538         LDKOpenChannel this_ptr_conv;
35539         this_ptr_conv.inner = untag_ptr(this_ptr);
35540         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35542         this_ptr_conv.is_owned = false;
35543         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
35544         return ret_conv;
35545 }
35546
35547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
35548         LDKOpenChannel this_ptr_conv;
35549         this_ptr_conv.inner = untag_ptr(this_ptr);
35550         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35552         this_ptr_conv.is_owned = false;
35553         OpenChannel_set_channel_flags(&this_ptr_conv, val);
35554 }
35555
35556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
35557         LDKOpenChannel this_ptr_conv;
35558         this_ptr_conv.inner = untag_ptr(this_ptr);
35559         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35561         this_ptr_conv.is_owned = false;
35562         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
35563         int64_t ret_ref = 0;
35564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35565         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35566         return ret_ref;
35567 }
35568
35569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35570         LDKOpenChannel this_ptr_conv;
35571         this_ptr_conv.inner = untag_ptr(this_ptr);
35572         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35574         this_ptr_conv.is_owned = false;
35575         LDKChannelTypeFeatures val_conv;
35576         val_conv.inner = untag_ptr(val);
35577         val_conv.is_owned = ptr_is_owned(val);
35578         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35579         val_conv = ChannelTypeFeatures_clone(&val_conv);
35580         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
35581 }
35582
35583 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
35584         LDKOpenChannel ret_var = OpenChannel_clone(arg);
35585         int64_t ret_ref = 0;
35586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35587         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35588         return ret_ref;
35589 }
35590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35591         LDKOpenChannel arg_conv;
35592         arg_conv.inner = untag_ptr(arg);
35593         arg_conv.is_owned = ptr_is_owned(arg);
35594         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35595         arg_conv.is_owned = false;
35596         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
35597         return ret_conv;
35598 }
35599
35600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35601         LDKOpenChannel orig_conv;
35602         orig_conv.inner = untag_ptr(orig);
35603         orig_conv.is_owned = ptr_is_owned(orig);
35604         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35605         orig_conv.is_owned = false;
35606         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
35607         int64_t ret_ref = 0;
35608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35609         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35610         return ret_ref;
35611 }
35612
35613 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OpenChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35614         LDKOpenChannel a_conv;
35615         a_conv.inner = untag_ptr(a);
35616         a_conv.is_owned = ptr_is_owned(a);
35617         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35618         a_conv.is_owned = false;
35619         LDKOpenChannel b_conv;
35620         b_conv.inner = untag_ptr(b);
35621         b_conv.is_owned = ptr_is_owned(b);
35622         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35623         b_conv.is_owned = false;
35624         jboolean ret_conv = OpenChannel_eq(&a_conv, &b_conv);
35625         return ret_conv;
35626 }
35627
35628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35629         LDKAcceptChannel this_obj_conv;
35630         this_obj_conv.inner = untag_ptr(this_obj);
35631         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35633         AcceptChannel_free(this_obj_conv);
35634 }
35635
35636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35637         LDKAcceptChannel this_ptr_conv;
35638         this_ptr_conv.inner = untag_ptr(this_ptr);
35639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35641         this_ptr_conv.is_owned = false;
35642         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35643         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
35644         return ret_arr;
35645 }
35646
35647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35648         LDKAcceptChannel this_ptr_conv;
35649         this_ptr_conv.inner = untag_ptr(this_ptr);
35650         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35652         this_ptr_conv.is_owned = false;
35653         LDKThirtyTwoBytes val_ref;
35654         CHECK((*env)->GetArrayLength(env, val) == 32);
35655         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35656         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
35657 }
35658
35659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35660         LDKAcceptChannel this_ptr_conv;
35661         this_ptr_conv.inner = untag_ptr(this_ptr);
35662         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35664         this_ptr_conv.is_owned = false;
35665         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
35666         return ret_conv;
35667 }
35668
35669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35670         LDKAcceptChannel this_ptr_conv;
35671         this_ptr_conv.inner = untag_ptr(this_ptr);
35672         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35674         this_ptr_conv.is_owned = false;
35675         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
35676 }
35677
35678 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) {
35679         LDKAcceptChannel this_ptr_conv;
35680         this_ptr_conv.inner = untag_ptr(this_ptr);
35681         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35683         this_ptr_conv.is_owned = false;
35684         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
35685         return ret_conv;
35686 }
35687
35688 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) {
35689         LDKAcceptChannel this_ptr_conv;
35690         this_ptr_conv.inner = untag_ptr(this_ptr);
35691         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35693         this_ptr_conv.is_owned = false;
35694         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
35695 }
35696
35697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35698         LDKAcceptChannel this_ptr_conv;
35699         this_ptr_conv.inner = untag_ptr(this_ptr);
35700         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35702         this_ptr_conv.is_owned = false;
35703         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
35704         return ret_conv;
35705 }
35706
35707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35708         LDKAcceptChannel this_ptr_conv;
35709         this_ptr_conv.inner = untag_ptr(this_ptr);
35710         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35712         this_ptr_conv.is_owned = false;
35713         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
35714 }
35715
35716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35717         LDKAcceptChannel this_ptr_conv;
35718         this_ptr_conv.inner = untag_ptr(this_ptr);
35719         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35721         this_ptr_conv.is_owned = false;
35722         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
35723         return ret_conv;
35724 }
35725
35726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35727         LDKAcceptChannel this_ptr_conv;
35728         this_ptr_conv.inner = untag_ptr(this_ptr);
35729         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35731         this_ptr_conv.is_owned = false;
35732         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
35733 }
35734
35735 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
35736         LDKAcceptChannel this_ptr_conv;
35737         this_ptr_conv.inner = untag_ptr(this_ptr);
35738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35740         this_ptr_conv.is_owned = false;
35741         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
35742         return ret_conv;
35743 }
35744
35745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35746         LDKAcceptChannel this_ptr_conv;
35747         this_ptr_conv.inner = untag_ptr(this_ptr);
35748         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35750         this_ptr_conv.is_owned = false;
35751         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
35752 }
35753
35754 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
35755         LDKAcceptChannel this_ptr_conv;
35756         this_ptr_conv.inner = untag_ptr(this_ptr);
35757         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35759         this_ptr_conv.is_owned = false;
35760         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
35761         return ret_conv;
35762 }
35763
35764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35765         LDKAcceptChannel this_ptr_conv;
35766         this_ptr_conv.inner = untag_ptr(this_ptr);
35767         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35769         this_ptr_conv.is_owned = false;
35770         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
35771 }
35772
35773 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35774         LDKAcceptChannel this_ptr_conv;
35775         this_ptr_conv.inner = untag_ptr(this_ptr);
35776         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35778         this_ptr_conv.is_owned = false;
35779         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
35780         return ret_conv;
35781 }
35782
35783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35784         LDKAcceptChannel this_ptr_conv;
35785         this_ptr_conv.inner = untag_ptr(this_ptr);
35786         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35788         this_ptr_conv.is_owned = false;
35789         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
35790 }
35791
35792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35793         LDKAcceptChannel this_ptr_conv;
35794         this_ptr_conv.inner = untag_ptr(this_ptr);
35795         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35797         this_ptr_conv.is_owned = false;
35798         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
35800         return ret_arr;
35801 }
35802
35803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKPublicKey val_ref;
35810         CHECK((*env)->GetArrayLength(env, val) == 33);
35811         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35812         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
35813 }
35814
35815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35816         LDKAcceptChannel this_ptr_conv;
35817         this_ptr_conv.inner = untag_ptr(this_ptr);
35818         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35820         this_ptr_conv.is_owned = false;
35821         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35822         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
35823         return ret_arr;
35824 }
35825
35826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35827         LDKAcceptChannel this_ptr_conv;
35828         this_ptr_conv.inner = untag_ptr(this_ptr);
35829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35831         this_ptr_conv.is_owned = false;
35832         LDKPublicKey val_ref;
35833         CHECK((*env)->GetArrayLength(env, val) == 33);
35834         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35835         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
35836 }
35837
35838 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35839         LDKAcceptChannel this_ptr_conv;
35840         this_ptr_conv.inner = untag_ptr(this_ptr);
35841         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35843         this_ptr_conv.is_owned = false;
35844         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35845         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
35846         return ret_arr;
35847 }
35848
35849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35850         LDKAcceptChannel this_ptr_conv;
35851         this_ptr_conv.inner = untag_ptr(this_ptr);
35852         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35854         this_ptr_conv.is_owned = false;
35855         LDKPublicKey val_ref;
35856         CHECK((*env)->GetArrayLength(env, val) == 33);
35857         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35858         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
35859 }
35860
35861 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35862         LDKAcceptChannel this_ptr_conv;
35863         this_ptr_conv.inner = untag_ptr(this_ptr);
35864         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35866         this_ptr_conv.is_owned = false;
35867         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35868         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
35869         return ret_arr;
35870 }
35871
35872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35873         LDKAcceptChannel this_ptr_conv;
35874         this_ptr_conv.inner = untag_ptr(this_ptr);
35875         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35877         this_ptr_conv.is_owned = false;
35878         LDKPublicKey val_ref;
35879         CHECK((*env)->GetArrayLength(env, val) == 33);
35880         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35881         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35882 }
35883
35884 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35885         LDKAcceptChannel this_ptr_conv;
35886         this_ptr_conv.inner = untag_ptr(this_ptr);
35887         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35889         this_ptr_conv.is_owned = false;
35890         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35891         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
35892         return ret_arr;
35893 }
35894
35895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35896         LDKAcceptChannel this_ptr_conv;
35897         this_ptr_conv.inner = untag_ptr(this_ptr);
35898         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35900         this_ptr_conv.is_owned = false;
35901         LDKPublicKey val_ref;
35902         CHECK((*env)->GetArrayLength(env, val) == 33);
35903         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35904         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
35905 }
35906
35907 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35908         LDKAcceptChannel this_ptr_conv;
35909         this_ptr_conv.inner = untag_ptr(this_ptr);
35910         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35912         this_ptr_conv.is_owned = false;
35913         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35914         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
35915         return ret_arr;
35916 }
35917
35918 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) {
35919         LDKAcceptChannel this_ptr_conv;
35920         this_ptr_conv.inner = untag_ptr(this_ptr);
35921         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35923         this_ptr_conv.is_owned = false;
35924         LDKPublicKey val_ref;
35925         CHECK((*env)->GetArrayLength(env, val) == 33);
35926         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35927         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
35928 }
35929
35930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
35931         LDKAcceptChannel this_ptr_conv;
35932         this_ptr_conv.inner = untag_ptr(this_ptr);
35933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35935         this_ptr_conv.is_owned = false;
35936         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
35937         int64_t ret_ref = 0;
35938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35939         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35940         return ret_ref;
35941 }
35942
35943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35944         LDKAcceptChannel this_ptr_conv;
35945         this_ptr_conv.inner = untag_ptr(this_ptr);
35946         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35948         this_ptr_conv.is_owned = false;
35949         LDKChannelTypeFeatures val_conv;
35950         val_conv.inner = untag_ptr(val);
35951         val_conv.is_owned = ptr_is_owned(val);
35952         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35953         val_conv = ChannelTypeFeatures_clone(&val_conv);
35954         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
35955 }
35956
35957 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
35958         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
35959         int64_t ret_ref = 0;
35960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35961         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35962         return ret_ref;
35963 }
35964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35965         LDKAcceptChannel arg_conv;
35966         arg_conv.inner = untag_ptr(arg);
35967         arg_conv.is_owned = ptr_is_owned(arg);
35968         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35969         arg_conv.is_owned = false;
35970         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
35971         return ret_conv;
35972 }
35973
35974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35975         LDKAcceptChannel orig_conv;
35976         orig_conv.inner = untag_ptr(orig);
35977         orig_conv.is_owned = ptr_is_owned(orig);
35978         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35979         orig_conv.is_owned = false;
35980         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
35981         int64_t ret_ref = 0;
35982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35983         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35984         return ret_ref;
35985 }
35986
35987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35988         LDKAcceptChannel a_conv;
35989         a_conv.inner = untag_ptr(a);
35990         a_conv.is_owned = ptr_is_owned(a);
35991         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35992         a_conv.is_owned = false;
35993         LDKAcceptChannel b_conv;
35994         b_conv.inner = untag_ptr(b);
35995         b_conv.is_owned = ptr_is_owned(b);
35996         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35997         b_conv.is_owned = false;
35998         jboolean ret_conv = AcceptChannel_eq(&a_conv, &b_conv);
35999         return ret_conv;
36000 }
36001
36002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36003         LDKFundingCreated this_obj_conv;
36004         this_obj_conv.inner = untag_ptr(this_obj);
36005         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36007         FundingCreated_free(this_obj_conv);
36008 }
36009
36010 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36011         LDKFundingCreated this_ptr_conv;
36012         this_ptr_conv.inner = untag_ptr(this_ptr);
36013         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36015         this_ptr_conv.is_owned = false;
36016         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36017         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
36018         return ret_arr;
36019 }
36020
36021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36022         LDKFundingCreated this_ptr_conv;
36023         this_ptr_conv.inner = untag_ptr(this_ptr);
36024         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36026         this_ptr_conv.is_owned = false;
36027         LDKThirtyTwoBytes val_ref;
36028         CHECK((*env)->GetArrayLength(env, val) == 32);
36029         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36030         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
36031 }
36032
36033 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
36034         LDKFundingCreated this_ptr_conv;
36035         this_ptr_conv.inner = untag_ptr(this_ptr);
36036         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36038         this_ptr_conv.is_owned = false;
36039         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36040         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
36041         return ret_arr;
36042 }
36043
36044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36045         LDKFundingCreated this_ptr_conv;
36046         this_ptr_conv.inner = untag_ptr(this_ptr);
36047         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36049         this_ptr_conv.is_owned = false;
36050         LDKThirtyTwoBytes val_ref;
36051         CHECK((*env)->GetArrayLength(env, val) == 32);
36052         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36053         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
36054 }
36055
36056 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
36057         LDKFundingCreated this_ptr_conv;
36058         this_ptr_conv.inner = untag_ptr(this_ptr);
36059         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36061         this_ptr_conv.is_owned = false;
36062         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
36063         return ret_conv;
36064 }
36065
36066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
36067         LDKFundingCreated this_ptr_conv;
36068         this_ptr_conv.inner = untag_ptr(this_ptr);
36069         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36071         this_ptr_conv.is_owned = false;
36072         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
36073 }
36074
36075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36076         LDKFundingCreated this_ptr_conv;
36077         this_ptr_conv.inner = untag_ptr(this_ptr);
36078         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36080         this_ptr_conv.is_owned = false;
36081         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36082         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
36083         return ret_arr;
36084 }
36085
36086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKSignature val_ref;
36093         CHECK((*env)->GetArrayLength(env, val) == 64);
36094         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36095         FundingCreated_set_signature(&this_ptr_conv, val_ref);
36096 }
36097
36098 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) {
36099         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
36100         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
36101         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
36102         LDKThirtyTwoBytes funding_txid_arg_ref;
36103         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
36104         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
36105         LDKSignature signature_arg_ref;
36106         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36107         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36108         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
36109         int64_t ret_ref = 0;
36110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36111         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36112         return ret_ref;
36113 }
36114
36115 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
36116         LDKFundingCreated ret_var = FundingCreated_clone(arg);
36117         int64_t ret_ref = 0;
36118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36119         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36120         return ret_ref;
36121 }
36122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36123         LDKFundingCreated arg_conv;
36124         arg_conv.inner = untag_ptr(arg);
36125         arg_conv.is_owned = ptr_is_owned(arg);
36126         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36127         arg_conv.is_owned = false;
36128         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
36129         return ret_conv;
36130 }
36131
36132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36133         LDKFundingCreated orig_conv;
36134         orig_conv.inner = untag_ptr(orig);
36135         orig_conv.is_owned = ptr_is_owned(orig);
36136         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36137         orig_conv.is_owned = false;
36138         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
36139         int64_t ret_ref = 0;
36140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36141         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36142         return ret_ref;
36143 }
36144
36145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingCreated_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36146         LDKFundingCreated a_conv;
36147         a_conv.inner = untag_ptr(a);
36148         a_conv.is_owned = ptr_is_owned(a);
36149         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36150         a_conv.is_owned = false;
36151         LDKFundingCreated b_conv;
36152         b_conv.inner = untag_ptr(b);
36153         b_conv.is_owned = ptr_is_owned(b);
36154         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36155         b_conv.is_owned = false;
36156         jboolean ret_conv = FundingCreated_eq(&a_conv, &b_conv);
36157         return ret_conv;
36158 }
36159
36160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36161         LDKFundingSigned this_obj_conv;
36162         this_obj_conv.inner = untag_ptr(this_obj);
36163         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36165         FundingSigned_free(this_obj_conv);
36166 }
36167
36168 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36169         LDKFundingSigned this_ptr_conv;
36170         this_ptr_conv.inner = untag_ptr(this_ptr);
36171         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36173         this_ptr_conv.is_owned = false;
36174         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36175         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
36176         return ret_arr;
36177 }
36178
36179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36180         LDKFundingSigned this_ptr_conv;
36181         this_ptr_conv.inner = untag_ptr(this_ptr);
36182         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36184         this_ptr_conv.is_owned = false;
36185         LDKThirtyTwoBytes val_ref;
36186         CHECK((*env)->GetArrayLength(env, val) == 32);
36187         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36188         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
36189 }
36190
36191 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36192         LDKFundingSigned this_ptr_conv;
36193         this_ptr_conv.inner = untag_ptr(this_ptr);
36194         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36196         this_ptr_conv.is_owned = false;
36197         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36198         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
36199         return ret_arr;
36200 }
36201
36202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36203         LDKFundingSigned this_ptr_conv;
36204         this_ptr_conv.inner = untag_ptr(this_ptr);
36205         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36207         this_ptr_conv.is_owned = false;
36208         LDKSignature val_ref;
36209         CHECK((*env)->GetArrayLength(env, val) == 64);
36210         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36211         FundingSigned_set_signature(&this_ptr_conv, val_ref);
36212 }
36213
36214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
36215         LDKThirtyTwoBytes channel_id_arg_ref;
36216         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36217         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36218         LDKSignature signature_arg_ref;
36219         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36220         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36221         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
36222         int64_t ret_ref = 0;
36223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36224         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36225         return ret_ref;
36226 }
36227
36228 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
36229         LDKFundingSigned ret_var = FundingSigned_clone(arg);
36230         int64_t ret_ref = 0;
36231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36232         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36233         return ret_ref;
36234 }
36235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36236         LDKFundingSigned arg_conv;
36237         arg_conv.inner = untag_ptr(arg);
36238         arg_conv.is_owned = ptr_is_owned(arg);
36239         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36240         arg_conv.is_owned = false;
36241         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
36242         return ret_conv;
36243 }
36244
36245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36246         LDKFundingSigned orig_conv;
36247         orig_conv.inner = untag_ptr(orig);
36248         orig_conv.is_owned = ptr_is_owned(orig);
36249         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36250         orig_conv.is_owned = false;
36251         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
36252         int64_t ret_ref = 0;
36253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36255         return ret_ref;
36256 }
36257
36258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36259         LDKFundingSigned a_conv;
36260         a_conv.inner = untag_ptr(a);
36261         a_conv.is_owned = ptr_is_owned(a);
36262         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36263         a_conv.is_owned = false;
36264         LDKFundingSigned b_conv;
36265         b_conv.inner = untag_ptr(b);
36266         b_conv.is_owned = ptr_is_owned(b);
36267         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36268         b_conv.is_owned = false;
36269         jboolean ret_conv = FundingSigned_eq(&a_conv, &b_conv);
36270         return ret_conv;
36271 }
36272
36273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36274         LDKChannelReady this_obj_conv;
36275         this_obj_conv.inner = untag_ptr(this_obj);
36276         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36278         ChannelReady_free(this_obj_conv);
36279 }
36280
36281 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36282         LDKChannelReady this_ptr_conv;
36283         this_ptr_conv.inner = untag_ptr(this_ptr);
36284         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36286         this_ptr_conv.is_owned = false;
36287         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36288         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
36289         return ret_arr;
36290 }
36291
36292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36293         LDKChannelReady this_ptr_conv;
36294         this_ptr_conv.inner = untag_ptr(this_ptr);
36295         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36297         this_ptr_conv.is_owned = false;
36298         LDKThirtyTwoBytes val_ref;
36299         CHECK((*env)->GetArrayLength(env, val) == 32);
36300         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36301         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
36302 }
36303
36304 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36305         LDKChannelReady this_ptr_conv;
36306         this_ptr_conv.inner = untag_ptr(this_ptr);
36307         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36309         this_ptr_conv.is_owned = false;
36310         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36311         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
36312         return ret_arr;
36313 }
36314
36315 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) {
36316         LDKChannelReady this_ptr_conv;
36317         this_ptr_conv.inner = untag_ptr(this_ptr);
36318         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36320         this_ptr_conv.is_owned = false;
36321         LDKPublicKey val_ref;
36322         CHECK((*env)->GetArrayLength(env, val) == 33);
36323         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36324         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
36325 }
36326
36327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
36328         LDKChannelReady this_ptr_conv;
36329         this_ptr_conv.inner = untag_ptr(this_ptr);
36330         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36332         this_ptr_conv.is_owned = false;
36333         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36334         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
36335         int64_t ret_ref = tag_ptr(ret_copy, true);
36336         return ret_ref;
36337 }
36338
36339 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) {
36340         LDKChannelReady this_ptr_conv;
36341         this_ptr_conv.inner = untag_ptr(this_ptr);
36342         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36344         this_ptr_conv.is_owned = false;
36345         void* val_ptr = untag_ptr(val);
36346         CHECK_ACCESS(val_ptr);
36347         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36348         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
36349         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
36350 }
36351
36352 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) {
36353         LDKThirtyTwoBytes channel_id_arg_ref;
36354         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36355         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36356         LDKPublicKey next_per_commitment_point_arg_ref;
36357         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
36358         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
36359         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
36360         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
36361         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
36362         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
36363         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
36364         int64_t ret_ref = 0;
36365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36366         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36367         return ret_ref;
36368 }
36369
36370 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
36371         LDKChannelReady ret_var = ChannelReady_clone(arg);
36372         int64_t ret_ref = 0;
36373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36374         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36375         return ret_ref;
36376 }
36377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36378         LDKChannelReady arg_conv;
36379         arg_conv.inner = untag_ptr(arg);
36380         arg_conv.is_owned = ptr_is_owned(arg);
36381         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36382         arg_conv.is_owned = false;
36383         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
36384         return ret_conv;
36385 }
36386
36387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36388         LDKChannelReady orig_conv;
36389         orig_conv.inner = untag_ptr(orig);
36390         orig_conv.is_owned = ptr_is_owned(orig);
36391         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36392         orig_conv.is_owned = false;
36393         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
36394         int64_t ret_ref = 0;
36395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36396         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36397         return ret_ref;
36398 }
36399
36400 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReady_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36401         LDKChannelReady a_conv;
36402         a_conv.inner = untag_ptr(a);
36403         a_conv.is_owned = ptr_is_owned(a);
36404         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36405         a_conv.is_owned = false;
36406         LDKChannelReady b_conv;
36407         b_conv.inner = untag_ptr(b);
36408         b_conv.is_owned = ptr_is_owned(b);
36409         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36410         b_conv.is_owned = false;
36411         jboolean ret_conv = ChannelReady_eq(&a_conv, &b_conv);
36412         return ret_conv;
36413 }
36414
36415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36416         LDKShutdown this_obj_conv;
36417         this_obj_conv.inner = untag_ptr(this_obj);
36418         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36420         Shutdown_free(this_obj_conv);
36421 }
36422
36423 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36424         LDKShutdown this_ptr_conv;
36425         this_ptr_conv.inner = untag_ptr(this_ptr);
36426         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36428         this_ptr_conv.is_owned = false;
36429         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36430         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
36431         return ret_arr;
36432 }
36433
36434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36435         LDKShutdown this_ptr_conv;
36436         this_ptr_conv.inner = untag_ptr(this_ptr);
36437         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36439         this_ptr_conv.is_owned = false;
36440         LDKThirtyTwoBytes val_ref;
36441         CHECK((*env)->GetArrayLength(env, val) == 32);
36442         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36443         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
36444 }
36445
36446 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
36447         LDKShutdown this_ptr_conv;
36448         this_ptr_conv.inner = untag_ptr(this_ptr);
36449         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36451         this_ptr_conv.is_owned = false;
36452         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
36453         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36454         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36455         return ret_arr;
36456 }
36457
36458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36459         LDKShutdown this_ptr_conv;
36460         this_ptr_conv.inner = untag_ptr(this_ptr);
36461         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36463         this_ptr_conv.is_owned = false;
36464         LDKCVec_u8Z val_ref;
36465         val_ref.datalen = (*env)->GetArrayLength(env, val);
36466         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
36467         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
36468         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
36469 }
36470
36471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
36472         LDKThirtyTwoBytes channel_id_arg_ref;
36473         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36474         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36475         LDKCVec_u8Z scriptpubkey_arg_ref;
36476         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
36477         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
36478         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
36479         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
36480         int64_t ret_ref = 0;
36481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36482         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36483         return ret_ref;
36484 }
36485
36486 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
36487         LDKShutdown ret_var = Shutdown_clone(arg);
36488         int64_t ret_ref = 0;
36489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36490         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36491         return ret_ref;
36492 }
36493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36494         LDKShutdown arg_conv;
36495         arg_conv.inner = untag_ptr(arg);
36496         arg_conv.is_owned = ptr_is_owned(arg);
36497         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36498         arg_conv.is_owned = false;
36499         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
36500         return ret_conv;
36501 }
36502
36503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36504         LDKShutdown orig_conv;
36505         orig_conv.inner = untag_ptr(orig);
36506         orig_conv.is_owned = ptr_is_owned(orig);
36507         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36508         orig_conv.is_owned = false;
36509         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
36510         int64_t ret_ref = 0;
36511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36512         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36513         return ret_ref;
36514 }
36515
36516 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Shutdown_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36517         LDKShutdown a_conv;
36518         a_conv.inner = untag_ptr(a);
36519         a_conv.is_owned = ptr_is_owned(a);
36520         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36521         a_conv.is_owned = false;
36522         LDKShutdown b_conv;
36523         b_conv.inner = untag_ptr(b);
36524         b_conv.is_owned = ptr_is_owned(b);
36525         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36526         b_conv.is_owned = false;
36527         jboolean ret_conv = Shutdown_eq(&a_conv, &b_conv);
36528         return ret_conv;
36529 }
36530
36531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36532         LDKClosingSignedFeeRange this_obj_conv;
36533         this_obj_conv.inner = untag_ptr(this_obj);
36534         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36536         ClosingSignedFeeRange_free(this_obj_conv);
36537 }
36538
36539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36540         LDKClosingSignedFeeRange this_ptr_conv;
36541         this_ptr_conv.inner = untag_ptr(this_ptr);
36542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36544         this_ptr_conv.is_owned = false;
36545         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
36546         return ret_conv;
36547 }
36548
36549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36550         LDKClosingSignedFeeRange this_ptr_conv;
36551         this_ptr_conv.inner = untag_ptr(this_ptr);
36552         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36554         this_ptr_conv.is_owned = false;
36555         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
36556 }
36557
36558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36559         LDKClosingSignedFeeRange this_ptr_conv;
36560         this_ptr_conv.inner = untag_ptr(this_ptr);
36561         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36563         this_ptr_conv.is_owned = false;
36564         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
36565         return ret_conv;
36566 }
36567
36568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36569         LDKClosingSignedFeeRange this_ptr_conv;
36570         this_ptr_conv.inner = untag_ptr(this_ptr);
36571         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36573         this_ptr_conv.is_owned = false;
36574         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
36575 }
36576
36577 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) {
36578         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
36579         int64_t ret_ref = 0;
36580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36581         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36582         return ret_ref;
36583 }
36584
36585 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
36586         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
36587         int64_t ret_ref = 0;
36588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36589         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36590         return ret_ref;
36591 }
36592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36593         LDKClosingSignedFeeRange arg_conv;
36594         arg_conv.inner = untag_ptr(arg);
36595         arg_conv.is_owned = ptr_is_owned(arg);
36596         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36597         arg_conv.is_owned = false;
36598         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
36599         return ret_conv;
36600 }
36601
36602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36603         LDKClosingSignedFeeRange orig_conv;
36604         orig_conv.inner = untag_ptr(orig);
36605         orig_conv.is_owned = ptr_is_owned(orig);
36606         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36607         orig_conv.is_owned = false;
36608         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
36609         int64_t ret_ref = 0;
36610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36611         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36612         return ret_ref;
36613 }
36614
36615 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36616         LDKClosingSignedFeeRange a_conv;
36617         a_conv.inner = untag_ptr(a);
36618         a_conv.is_owned = ptr_is_owned(a);
36619         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36620         a_conv.is_owned = false;
36621         LDKClosingSignedFeeRange b_conv;
36622         b_conv.inner = untag_ptr(b);
36623         b_conv.is_owned = ptr_is_owned(b);
36624         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36625         b_conv.is_owned = false;
36626         jboolean ret_conv = ClosingSignedFeeRange_eq(&a_conv, &b_conv);
36627         return ret_conv;
36628 }
36629
36630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36631         LDKClosingSigned this_obj_conv;
36632         this_obj_conv.inner = untag_ptr(this_obj);
36633         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36635         ClosingSigned_free(this_obj_conv);
36636 }
36637
36638 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36639         LDKClosingSigned this_ptr_conv;
36640         this_ptr_conv.inner = untag_ptr(this_ptr);
36641         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36643         this_ptr_conv.is_owned = false;
36644         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36645         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
36646         return ret_arr;
36647 }
36648
36649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36650         LDKClosingSigned this_ptr_conv;
36651         this_ptr_conv.inner = untag_ptr(this_ptr);
36652         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36654         this_ptr_conv.is_owned = false;
36655         LDKThirtyTwoBytes val_ref;
36656         CHECK((*env)->GetArrayLength(env, val) == 32);
36657         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36658         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
36659 }
36660
36661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
36662         LDKClosingSigned this_ptr_conv;
36663         this_ptr_conv.inner = untag_ptr(this_ptr);
36664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36666         this_ptr_conv.is_owned = false;
36667         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
36668         return ret_conv;
36669 }
36670
36671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36672         LDKClosingSigned this_ptr_conv;
36673         this_ptr_conv.inner = untag_ptr(this_ptr);
36674         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36676         this_ptr_conv.is_owned = false;
36677         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
36678 }
36679
36680 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36681         LDKClosingSigned this_ptr_conv;
36682         this_ptr_conv.inner = untag_ptr(this_ptr);
36683         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36685         this_ptr_conv.is_owned = false;
36686         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36687         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
36688         return ret_arr;
36689 }
36690
36691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKSignature val_ref;
36698         CHECK((*env)->GetArrayLength(env, val) == 64);
36699         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36700         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
36701 }
36702
36703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
36704         LDKClosingSigned this_ptr_conv;
36705         this_ptr_conv.inner = untag_ptr(this_ptr);
36706         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36708         this_ptr_conv.is_owned = false;
36709         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
36710         int64_t ret_ref = 0;
36711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36712         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36713         return ret_ref;
36714 }
36715
36716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36717         LDKClosingSigned this_ptr_conv;
36718         this_ptr_conv.inner = untag_ptr(this_ptr);
36719         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36721         this_ptr_conv.is_owned = false;
36722         LDKClosingSignedFeeRange val_conv;
36723         val_conv.inner = untag_ptr(val);
36724         val_conv.is_owned = ptr_is_owned(val);
36725         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36726         val_conv = ClosingSignedFeeRange_clone(&val_conv);
36727         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
36728 }
36729
36730 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) {
36731         LDKThirtyTwoBytes channel_id_arg_ref;
36732         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36733         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36734         LDKSignature signature_arg_ref;
36735         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36736         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36737         LDKClosingSignedFeeRange fee_range_arg_conv;
36738         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
36739         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
36740         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
36741         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
36742         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
36743         int64_t ret_ref = 0;
36744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36745         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36746         return ret_ref;
36747 }
36748
36749 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
36750         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
36751         int64_t ret_ref = 0;
36752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36753         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36754         return ret_ref;
36755 }
36756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36757         LDKClosingSigned arg_conv;
36758         arg_conv.inner = untag_ptr(arg);
36759         arg_conv.is_owned = ptr_is_owned(arg);
36760         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36761         arg_conv.is_owned = false;
36762         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
36763         return ret_conv;
36764 }
36765
36766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36767         LDKClosingSigned orig_conv;
36768         orig_conv.inner = untag_ptr(orig);
36769         orig_conv.is_owned = ptr_is_owned(orig);
36770         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36771         orig_conv.is_owned = false;
36772         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
36773         int64_t ret_ref = 0;
36774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36775         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36776         return ret_ref;
36777 }
36778
36779 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36780         LDKClosingSigned a_conv;
36781         a_conv.inner = untag_ptr(a);
36782         a_conv.is_owned = ptr_is_owned(a);
36783         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36784         a_conv.is_owned = false;
36785         LDKClosingSigned b_conv;
36786         b_conv.inner = untag_ptr(b);
36787         b_conv.is_owned = ptr_is_owned(b);
36788         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36789         b_conv.is_owned = false;
36790         jboolean ret_conv = ClosingSigned_eq(&a_conv, &b_conv);
36791         return ret_conv;
36792 }
36793
36794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36795         LDKUpdateAddHTLC this_obj_conv;
36796         this_obj_conv.inner = untag_ptr(this_obj);
36797         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36799         UpdateAddHTLC_free(this_obj_conv);
36800 }
36801
36802 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36803         LDKUpdateAddHTLC this_ptr_conv;
36804         this_ptr_conv.inner = untag_ptr(this_ptr);
36805         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36807         this_ptr_conv.is_owned = false;
36808         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36809         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
36810         return ret_arr;
36811 }
36812
36813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36814         LDKUpdateAddHTLC this_ptr_conv;
36815         this_ptr_conv.inner = untag_ptr(this_ptr);
36816         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36818         this_ptr_conv.is_owned = false;
36819         LDKThirtyTwoBytes val_ref;
36820         CHECK((*env)->GetArrayLength(env, val) == 32);
36821         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36822         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
36823 }
36824
36825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36826         LDKUpdateAddHTLC this_ptr_conv;
36827         this_ptr_conv.inner = untag_ptr(this_ptr);
36828         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36830         this_ptr_conv.is_owned = false;
36831         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
36832         return ret_conv;
36833 }
36834
36835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36836         LDKUpdateAddHTLC this_ptr_conv;
36837         this_ptr_conv.inner = untag_ptr(this_ptr);
36838         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36840         this_ptr_conv.is_owned = false;
36841         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
36842 }
36843
36844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36845         LDKUpdateAddHTLC this_ptr_conv;
36846         this_ptr_conv.inner = untag_ptr(this_ptr);
36847         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36849         this_ptr_conv.is_owned = false;
36850         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
36851         return ret_conv;
36852 }
36853
36854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36855         LDKUpdateAddHTLC this_ptr_conv;
36856         this_ptr_conv.inner = untag_ptr(this_ptr);
36857         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36859         this_ptr_conv.is_owned = false;
36860         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
36861 }
36862
36863 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36864         LDKUpdateAddHTLC this_ptr_conv;
36865         this_ptr_conv.inner = untag_ptr(this_ptr);
36866         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36868         this_ptr_conv.is_owned = false;
36869         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36870         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
36871         return ret_arr;
36872 }
36873
36874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKThirtyTwoBytes val_ref;
36881         CHECK((*env)->GetArrayLength(env, val) == 32);
36882         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36883         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
36884 }
36885
36886 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
36887         LDKUpdateAddHTLC this_ptr_conv;
36888         this_ptr_conv.inner = untag_ptr(this_ptr);
36889         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36891         this_ptr_conv.is_owned = false;
36892         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
36893         return ret_conv;
36894 }
36895
36896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36897         LDKUpdateAddHTLC this_ptr_conv;
36898         this_ptr_conv.inner = untag_ptr(this_ptr);
36899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36901         this_ptr_conv.is_owned = false;
36902         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
36903 }
36904
36905 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
36906         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
36907         int64_t ret_ref = 0;
36908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36910         return ret_ref;
36911 }
36912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36913         LDKUpdateAddHTLC arg_conv;
36914         arg_conv.inner = untag_ptr(arg);
36915         arg_conv.is_owned = ptr_is_owned(arg);
36916         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36917         arg_conv.is_owned = false;
36918         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
36919         return ret_conv;
36920 }
36921
36922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36923         LDKUpdateAddHTLC orig_conv;
36924         orig_conv.inner = untag_ptr(orig);
36925         orig_conv.is_owned = ptr_is_owned(orig);
36926         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36927         orig_conv.is_owned = false;
36928         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
36929         int64_t ret_ref = 0;
36930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36932         return ret_ref;
36933 }
36934
36935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36936         LDKUpdateAddHTLC a_conv;
36937         a_conv.inner = untag_ptr(a);
36938         a_conv.is_owned = ptr_is_owned(a);
36939         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36940         a_conv.is_owned = false;
36941         LDKUpdateAddHTLC b_conv;
36942         b_conv.inner = untag_ptr(b);
36943         b_conv.is_owned = ptr_is_owned(b);
36944         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36945         b_conv.is_owned = false;
36946         jboolean ret_conv = UpdateAddHTLC_eq(&a_conv, &b_conv);
36947         return ret_conv;
36948 }
36949
36950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36951         LDKOnionMessage this_obj_conv;
36952         this_obj_conv.inner = untag_ptr(this_obj);
36953         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36955         OnionMessage_free(this_obj_conv);
36956 }
36957
36958 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36959         LDKOnionMessage this_ptr_conv;
36960         this_ptr_conv.inner = untag_ptr(this_ptr);
36961         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36963         this_ptr_conv.is_owned = false;
36964         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36965         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OnionMessage_get_blinding_point(&this_ptr_conv).compressed_form);
36966         return ret_arr;
36967 }
36968
36969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36970         LDKOnionMessage this_ptr_conv;
36971         this_ptr_conv.inner = untag_ptr(this_ptr);
36972         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36974         this_ptr_conv.is_owned = false;
36975         LDKPublicKey val_ref;
36976         CHECK((*env)->GetArrayLength(env, val) == 33);
36977         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36978         OnionMessage_set_blinding_point(&this_ptr_conv, val_ref);
36979 }
36980
36981 static inline uint64_t OnionMessage_clone_ptr(LDKOnionMessage *NONNULL_PTR arg) {
36982         LDKOnionMessage ret_var = OnionMessage_clone(arg);
36983         int64_t ret_ref = 0;
36984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36985         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36986         return ret_ref;
36987 }
36988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36989         LDKOnionMessage arg_conv;
36990         arg_conv.inner = untag_ptr(arg);
36991         arg_conv.is_owned = ptr_is_owned(arg);
36992         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36993         arg_conv.is_owned = false;
36994         int64_t ret_conv = OnionMessage_clone_ptr(&arg_conv);
36995         return ret_conv;
36996 }
36997
36998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36999         LDKOnionMessage orig_conv;
37000         orig_conv.inner = untag_ptr(orig);
37001         orig_conv.is_owned = ptr_is_owned(orig);
37002         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37003         orig_conv.is_owned = false;
37004         LDKOnionMessage ret_var = OnionMessage_clone(&orig_conv);
37005         int64_t ret_ref = 0;
37006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37007         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37008         return ret_ref;
37009 }
37010
37011 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OnionMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37012         LDKOnionMessage a_conv;
37013         a_conv.inner = untag_ptr(a);
37014         a_conv.is_owned = ptr_is_owned(a);
37015         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37016         a_conv.is_owned = false;
37017         LDKOnionMessage b_conv;
37018         b_conv.inner = untag_ptr(b);
37019         b_conv.is_owned = ptr_is_owned(b);
37020         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37021         b_conv.is_owned = false;
37022         jboolean ret_conv = OnionMessage_eq(&a_conv, &b_conv);
37023         return ret_conv;
37024 }
37025
37026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37027         LDKUpdateFulfillHTLC this_obj_conv;
37028         this_obj_conv.inner = untag_ptr(this_obj);
37029         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37031         UpdateFulfillHTLC_free(this_obj_conv);
37032 }
37033
37034 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37035         LDKUpdateFulfillHTLC this_ptr_conv;
37036         this_ptr_conv.inner = untag_ptr(this_ptr);
37037         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37039         this_ptr_conv.is_owned = false;
37040         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37041         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
37042         return ret_arr;
37043 }
37044
37045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37046         LDKUpdateFulfillHTLC this_ptr_conv;
37047         this_ptr_conv.inner = untag_ptr(this_ptr);
37048         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37050         this_ptr_conv.is_owned = false;
37051         LDKThirtyTwoBytes val_ref;
37052         CHECK((*env)->GetArrayLength(env, val) == 32);
37053         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37054         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
37055 }
37056
37057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37058         LDKUpdateFulfillHTLC this_ptr_conv;
37059         this_ptr_conv.inner = untag_ptr(this_ptr);
37060         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37062         this_ptr_conv.is_owned = false;
37063         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
37064         return ret_conv;
37065 }
37066
37067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37068         LDKUpdateFulfillHTLC this_ptr_conv;
37069         this_ptr_conv.inner = untag_ptr(this_ptr);
37070         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37072         this_ptr_conv.is_owned = false;
37073         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
37074 }
37075
37076 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
37077         LDKUpdateFulfillHTLC this_ptr_conv;
37078         this_ptr_conv.inner = untag_ptr(this_ptr);
37079         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37081         this_ptr_conv.is_owned = false;
37082         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37083         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
37084         return ret_arr;
37085 }
37086
37087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKThirtyTwoBytes val_ref;
37094         CHECK((*env)->GetArrayLength(env, val) == 32);
37095         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37096         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
37097 }
37098
37099 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) {
37100         LDKThirtyTwoBytes channel_id_arg_ref;
37101         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37102         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37103         LDKThirtyTwoBytes payment_preimage_arg_ref;
37104         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
37105         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
37106         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
37107         int64_t ret_ref = 0;
37108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37109         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37110         return ret_ref;
37111 }
37112
37113 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
37114         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
37115         int64_t ret_ref = 0;
37116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37117         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37118         return ret_ref;
37119 }
37120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37121         LDKUpdateFulfillHTLC arg_conv;
37122         arg_conv.inner = untag_ptr(arg);
37123         arg_conv.is_owned = ptr_is_owned(arg);
37124         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37125         arg_conv.is_owned = false;
37126         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
37127         return ret_conv;
37128 }
37129
37130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37131         LDKUpdateFulfillHTLC orig_conv;
37132         orig_conv.inner = untag_ptr(orig);
37133         orig_conv.is_owned = ptr_is_owned(orig);
37134         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37135         orig_conv.is_owned = false;
37136         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
37137         int64_t ret_ref = 0;
37138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37139         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37140         return ret_ref;
37141 }
37142
37143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37144         LDKUpdateFulfillHTLC a_conv;
37145         a_conv.inner = untag_ptr(a);
37146         a_conv.is_owned = ptr_is_owned(a);
37147         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37148         a_conv.is_owned = false;
37149         LDKUpdateFulfillHTLC b_conv;
37150         b_conv.inner = untag_ptr(b);
37151         b_conv.is_owned = ptr_is_owned(b);
37152         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37153         b_conv.is_owned = false;
37154         jboolean ret_conv = UpdateFulfillHTLC_eq(&a_conv, &b_conv);
37155         return ret_conv;
37156 }
37157
37158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37159         LDKUpdateFailHTLC this_obj_conv;
37160         this_obj_conv.inner = untag_ptr(this_obj);
37161         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37163         UpdateFailHTLC_free(this_obj_conv);
37164 }
37165
37166 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37167         LDKUpdateFailHTLC this_ptr_conv;
37168         this_ptr_conv.inner = untag_ptr(this_ptr);
37169         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37171         this_ptr_conv.is_owned = false;
37172         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37173         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
37174         return ret_arr;
37175 }
37176
37177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37178         LDKUpdateFailHTLC this_ptr_conv;
37179         this_ptr_conv.inner = untag_ptr(this_ptr);
37180         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37182         this_ptr_conv.is_owned = false;
37183         LDKThirtyTwoBytes val_ref;
37184         CHECK((*env)->GetArrayLength(env, val) == 32);
37185         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37186         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
37187 }
37188
37189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37190         LDKUpdateFailHTLC this_ptr_conv;
37191         this_ptr_conv.inner = untag_ptr(this_ptr);
37192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37194         this_ptr_conv.is_owned = false;
37195         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
37196         return ret_conv;
37197 }
37198
37199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37200         LDKUpdateFailHTLC this_ptr_conv;
37201         this_ptr_conv.inner = untag_ptr(this_ptr);
37202         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37204         this_ptr_conv.is_owned = false;
37205         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
37206 }
37207
37208 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
37209         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
37210         int64_t ret_ref = 0;
37211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37212         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37213         return ret_ref;
37214 }
37215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37216         LDKUpdateFailHTLC arg_conv;
37217         arg_conv.inner = untag_ptr(arg);
37218         arg_conv.is_owned = ptr_is_owned(arg);
37219         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37220         arg_conv.is_owned = false;
37221         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
37222         return ret_conv;
37223 }
37224
37225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37226         LDKUpdateFailHTLC orig_conv;
37227         orig_conv.inner = untag_ptr(orig);
37228         orig_conv.is_owned = ptr_is_owned(orig);
37229         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37230         orig_conv.is_owned = false;
37231         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
37232         int64_t ret_ref = 0;
37233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37234         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37235         return ret_ref;
37236 }
37237
37238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37239         LDKUpdateFailHTLC a_conv;
37240         a_conv.inner = untag_ptr(a);
37241         a_conv.is_owned = ptr_is_owned(a);
37242         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37243         a_conv.is_owned = false;
37244         LDKUpdateFailHTLC b_conv;
37245         b_conv.inner = untag_ptr(b);
37246         b_conv.is_owned = ptr_is_owned(b);
37247         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37248         b_conv.is_owned = false;
37249         jboolean ret_conv = UpdateFailHTLC_eq(&a_conv, &b_conv);
37250         return ret_conv;
37251 }
37252
37253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37254         LDKUpdateFailMalformedHTLC this_obj_conv;
37255         this_obj_conv.inner = untag_ptr(this_obj);
37256         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37258         UpdateFailMalformedHTLC_free(this_obj_conv);
37259 }
37260
37261 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37262         LDKUpdateFailMalformedHTLC this_ptr_conv;
37263         this_ptr_conv.inner = untag_ptr(this_ptr);
37264         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37266         this_ptr_conv.is_owned = false;
37267         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37268         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
37269         return ret_arr;
37270 }
37271
37272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37273         LDKUpdateFailMalformedHTLC this_ptr_conv;
37274         this_ptr_conv.inner = untag_ptr(this_ptr);
37275         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37277         this_ptr_conv.is_owned = false;
37278         LDKThirtyTwoBytes val_ref;
37279         CHECK((*env)->GetArrayLength(env, val) == 32);
37280         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37281         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
37282 }
37283
37284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37285         LDKUpdateFailMalformedHTLC this_ptr_conv;
37286         this_ptr_conv.inner = untag_ptr(this_ptr);
37287         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37289         this_ptr_conv.is_owned = false;
37290         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
37291         return ret_conv;
37292 }
37293
37294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37295         LDKUpdateFailMalformedHTLC this_ptr_conv;
37296         this_ptr_conv.inner = untag_ptr(this_ptr);
37297         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37299         this_ptr_conv.is_owned = false;
37300         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
37301 }
37302
37303 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
37304         LDKUpdateFailMalformedHTLC this_ptr_conv;
37305         this_ptr_conv.inner = untag_ptr(this_ptr);
37306         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37308         this_ptr_conv.is_owned = false;
37309         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
37310         return ret_conv;
37311 }
37312
37313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37314         LDKUpdateFailMalformedHTLC this_ptr_conv;
37315         this_ptr_conv.inner = untag_ptr(this_ptr);
37316         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37318         this_ptr_conv.is_owned = false;
37319         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
37320 }
37321
37322 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
37323         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
37324         int64_t ret_ref = 0;
37325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37326         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37327         return ret_ref;
37328 }
37329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37330         LDKUpdateFailMalformedHTLC arg_conv;
37331         arg_conv.inner = untag_ptr(arg);
37332         arg_conv.is_owned = ptr_is_owned(arg);
37333         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37334         arg_conv.is_owned = false;
37335         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
37336         return ret_conv;
37337 }
37338
37339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37340         LDKUpdateFailMalformedHTLC orig_conv;
37341         orig_conv.inner = untag_ptr(orig);
37342         orig_conv.is_owned = ptr_is_owned(orig);
37343         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37344         orig_conv.is_owned = false;
37345         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
37346         int64_t ret_ref = 0;
37347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37348         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37349         return ret_ref;
37350 }
37351
37352 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37353         LDKUpdateFailMalformedHTLC a_conv;
37354         a_conv.inner = untag_ptr(a);
37355         a_conv.is_owned = ptr_is_owned(a);
37356         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37357         a_conv.is_owned = false;
37358         LDKUpdateFailMalformedHTLC b_conv;
37359         b_conv.inner = untag_ptr(b);
37360         b_conv.is_owned = ptr_is_owned(b);
37361         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37362         b_conv.is_owned = false;
37363         jboolean ret_conv = UpdateFailMalformedHTLC_eq(&a_conv, &b_conv);
37364         return ret_conv;
37365 }
37366
37367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37368         LDKCommitmentSigned this_obj_conv;
37369         this_obj_conv.inner = untag_ptr(this_obj);
37370         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37372         CommitmentSigned_free(this_obj_conv);
37373 }
37374
37375 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37376         LDKCommitmentSigned this_ptr_conv;
37377         this_ptr_conv.inner = untag_ptr(this_ptr);
37378         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37380         this_ptr_conv.is_owned = false;
37381         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37382         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
37383         return ret_arr;
37384 }
37385
37386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37387         LDKCommitmentSigned this_ptr_conv;
37388         this_ptr_conv.inner = untag_ptr(this_ptr);
37389         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37391         this_ptr_conv.is_owned = false;
37392         LDKThirtyTwoBytes val_ref;
37393         CHECK((*env)->GetArrayLength(env, val) == 32);
37394         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37395         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
37396 }
37397
37398 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
37399         LDKCommitmentSigned this_ptr_conv;
37400         this_ptr_conv.inner = untag_ptr(this_ptr);
37401         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37403         this_ptr_conv.is_owned = false;
37404         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37405         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
37406         return ret_arr;
37407 }
37408
37409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37410         LDKCommitmentSigned this_ptr_conv;
37411         this_ptr_conv.inner = untag_ptr(this_ptr);
37412         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37414         this_ptr_conv.is_owned = false;
37415         LDKSignature val_ref;
37416         CHECK((*env)->GetArrayLength(env, val) == 64);
37417         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37418         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
37419 }
37420
37421 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr) {
37422         LDKCommitmentSigned this_ptr_conv;
37423         this_ptr_conv.inner = untag_ptr(this_ptr);
37424         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37426         this_ptr_conv.is_owned = false;
37427         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
37428         jobjectArray ret_arr = NULL;
37429         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
37430         ;
37431         for (size_t i = 0; i < ret_var.datalen; i++) {
37432                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
37433                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
37434                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
37435         }
37436         
37437         FREE(ret_var.data);
37438         return ret_arr;
37439 }
37440
37441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
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 val_constr;
37448         val_constr.datalen = (*env)->GetArrayLength(env, val);
37449         if (val_constr.datalen > 0)
37450                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37451         else
37452                 val_constr.data = NULL;
37453         for (size_t i = 0; i < val_constr.datalen; i++) {
37454                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
37455                 LDKSignature val_conv_8_ref;
37456                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
37457                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
37458                 val_constr.data[i] = val_conv_8_ref;
37459         }
37460         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
37461 }
37462
37463 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) {
37464         LDKThirtyTwoBytes channel_id_arg_ref;
37465         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37466         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37467         LDKSignature signature_arg_ref;
37468         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
37469         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
37470         LDKCVec_SignatureZ htlc_signatures_arg_constr;
37471         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
37472         if (htlc_signatures_arg_constr.datalen > 0)
37473                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37474         else
37475                 htlc_signatures_arg_constr.data = NULL;
37476         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
37477                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
37478                 LDKSignature htlc_signatures_arg_conv_8_ref;
37479                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
37480                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
37481                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
37482         }
37483         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
37484         int64_t ret_ref = 0;
37485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37486         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37487         return ret_ref;
37488 }
37489
37490 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
37491         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
37492         int64_t ret_ref = 0;
37493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37494         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37495         return ret_ref;
37496 }
37497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37498         LDKCommitmentSigned arg_conv;
37499         arg_conv.inner = untag_ptr(arg);
37500         arg_conv.is_owned = ptr_is_owned(arg);
37501         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37502         arg_conv.is_owned = false;
37503         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
37504         return ret_conv;
37505 }
37506
37507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37508         LDKCommitmentSigned orig_conv;
37509         orig_conv.inner = untag_ptr(orig);
37510         orig_conv.is_owned = ptr_is_owned(orig);
37511         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37512         orig_conv.is_owned = false;
37513         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
37514         int64_t ret_ref = 0;
37515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37516         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37517         return ret_ref;
37518 }
37519
37520 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37521         LDKCommitmentSigned a_conv;
37522         a_conv.inner = untag_ptr(a);
37523         a_conv.is_owned = ptr_is_owned(a);
37524         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37525         a_conv.is_owned = false;
37526         LDKCommitmentSigned b_conv;
37527         b_conv.inner = untag_ptr(b);
37528         b_conv.is_owned = ptr_is_owned(b);
37529         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37530         b_conv.is_owned = false;
37531         jboolean ret_conv = CommitmentSigned_eq(&a_conv, &b_conv);
37532         return ret_conv;
37533 }
37534
37535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37536         LDKRevokeAndACK this_obj_conv;
37537         this_obj_conv.inner = untag_ptr(this_obj);
37538         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37540         RevokeAndACK_free(this_obj_conv);
37541 }
37542
37543 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37544         LDKRevokeAndACK this_ptr_conv;
37545         this_ptr_conv.inner = untag_ptr(this_ptr);
37546         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37548         this_ptr_conv.is_owned = false;
37549         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37550         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
37551         return ret_arr;
37552 }
37553
37554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37555         LDKRevokeAndACK this_ptr_conv;
37556         this_ptr_conv.inner = untag_ptr(this_ptr);
37557         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37559         this_ptr_conv.is_owned = false;
37560         LDKThirtyTwoBytes val_ref;
37561         CHECK((*env)->GetArrayLength(env, val) == 32);
37562         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37563         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
37564 }
37565
37566 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
37567         LDKRevokeAndACK this_ptr_conv;
37568         this_ptr_conv.inner = untag_ptr(this_ptr);
37569         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37571         this_ptr_conv.is_owned = false;
37572         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37573         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
37574         return ret_arr;
37575 }
37576
37577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37578         LDKRevokeAndACK this_ptr_conv;
37579         this_ptr_conv.inner = untag_ptr(this_ptr);
37580         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37582         this_ptr_conv.is_owned = false;
37583         LDKThirtyTwoBytes val_ref;
37584         CHECK((*env)->GetArrayLength(env, val) == 32);
37585         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37586         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
37587 }
37588
37589 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37590         LDKRevokeAndACK this_ptr_conv;
37591         this_ptr_conv.inner = untag_ptr(this_ptr);
37592         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37594         this_ptr_conv.is_owned = false;
37595         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37596         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
37597         return ret_arr;
37598 }
37599
37600 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) {
37601         LDKRevokeAndACK this_ptr_conv;
37602         this_ptr_conv.inner = untag_ptr(this_ptr);
37603         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37605         this_ptr_conv.is_owned = false;
37606         LDKPublicKey val_ref;
37607         CHECK((*env)->GetArrayLength(env, val) == 33);
37608         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37609         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
37610 }
37611
37612 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) {
37613         LDKThirtyTwoBytes channel_id_arg_ref;
37614         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37615         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37616         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
37617         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
37618         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
37619         LDKPublicKey next_per_commitment_point_arg_ref;
37620         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
37621         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
37622         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
37623         int64_t ret_ref = 0;
37624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37625         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37626         return ret_ref;
37627 }
37628
37629 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
37630         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
37631         int64_t ret_ref = 0;
37632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37634         return ret_ref;
37635 }
37636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37637         LDKRevokeAndACK arg_conv;
37638         arg_conv.inner = untag_ptr(arg);
37639         arg_conv.is_owned = ptr_is_owned(arg);
37640         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37641         arg_conv.is_owned = false;
37642         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
37643         return ret_conv;
37644 }
37645
37646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37647         LDKRevokeAndACK orig_conv;
37648         orig_conv.inner = untag_ptr(orig);
37649         orig_conv.is_owned = ptr_is_owned(orig);
37650         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37651         orig_conv.is_owned = false;
37652         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
37653         int64_t ret_ref = 0;
37654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37656         return ret_ref;
37657 }
37658
37659 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37660         LDKRevokeAndACK a_conv;
37661         a_conv.inner = untag_ptr(a);
37662         a_conv.is_owned = ptr_is_owned(a);
37663         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37664         a_conv.is_owned = false;
37665         LDKRevokeAndACK b_conv;
37666         b_conv.inner = untag_ptr(b);
37667         b_conv.is_owned = ptr_is_owned(b);
37668         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37669         b_conv.is_owned = false;
37670         jboolean ret_conv = RevokeAndACK_eq(&a_conv, &b_conv);
37671         return ret_conv;
37672 }
37673
37674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37675         LDKUpdateFee this_obj_conv;
37676         this_obj_conv.inner = untag_ptr(this_obj);
37677         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37679         UpdateFee_free(this_obj_conv);
37680 }
37681
37682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37683         LDKUpdateFee this_ptr_conv;
37684         this_ptr_conv.inner = untag_ptr(this_ptr);
37685         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37687         this_ptr_conv.is_owned = false;
37688         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37689         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
37690         return ret_arr;
37691 }
37692
37693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37694         LDKUpdateFee this_ptr_conv;
37695         this_ptr_conv.inner = untag_ptr(this_ptr);
37696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37698         this_ptr_conv.is_owned = false;
37699         LDKThirtyTwoBytes val_ref;
37700         CHECK((*env)->GetArrayLength(env, val) == 32);
37701         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37702         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
37703 }
37704
37705 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
37706         LDKUpdateFee this_ptr_conv;
37707         this_ptr_conv.inner = untag_ptr(this_ptr);
37708         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37710         this_ptr_conv.is_owned = false;
37711         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
37712         return ret_conv;
37713 }
37714
37715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37716         LDKUpdateFee this_ptr_conv;
37717         this_ptr_conv.inner = untag_ptr(this_ptr);
37718         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37720         this_ptr_conv.is_owned = false;
37721         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
37722 }
37723
37724 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) {
37725         LDKThirtyTwoBytes channel_id_arg_ref;
37726         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37727         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37728         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
37729         int64_t ret_ref = 0;
37730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37731         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37732         return ret_ref;
37733 }
37734
37735 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
37736         LDKUpdateFee ret_var = UpdateFee_clone(arg);
37737         int64_t ret_ref = 0;
37738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37740         return ret_ref;
37741 }
37742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37743         LDKUpdateFee arg_conv;
37744         arg_conv.inner = untag_ptr(arg);
37745         arg_conv.is_owned = ptr_is_owned(arg);
37746         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37747         arg_conv.is_owned = false;
37748         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
37749         return ret_conv;
37750 }
37751
37752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37753         LDKUpdateFee orig_conv;
37754         orig_conv.inner = untag_ptr(orig);
37755         orig_conv.is_owned = ptr_is_owned(orig);
37756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37757         orig_conv.is_owned = false;
37758         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
37759         int64_t ret_ref = 0;
37760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37762         return ret_ref;
37763 }
37764
37765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37766         LDKUpdateFee a_conv;
37767         a_conv.inner = untag_ptr(a);
37768         a_conv.is_owned = ptr_is_owned(a);
37769         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37770         a_conv.is_owned = false;
37771         LDKUpdateFee b_conv;
37772         b_conv.inner = untag_ptr(b);
37773         b_conv.is_owned = ptr_is_owned(b);
37774         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37775         b_conv.is_owned = false;
37776         jboolean ret_conv = UpdateFee_eq(&a_conv, &b_conv);
37777         return ret_conv;
37778 }
37779
37780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37781         LDKDataLossProtect this_obj_conv;
37782         this_obj_conv.inner = untag_ptr(this_obj);
37783         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37785         DataLossProtect_free(this_obj_conv);
37786 }
37787
37788 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
37789         LDKDataLossProtect this_ptr_conv;
37790         this_ptr_conv.inner = untag_ptr(this_ptr);
37791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37793         this_ptr_conv.is_owned = false;
37794         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37795         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
37796         return ret_arr;
37797 }
37798
37799 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) {
37800         LDKDataLossProtect this_ptr_conv;
37801         this_ptr_conv.inner = untag_ptr(this_ptr);
37802         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37804         this_ptr_conv.is_owned = false;
37805         LDKThirtyTwoBytes val_ref;
37806         CHECK((*env)->GetArrayLength(env, val) == 32);
37807         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37808         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
37809 }
37810
37811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37812         LDKDataLossProtect this_ptr_conv;
37813         this_ptr_conv.inner = untag_ptr(this_ptr);
37814         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37816         this_ptr_conv.is_owned = false;
37817         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37818         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
37819         return ret_arr;
37820 }
37821
37822 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) {
37823         LDKDataLossProtect this_ptr_conv;
37824         this_ptr_conv.inner = untag_ptr(this_ptr);
37825         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37827         this_ptr_conv.is_owned = false;
37828         LDKPublicKey val_ref;
37829         CHECK((*env)->GetArrayLength(env, val) == 33);
37830         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37831         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
37832 }
37833
37834 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) {
37835         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
37836         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
37837         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
37838         LDKPublicKey my_current_per_commitment_point_arg_ref;
37839         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
37840         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
37841         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
37842         int64_t ret_ref = 0;
37843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37844         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37845         return ret_ref;
37846 }
37847
37848 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
37849         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
37850         int64_t ret_ref = 0;
37851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37852         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37853         return ret_ref;
37854 }
37855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37856         LDKDataLossProtect arg_conv;
37857         arg_conv.inner = untag_ptr(arg);
37858         arg_conv.is_owned = ptr_is_owned(arg);
37859         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37860         arg_conv.is_owned = false;
37861         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
37862         return ret_conv;
37863 }
37864
37865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37866         LDKDataLossProtect orig_conv;
37867         orig_conv.inner = untag_ptr(orig);
37868         orig_conv.is_owned = ptr_is_owned(orig);
37869         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37870         orig_conv.is_owned = false;
37871         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
37872         int64_t ret_ref = 0;
37873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37874         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37875         return ret_ref;
37876 }
37877
37878 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37879         LDKDataLossProtect a_conv;
37880         a_conv.inner = untag_ptr(a);
37881         a_conv.is_owned = ptr_is_owned(a);
37882         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37883         a_conv.is_owned = false;
37884         LDKDataLossProtect b_conv;
37885         b_conv.inner = untag_ptr(b);
37886         b_conv.is_owned = ptr_is_owned(b);
37887         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37888         b_conv.is_owned = false;
37889         jboolean ret_conv = DataLossProtect_eq(&a_conv, &b_conv);
37890         return ret_conv;
37891 }
37892
37893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37894         LDKChannelReestablish this_obj_conv;
37895         this_obj_conv.inner = untag_ptr(this_obj);
37896         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37898         ChannelReestablish_free(this_obj_conv);
37899 }
37900
37901 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37902         LDKChannelReestablish this_ptr_conv;
37903         this_ptr_conv.inner = untag_ptr(this_ptr);
37904         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37906         this_ptr_conv.is_owned = false;
37907         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37908         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
37909         return ret_arr;
37910 }
37911
37912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37913         LDKChannelReestablish this_ptr_conv;
37914         this_ptr_conv.inner = untag_ptr(this_ptr);
37915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37917         this_ptr_conv.is_owned = false;
37918         LDKThirtyTwoBytes val_ref;
37919         CHECK((*env)->GetArrayLength(env, val) == 32);
37920         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37921         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
37922 }
37923
37924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37925         LDKChannelReestablish this_ptr_conv;
37926         this_ptr_conv.inner = untag_ptr(this_ptr);
37927         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37929         this_ptr_conv.is_owned = false;
37930         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
37931         return ret_conv;
37932 }
37933
37934 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) {
37935         LDKChannelReestablish this_ptr_conv;
37936         this_ptr_conv.inner = untag_ptr(this_ptr);
37937         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37939         this_ptr_conv.is_owned = false;
37940         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
37941 }
37942
37943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37944         LDKChannelReestablish this_ptr_conv;
37945         this_ptr_conv.inner = untag_ptr(this_ptr);
37946         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37948         this_ptr_conv.is_owned = false;
37949         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
37950         return ret_conv;
37951 }
37952
37953 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) {
37954         LDKChannelReestablish this_ptr_conv;
37955         this_ptr_conv.inner = untag_ptr(this_ptr);
37956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37958         this_ptr_conv.is_owned = false;
37959         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
37960 }
37961
37962 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
37963         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
37964         int64_t ret_ref = 0;
37965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37967         return ret_ref;
37968 }
37969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37970         LDKChannelReestablish arg_conv;
37971         arg_conv.inner = untag_ptr(arg);
37972         arg_conv.is_owned = ptr_is_owned(arg);
37973         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37974         arg_conv.is_owned = false;
37975         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
37976         return ret_conv;
37977 }
37978
37979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37980         LDKChannelReestablish orig_conv;
37981         orig_conv.inner = untag_ptr(orig);
37982         orig_conv.is_owned = ptr_is_owned(orig);
37983         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37984         orig_conv.is_owned = false;
37985         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
37986         int64_t ret_ref = 0;
37987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37989         return ret_ref;
37990 }
37991
37992 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37993         LDKChannelReestablish a_conv;
37994         a_conv.inner = untag_ptr(a);
37995         a_conv.is_owned = ptr_is_owned(a);
37996         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37997         a_conv.is_owned = false;
37998         LDKChannelReestablish b_conv;
37999         b_conv.inner = untag_ptr(b);
38000         b_conv.is_owned = ptr_is_owned(b);
38001         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38002         b_conv.is_owned = false;
38003         jboolean ret_conv = ChannelReestablish_eq(&a_conv, &b_conv);
38004         return ret_conv;
38005 }
38006
38007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38008         LDKAnnouncementSignatures this_obj_conv;
38009         this_obj_conv.inner = untag_ptr(this_obj);
38010         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38012         AnnouncementSignatures_free(this_obj_conv);
38013 }
38014
38015 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38016         LDKAnnouncementSignatures this_ptr_conv;
38017         this_ptr_conv.inner = untag_ptr(this_ptr);
38018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38020         this_ptr_conv.is_owned = false;
38021         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38022         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
38023         return ret_arr;
38024 }
38025
38026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38027         LDKAnnouncementSignatures this_ptr_conv;
38028         this_ptr_conv.inner = untag_ptr(this_ptr);
38029         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38031         this_ptr_conv.is_owned = false;
38032         LDKThirtyTwoBytes val_ref;
38033         CHECK((*env)->GetArrayLength(env, val) == 32);
38034         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38035         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
38036 }
38037
38038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38039         LDKAnnouncementSignatures this_ptr_conv;
38040         this_ptr_conv.inner = untag_ptr(this_ptr);
38041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38043         this_ptr_conv.is_owned = false;
38044         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
38045         return ret_conv;
38046 }
38047
38048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38049         LDKAnnouncementSignatures this_ptr_conv;
38050         this_ptr_conv.inner = untag_ptr(this_ptr);
38051         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38053         this_ptr_conv.is_owned = false;
38054         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
38055 }
38056
38057 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38058         LDKAnnouncementSignatures this_ptr_conv;
38059         this_ptr_conv.inner = untag_ptr(this_ptr);
38060         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38062         this_ptr_conv.is_owned = false;
38063         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38064         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
38065         return ret_arr;
38066 }
38067
38068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKSignature val_ref;
38075         CHECK((*env)->GetArrayLength(env, val) == 64);
38076         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38077         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
38078 }
38079
38080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38081         LDKAnnouncementSignatures this_ptr_conv;
38082         this_ptr_conv.inner = untag_ptr(this_ptr);
38083         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38085         this_ptr_conv.is_owned = false;
38086         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38087         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
38088         return ret_arr;
38089 }
38090
38091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38092         LDKAnnouncementSignatures this_ptr_conv;
38093         this_ptr_conv.inner = untag_ptr(this_ptr);
38094         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38096         this_ptr_conv.is_owned = false;
38097         LDKSignature val_ref;
38098         CHECK((*env)->GetArrayLength(env, val) == 64);
38099         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38100         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
38101 }
38102
38103 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) {
38104         LDKThirtyTwoBytes channel_id_arg_ref;
38105         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
38106         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
38107         LDKSignature node_signature_arg_ref;
38108         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
38109         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
38110         LDKSignature bitcoin_signature_arg_ref;
38111         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
38112         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
38113         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
38114         int64_t ret_ref = 0;
38115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38116         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38117         return ret_ref;
38118 }
38119
38120 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
38121         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
38122         int64_t ret_ref = 0;
38123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38124         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38125         return ret_ref;
38126 }
38127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38128         LDKAnnouncementSignatures arg_conv;
38129         arg_conv.inner = untag_ptr(arg);
38130         arg_conv.is_owned = ptr_is_owned(arg);
38131         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38132         arg_conv.is_owned = false;
38133         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
38134         return ret_conv;
38135 }
38136
38137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38138         LDKAnnouncementSignatures orig_conv;
38139         orig_conv.inner = untag_ptr(orig);
38140         orig_conv.is_owned = ptr_is_owned(orig);
38141         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38142         orig_conv.is_owned = false;
38143         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
38144         int64_t ret_ref = 0;
38145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38147         return ret_ref;
38148 }
38149
38150 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38151         LDKAnnouncementSignatures a_conv;
38152         a_conv.inner = untag_ptr(a);
38153         a_conv.is_owned = ptr_is_owned(a);
38154         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38155         a_conv.is_owned = false;
38156         LDKAnnouncementSignatures b_conv;
38157         b_conv.inner = untag_ptr(b);
38158         b_conv.is_owned = ptr_is_owned(b);
38159         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38160         b_conv.is_owned = false;
38161         jboolean ret_conv = AnnouncementSignatures_eq(&a_conv, &b_conv);
38162         return ret_conv;
38163 }
38164
38165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38166         if (!ptr_is_owned(this_ptr)) return;
38167         void* this_ptr_ptr = untag_ptr(this_ptr);
38168         CHECK_ACCESS(this_ptr_ptr);
38169         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
38170         FREE(untag_ptr(this_ptr));
38171         NetAddress_free(this_ptr_conv);
38172 }
38173
38174 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
38175         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38176         *ret_copy = NetAddress_clone(arg);
38177         int64_t ret_ref = tag_ptr(ret_copy, true);
38178         return ret_ref;
38179 }
38180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38181         LDKNetAddress* arg_conv = (LDKNetAddress*)untag_ptr(arg);
38182         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
38183         return ret_conv;
38184 }
38185
38186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38187         LDKNetAddress* orig_conv = (LDKNetAddress*)untag_ptr(orig);
38188         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38189         *ret_copy = NetAddress_clone(orig_conv);
38190         int64_t ret_ref = tag_ptr(ret_copy, true);
38191         return ret_ref;
38192 }
38193
38194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
38195         LDKFourBytes addr_ref;
38196         CHECK((*env)->GetArrayLength(env, addr) == 4);
38197         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
38198         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38199         *ret_copy = NetAddress_ipv4(addr_ref, port);
38200         int64_t ret_ref = tag_ptr(ret_copy, true);
38201         return ret_ref;
38202 }
38203
38204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
38205         LDKSixteenBytes addr_ref;
38206         CHECK((*env)->GetArrayLength(env, addr) == 16);
38207         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
38208         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38209         *ret_copy = NetAddress_ipv6(addr_ref, port);
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_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
38215         LDKTwelveBytes a_ref;
38216         CHECK((*env)->GetArrayLength(env, a) == 12);
38217         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
38218         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38219         *ret_copy = NetAddress_onion_v2(a_ref);
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_1onion_1v3(JNIEnv *env, jclass clz, int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
38225         LDKThirtyTwoBytes ed25519_pubkey_ref;
38226         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
38227         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
38228         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38229         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, 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_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
38235         LDKHostname hostname_conv;
38236         hostname_conv.inner = untag_ptr(hostname);
38237         hostname_conv.is_owned = ptr_is_owned(hostname);
38238         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
38239         hostname_conv = Hostname_clone(&hostname_conv);
38240         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38241         *ret_copy = NetAddress_hostname(hostname_conv, port);
38242         int64_t ret_ref = tag_ptr(ret_copy, true);
38243         return ret_ref;
38244 }
38245
38246 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetAddress_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38247         LDKNetAddress* a_conv = (LDKNetAddress*)untag_ptr(a);
38248         LDKNetAddress* b_conv = (LDKNetAddress*)untag_ptr(b);
38249         jboolean ret_conv = NetAddress_eq(a_conv, b_conv);
38250         return ret_conv;
38251 }
38252
38253 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
38254         LDKNetAddress* obj_conv = (LDKNetAddress*)untag_ptr(obj);
38255         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
38256         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38257         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38258         CVec_u8Z_free(ret_var);
38259         return ret_arr;
38260 }
38261
38262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38263         LDKu8slice ser_ref;
38264         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38265         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38266         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
38267         *ret_conv = NetAddress_read(ser_ref);
38268         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38269         return tag_ptr(ret_conv, true);
38270 }
38271
38272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38273         if (!ptr_is_owned(this_ptr)) return;
38274         void* this_ptr_ptr = untag_ptr(this_ptr);
38275         CHECK_ACCESS(this_ptr_ptr);
38276         LDKUnsignedGossipMessage this_ptr_conv = *(LDKUnsignedGossipMessage*)(this_ptr_ptr);
38277         FREE(untag_ptr(this_ptr));
38278         UnsignedGossipMessage_free(this_ptr_conv);
38279 }
38280
38281 static inline uint64_t UnsignedGossipMessage_clone_ptr(LDKUnsignedGossipMessage *NONNULL_PTR arg) {
38282         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38283         *ret_copy = UnsignedGossipMessage_clone(arg);
38284         int64_t ret_ref = tag_ptr(ret_copy, true);
38285         return ret_ref;
38286 }
38287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38288         LDKUnsignedGossipMessage* arg_conv = (LDKUnsignedGossipMessage*)untag_ptr(arg);
38289         int64_t ret_conv = UnsignedGossipMessage_clone_ptr(arg_conv);
38290         return ret_conv;
38291 }
38292
38293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38294         LDKUnsignedGossipMessage* orig_conv = (LDKUnsignedGossipMessage*)untag_ptr(orig);
38295         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38296         *ret_copy = UnsignedGossipMessage_clone(orig_conv);
38297         int64_t ret_ref = tag_ptr(ret_copy, true);
38298         return ret_ref;
38299 }
38300
38301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1channel_1announcement(JNIEnv *env, jclass clz, int64_t a) {
38302         LDKUnsignedChannelAnnouncement a_conv;
38303         a_conv.inner = untag_ptr(a);
38304         a_conv.is_owned = ptr_is_owned(a);
38305         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38306         a_conv = UnsignedChannelAnnouncement_clone(&a_conv);
38307         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38308         *ret_copy = UnsignedGossipMessage_channel_announcement(a_conv);
38309         int64_t ret_ref = tag_ptr(ret_copy, true);
38310         return ret_ref;
38311 }
38312
38313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1channel_1update(JNIEnv *env, jclass clz, int64_t a) {
38314         LDKUnsignedChannelUpdate a_conv;
38315         a_conv.inner = untag_ptr(a);
38316         a_conv.is_owned = ptr_is_owned(a);
38317         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38318         a_conv = UnsignedChannelUpdate_clone(&a_conv);
38319         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38320         *ret_copy = UnsignedGossipMessage_channel_update(a_conv);
38321         int64_t ret_ref = tag_ptr(ret_copy, true);
38322         return ret_ref;
38323 }
38324
38325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1node_1announcement(JNIEnv *env, jclass clz, int64_t a) {
38326         LDKUnsignedNodeAnnouncement a_conv;
38327         a_conv.inner = untag_ptr(a);
38328         a_conv.is_owned = ptr_is_owned(a);
38329         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38330         a_conv = UnsignedNodeAnnouncement_clone(&a_conv);
38331         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
38332         *ret_copy = UnsignedGossipMessage_node_announcement(a_conv);
38333         int64_t ret_ref = tag_ptr(ret_copy, true);
38334         return ret_ref;
38335 }
38336
38337 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedGossipMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
38338         LDKUnsignedGossipMessage* obj_conv = (LDKUnsignedGossipMessage*)untag_ptr(obj);
38339         LDKCVec_u8Z ret_var = UnsignedGossipMessage_write(obj_conv);
38340         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38341         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38342         CVec_u8Z_free(ret_var);
38343         return ret_arr;
38344 }
38345
38346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38347         LDKUnsignedNodeAnnouncement this_obj_conv;
38348         this_obj_conv.inner = untag_ptr(this_obj);
38349         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38351         UnsignedNodeAnnouncement_free(this_obj_conv);
38352 }
38353
38354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
38355         LDKUnsignedNodeAnnouncement this_ptr_conv;
38356         this_ptr_conv.inner = untag_ptr(this_ptr);
38357         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38359         this_ptr_conv.is_owned = false;
38360         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
38361         int64_t ret_ref = 0;
38362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38363         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38364         return ret_ref;
38365 }
38366
38367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38368         LDKUnsignedNodeAnnouncement this_ptr_conv;
38369         this_ptr_conv.inner = untag_ptr(this_ptr);
38370         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38372         this_ptr_conv.is_owned = false;
38373         LDKNodeFeatures val_conv;
38374         val_conv.inner = untag_ptr(val);
38375         val_conv.is_owned = ptr_is_owned(val);
38376         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38377         val_conv = NodeFeatures_clone(&val_conv);
38378         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
38379 }
38380
38381 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
38382         LDKUnsignedNodeAnnouncement this_ptr_conv;
38383         this_ptr_conv.inner = untag_ptr(this_ptr);
38384         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38386         this_ptr_conv.is_owned = false;
38387         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
38388         return ret_conv;
38389 }
38390
38391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38392         LDKUnsignedNodeAnnouncement this_ptr_conv;
38393         this_ptr_conv.inner = untag_ptr(this_ptr);
38394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38396         this_ptr_conv.is_owned = false;
38397         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
38398 }
38399
38400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38401         LDKUnsignedNodeAnnouncement this_ptr_conv;
38402         this_ptr_conv.inner = untag_ptr(this_ptr);
38403         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38405         this_ptr_conv.is_owned = false;
38406         LDKNodeId ret_var = UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv);
38407         int64_t ret_ref = 0;
38408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38409         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38410         return ret_ref;
38411 }
38412
38413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38414         LDKUnsignedNodeAnnouncement this_ptr_conv;
38415         this_ptr_conv.inner = untag_ptr(this_ptr);
38416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38418         this_ptr_conv.is_owned = false;
38419         LDKNodeId val_conv;
38420         val_conv.inner = untag_ptr(val);
38421         val_conv.is_owned = ptr_is_owned(val);
38422         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38423         val_conv = NodeId_clone(&val_conv);
38424         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_conv);
38425 }
38426
38427 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
38428         LDKUnsignedNodeAnnouncement this_ptr_conv;
38429         this_ptr_conv.inner = untag_ptr(this_ptr);
38430         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38432         this_ptr_conv.is_owned = false;
38433         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
38434         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
38435         return ret_arr;
38436 }
38437
38438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38439         LDKUnsignedNodeAnnouncement this_ptr_conv;
38440         this_ptr_conv.inner = untag_ptr(this_ptr);
38441         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38443         this_ptr_conv.is_owned = false;
38444         LDKThreeBytes val_ref;
38445         CHECK((*env)->GetArrayLength(env, val) == 3);
38446         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
38447         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
38448 }
38449
38450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
38451         LDKUnsignedNodeAnnouncement this_ptr_conv;
38452         this_ptr_conv.inner = untag_ptr(this_ptr);
38453         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38455         this_ptr_conv.is_owned = false;
38456         LDKNodeAlias ret_var = UnsignedNodeAnnouncement_get_alias(&this_ptr_conv);
38457         int64_t ret_ref = 0;
38458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38459         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38460         return ret_ref;
38461 }
38462
38463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38464         LDKUnsignedNodeAnnouncement this_ptr_conv;
38465         this_ptr_conv.inner = untag_ptr(this_ptr);
38466         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38468         this_ptr_conv.is_owned = false;
38469         LDKNodeAlias val_conv;
38470         val_conv.inner = untag_ptr(val);
38471         val_conv.is_owned = ptr_is_owned(val);
38472         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38473         val_conv = NodeAlias_clone(&val_conv);
38474         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_conv);
38475 }
38476
38477 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
38478         LDKUnsignedNodeAnnouncement this_ptr_conv;
38479         this_ptr_conv.inner = untag_ptr(this_ptr);
38480         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38482         this_ptr_conv.is_owned = false;
38483         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
38484         int64_tArray ret_arr = NULL;
38485         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38486         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38487         for (size_t m = 0; m < ret_var.datalen; m++) {
38488                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
38489                 *ret_conv_12_copy = ret_var.data[m];
38490                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
38491                 ret_arr_ptr[m] = ret_conv_12_ref;
38492         }
38493         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38494         FREE(ret_var.data);
38495         return ret_arr;
38496 }
38497
38498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38499         LDKUnsignedNodeAnnouncement this_ptr_conv;
38500         this_ptr_conv.inner = untag_ptr(this_ptr);
38501         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38503         this_ptr_conv.is_owned = false;
38504         LDKCVec_NetAddressZ val_constr;
38505         val_constr.datalen = (*env)->GetArrayLength(env, val);
38506         if (val_constr.datalen > 0)
38507                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
38508         else
38509                 val_constr.data = NULL;
38510         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38511         for (size_t m = 0; m < val_constr.datalen; m++) {
38512                 int64_t val_conv_12 = val_vals[m];
38513                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
38514                 CHECK_ACCESS(val_conv_12_ptr);
38515                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
38516                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
38517                 val_constr.data[m] = val_conv_12_conv;
38518         }
38519         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38520         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
38521 }
38522
38523 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
38524         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
38525         int64_t ret_ref = 0;
38526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38527         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38528         return ret_ref;
38529 }
38530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38531         LDKUnsignedNodeAnnouncement arg_conv;
38532         arg_conv.inner = untag_ptr(arg);
38533         arg_conv.is_owned = ptr_is_owned(arg);
38534         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38535         arg_conv.is_owned = false;
38536         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
38537         return ret_conv;
38538 }
38539
38540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38541         LDKUnsignedNodeAnnouncement orig_conv;
38542         orig_conv.inner = untag_ptr(orig);
38543         orig_conv.is_owned = ptr_is_owned(orig);
38544         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38545         orig_conv.is_owned = false;
38546         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
38547         int64_t ret_ref = 0;
38548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38549         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38550         return ret_ref;
38551 }
38552
38553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38554         LDKUnsignedNodeAnnouncement a_conv;
38555         a_conv.inner = untag_ptr(a);
38556         a_conv.is_owned = ptr_is_owned(a);
38557         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38558         a_conv.is_owned = false;
38559         LDKUnsignedNodeAnnouncement b_conv;
38560         b_conv.inner = untag_ptr(b);
38561         b_conv.is_owned = ptr_is_owned(b);
38562         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38563         b_conv.is_owned = false;
38564         jboolean ret_conv = UnsignedNodeAnnouncement_eq(&a_conv, &b_conv);
38565         return ret_conv;
38566 }
38567
38568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38569         LDKNodeAnnouncement this_obj_conv;
38570         this_obj_conv.inner = untag_ptr(this_obj);
38571         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38573         NodeAnnouncement_free(this_obj_conv);
38574 }
38575
38576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38577         LDKNodeAnnouncement this_ptr_conv;
38578         this_ptr_conv.inner = untag_ptr(this_ptr);
38579         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38581         this_ptr_conv.is_owned = false;
38582         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38583         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
38584         return ret_arr;
38585 }
38586
38587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38588         LDKNodeAnnouncement this_ptr_conv;
38589         this_ptr_conv.inner = untag_ptr(this_ptr);
38590         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38592         this_ptr_conv.is_owned = false;
38593         LDKSignature val_ref;
38594         CHECK((*env)->GetArrayLength(env, val) == 64);
38595         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38596         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
38597 }
38598
38599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
38600         LDKNodeAnnouncement this_ptr_conv;
38601         this_ptr_conv.inner = untag_ptr(this_ptr);
38602         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38604         this_ptr_conv.is_owned = false;
38605         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
38606         int64_t ret_ref = 0;
38607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38608         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38609         return ret_ref;
38610 }
38611
38612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38613         LDKNodeAnnouncement this_ptr_conv;
38614         this_ptr_conv.inner = untag_ptr(this_ptr);
38615         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38617         this_ptr_conv.is_owned = false;
38618         LDKUnsignedNodeAnnouncement val_conv;
38619         val_conv.inner = untag_ptr(val);
38620         val_conv.is_owned = ptr_is_owned(val);
38621         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38622         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
38623         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
38624 }
38625
38626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
38627         LDKSignature signature_arg_ref;
38628         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
38629         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
38630         LDKUnsignedNodeAnnouncement contents_arg_conv;
38631         contents_arg_conv.inner = untag_ptr(contents_arg);
38632         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
38633         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
38634         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
38635         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
38636         int64_t ret_ref = 0;
38637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38638         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38639         return ret_ref;
38640 }
38641
38642 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
38643         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
38644         int64_t ret_ref = 0;
38645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38646         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38647         return ret_ref;
38648 }
38649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38650         LDKNodeAnnouncement arg_conv;
38651         arg_conv.inner = untag_ptr(arg);
38652         arg_conv.is_owned = ptr_is_owned(arg);
38653         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38654         arg_conv.is_owned = false;
38655         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
38656         return ret_conv;
38657 }
38658
38659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38660         LDKNodeAnnouncement orig_conv;
38661         orig_conv.inner = untag_ptr(orig);
38662         orig_conv.is_owned = ptr_is_owned(orig);
38663         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38664         orig_conv.is_owned = false;
38665         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
38666         int64_t ret_ref = 0;
38667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38668         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38669         return ret_ref;
38670 }
38671
38672 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38673         LDKNodeAnnouncement a_conv;
38674         a_conv.inner = untag_ptr(a);
38675         a_conv.is_owned = ptr_is_owned(a);
38676         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38677         a_conv.is_owned = false;
38678         LDKNodeAnnouncement b_conv;
38679         b_conv.inner = untag_ptr(b);
38680         b_conv.is_owned = ptr_is_owned(b);
38681         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38682         b_conv.is_owned = false;
38683         jboolean ret_conv = NodeAnnouncement_eq(&a_conv, &b_conv);
38684         return ret_conv;
38685 }
38686
38687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38688         LDKUnsignedChannelAnnouncement this_obj_conv;
38689         this_obj_conv.inner = untag_ptr(this_obj);
38690         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38692         UnsignedChannelAnnouncement_free(this_obj_conv);
38693 }
38694
38695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
38696         LDKUnsignedChannelAnnouncement this_ptr_conv;
38697         this_ptr_conv.inner = untag_ptr(this_ptr);
38698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38700         this_ptr_conv.is_owned = false;
38701         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
38702         int64_t ret_ref = 0;
38703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38704         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38705         return ret_ref;
38706 }
38707
38708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38709         LDKUnsignedChannelAnnouncement this_ptr_conv;
38710         this_ptr_conv.inner = untag_ptr(this_ptr);
38711         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38713         this_ptr_conv.is_owned = false;
38714         LDKChannelFeatures val_conv;
38715         val_conv.inner = untag_ptr(val);
38716         val_conv.is_owned = ptr_is_owned(val);
38717         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38718         val_conv = ChannelFeatures_clone(&val_conv);
38719         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
38720 }
38721
38722 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38723         LDKUnsignedChannelAnnouncement this_ptr_conv;
38724         this_ptr_conv.inner = untag_ptr(this_ptr);
38725         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38727         this_ptr_conv.is_owned = false;
38728         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38729         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
38730         return ret_arr;
38731 }
38732
38733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38734         LDKUnsignedChannelAnnouncement this_ptr_conv;
38735         this_ptr_conv.inner = untag_ptr(this_ptr);
38736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38738         this_ptr_conv.is_owned = false;
38739         LDKThirtyTwoBytes val_ref;
38740         CHECK((*env)->GetArrayLength(env, val) == 32);
38741         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38742         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
38743 }
38744
38745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38746         LDKUnsignedChannelAnnouncement this_ptr_conv;
38747         this_ptr_conv.inner = untag_ptr(this_ptr);
38748         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38750         this_ptr_conv.is_owned = false;
38751         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
38752         return ret_conv;
38753 }
38754
38755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38756         LDKUnsignedChannelAnnouncement this_ptr_conv;
38757         this_ptr_conv.inner = untag_ptr(this_ptr);
38758         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38760         this_ptr_conv.is_owned = false;
38761         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
38762 }
38763
38764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38765         LDKUnsignedChannelAnnouncement this_ptr_conv;
38766         this_ptr_conv.inner = untag_ptr(this_ptr);
38767         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38769         this_ptr_conv.is_owned = false;
38770         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv);
38771         int64_t ret_ref = 0;
38772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38773         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38774         return ret_ref;
38775 }
38776
38777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38778         LDKUnsignedChannelAnnouncement this_ptr_conv;
38779         this_ptr_conv.inner = untag_ptr(this_ptr);
38780         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38782         this_ptr_conv.is_owned = false;
38783         LDKNodeId val_conv;
38784         val_conv.inner = untag_ptr(val);
38785         val_conv.is_owned = ptr_is_owned(val);
38786         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38787         val_conv = NodeId_clone(&val_conv);
38788         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_conv);
38789 }
38790
38791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38792         LDKUnsignedChannelAnnouncement this_ptr_conv;
38793         this_ptr_conv.inner = untag_ptr(this_ptr);
38794         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38796         this_ptr_conv.is_owned = false;
38797         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv);
38798         int64_t ret_ref = 0;
38799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38800         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38801         return ret_ref;
38802 }
38803
38804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38805         LDKUnsignedChannelAnnouncement this_ptr_conv;
38806         this_ptr_conv.inner = untag_ptr(this_ptr);
38807         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38809         this_ptr_conv.is_owned = false;
38810         LDKNodeId val_conv;
38811         val_conv.inner = untag_ptr(val);
38812         val_conv.is_owned = ptr_is_owned(val);
38813         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38814         val_conv = NodeId_clone(&val_conv);
38815         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_conv);
38816 }
38817
38818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38819         LDKUnsignedChannelAnnouncement this_ptr_conv;
38820         this_ptr_conv.inner = untag_ptr(this_ptr);
38821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38823         this_ptr_conv.is_owned = false;
38824         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv);
38825         int64_t ret_ref = 0;
38826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38827         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38828         return ret_ref;
38829 }
38830
38831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38832         LDKUnsignedChannelAnnouncement this_ptr_conv;
38833         this_ptr_conv.inner = untag_ptr(this_ptr);
38834         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38836         this_ptr_conv.is_owned = false;
38837         LDKNodeId val_conv;
38838         val_conv.inner = untag_ptr(val);
38839         val_conv.is_owned = ptr_is_owned(val);
38840         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38841         val_conv = NodeId_clone(&val_conv);
38842         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_conv);
38843 }
38844
38845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38846         LDKUnsignedChannelAnnouncement this_ptr_conv;
38847         this_ptr_conv.inner = untag_ptr(this_ptr);
38848         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38850         this_ptr_conv.is_owned = false;
38851         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv);
38852         int64_t ret_ref = 0;
38853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38854         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38855         return ret_ref;
38856 }
38857
38858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38859         LDKUnsignedChannelAnnouncement this_ptr_conv;
38860         this_ptr_conv.inner = untag_ptr(this_ptr);
38861         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38863         this_ptr_conv.is_owned = false;
38864         LDKNodeId val_conv;
38865         val_conv.inner = untag_ptr(val);
38866         val_conv.is_owned = ptr_is_owned(val);
38867         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38868         val_conv = NodeId_clone(&val_conv);
38869         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_conv);
38870 }
38871
38872 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
38873         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
38874         int64_t ret_ref = 0;
38875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38876         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38877         return ret_ref;
38878 }
38879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38880         LDKUnsignedChannelAnnouncement arg_conv;
38881         arg_conv.inner = untag_ptr(arg);
38882         arg_conv.is_owned = ptr_is_owned(arg);
38883         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38884         arg_conv.is_owned = false;
38885         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
38886         return ret_conv;
38887 }
38888
38889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38890         LDKUnsignedChannelAnnouncement orig_conv;
38891         orig_conv.inner = untag_ptr(orig);
38892         orig_conv.is_owned = ptr_is_owned(orig);
38893         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38894         orig_conv.is_owned = false;
38895         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
38896         int64_t ret_ref = 0;
38897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38899         return ret_ref;
38900 }
38901
38902 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38903         LDKUnsignedChannelAnnouncement a_conv;
38904         a_conv.inner = untag_ptr(a);
38905         a_conv.is_owned = ptr_is_owned(a);
38906         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38907         a_conv.is_owned = false;
38908         LDKUnsignedChannelAnnouncement b_conv;
38909         b_conv.inner = untag_ptr(b);
38910         b_conv.is_owned = ptr_is_owned(b);
38911         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38912         b_conv.is_owned = false;
38913         jboolean ret_conv = UnsignedChannelAnnouncement_eq(&a_conv, &b_conv);
38914         return ret_conv;
38915 }
38916
38917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38918         LDKChannelAnnouncement this_obj_conv;
38919         this_obj_conv.inner = untag_ptr(this_obj);
38920         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38922         ChannelAnnouncement_free(this_obj_conv);
38923 }
38924
38925 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38926         LDKChannelAnnouncement this_ptr_conv;
38927         this_ptr_conv.inner = untag_ptr(this_ptr);
38928         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38930         this_ptr_conv.is_owned = false;
38931         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38932         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
38933         return ret_arr;
38934 }
38935
38936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38937         LDKChannelAnnouncement this_ptr_conv;
38938         this_ptr_conv.inner = untag_ptr(this_ptr);
38939         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38941         this_ptr_conv.is_owned = false;
38942         LDKSignature val_ref;
38943         CHECK((*env)->GetArrayLength(env, val) == 64);
38944         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38945         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
38946 }
38947
38948 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38949         LDKChannelAnnouncement this_ptr_conv;
38950         this_ptr_conv.inner = untag_ptr(this_ptr);
38951         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38953         this_ptr_conv.is_owned = false;
38954         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38955         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
38956         return ret_arr;
38957 }
38958
38959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38960         LDKChannelAnnouncement this_ptr_conv;
38961         this_ptr_conv.inner = untag_ptr(this_ptr);
38962         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38964         this_ptr_conv.is_owned = false;
38965         LDKSignature val_ref;
38966         CHECK((*env)->GetArrayLength(env, val) == 64);
38967         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38968         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
38969 }
38970
38971 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38972         LDKChannelAnnouncement this_ptr_conv;
38973         this_ptr_conv.inner = untag_ptr(this_ptr);
38974         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38976         this_ptr_conv.is_owned = false;
38977         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38978         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
38979         return ret_arr;
38980 }
38981
38982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38983         LDKChannelAnnouncement this_ptr_conv;
38984         this_ptr_conv.inner = untag_ptr(this_ptr);
38985         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38987         this_ptr_conv.is_owned = false;
38988         LDKSignature val_ref;
38989         CHECK((*env)->GetArrayLength(env, val) == 64);
38990         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38991         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
38992 }
38993
38994 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38995         LDKChannelAnnouncement this_ptr_conv;
38996         this_ptr_conv.inner = untag_ptr(this_ptr);
38997         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38999         this_ptr_conv.is_owned = false;
39000         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39001         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
39002         return ret_arr;
39003 }
39004
39005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39006         LDKChannelAnnouncement this_ptr_conv;
39007         this_ptr_conv.inner = untag_ptr(this_ptr);
39008         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39010         this_ptr_conv.is_owned = false;
39011         LDKSignature val_ref;
39012         CHECK((*env)->GetArrayLength(env, val) == 64);
39013         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
39014         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
39015 }
39016
39017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
39018         LDKChannelAnnouncement this_ptr_conv;
39019         this_ptr_conv.inner = untag_ptr(this_ptr);
39020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39022         this_ptr_conv.is_owned = false;
39023         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
39024         int64_t ret_ref = 0;
39025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39026         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39027         return ret_ref;
39028 }
39029
39030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39031         LDKChannelAnnouncement this_ptr_conv;
39032         this_ptr_conv.inner = untag_ptr(this_ptr);
39033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39035         this_ptr_conv.is_owned = false;
39036         LDKUnsignedChannelAnnouncement val_conv;
39037         val_conv.inner = untag_ptr(val);
39038         val_conv.is_owned = ptr_is_owned(val);
39039         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39040         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
39041         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
39042 }
39043
39044 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) {
39045         LDKSignature node_signature_1_arg_ref;
39046         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
39047         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
39048         LDKSignature node_signature_2_arg_ref;
39049         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
39050         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
39051         LDKSignature bitcoin_signature_1_arg_ref;
39052         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
39053         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
39054         LDKSignature bitcoin_signature_2_arg_ref;
39055         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
39056         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
39057         LDKUnsignedChannelAnnouncement contents_arg_conv;
39058         contents_arg_conv.inner = untag_ptr(contents_arg);
39059         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
39060         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
39061         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
39062         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);
39063         int64_t ret_ref = 0;
39064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39065         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39066         return ret_ref;
39067 }
39068
39069 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
39070         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
39071         int64_t ret_ref = 0;
39072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39073         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39074         return ret_ref;
39075 }
39076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39077         LDKChannelAnnouncement arg_conv;
39078         arg_conv.inner = untag_ptr(arg);
39079         arg_conv.is_owned = ptr_is_owned(arg);
39080         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39081         arg_conv.is_owned = false;
39082         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
39083         return ret_conv;
39084 }
39085
39086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39087         LDKChannelAnnouncement orig_conv;
39088         orig_conv.inner = untag_ptr(orig);
39089         orig_conv.is_owned = ptr_is_owned(orig);
39090         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39091         orig_conv.is_owned = false;
39092         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
39093         int64_t ret_ref = 0;
39094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39095         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39096         return ret_ref;
39097 }
39098
39099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39100         LDKChannelAnnouncement a_conv;
39101         a_conv.inner = untag_ptr(a);
39102         a_conv.is_owned = ptr_is_owned(a);
39103         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39104         a_conv.is_owned = false;
39105         LDKChannelAnnouncement b_conv;
39106         b_conv.inner = untag_ptr(b);
39107         b_conv.is_owned = ptr_is_owned(b);
39108         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39109         b_conv.is_owned = false;
39110         jboolean ret_conv = ChannelAnnouncement_eq(&a_conv, &b_conv);
39111         return ret_conv;
39112 }
39113
39114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39115         LDKUnsignedChannelUpdate this_obj_conv;
39116         this_obj_conv.inner = untag_ptr(this_obj);
39117         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39119         UnsignedChannelUpdate_free(this_obj_conv);
39120 }
39121
39122 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39123         LDKUnsignedChannelUpdate this_ptr_conv;
39124         this_ptr_conv.inner = untag_ptr(this_ptr);
39125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39127         this_ptr_conv.is_owned = false;
39128         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39129         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
39130         return ret_arr;
39131 }
39132
39133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39134         LDKUnsignedChannelUpdate this_ptr_conv;
39135         this_ptr_conv.inner = untag_ptr(this_ptr);
39136         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39138         this_ptr_conv.is_owned = false;
39139         LDKThirtyTwoBytes val_ref;
39140         CHECK((*env)->GetArrayLength(env, val) == 32);
39141         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39142         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
39143 }
39144
39145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
39146         LDKUnsignedChannelUpdate this_ptr_conv;
39147         this_ptr_conv.inner = untag_ptr(this_ptr);
39148         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39150         this_ptr_conv.is_owned = false;
39151         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
39152         return ret_conv;
39153 }
39154
39155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39156         LDKUnsignedChannelUpdate this_ptr_conv;
39157         this_ptr_conv.inner = untag_ptr(this_ptr);
39158         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39160         this_ptr_conv.is_owned = false;
39161         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
39162 }
39163
39164 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
39165         LDKUnsignedChannelUpdate this_ptr_conv;
39166         this_ptr_conv.inner = untag_ptr(this_ptr);
39167         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39169         this_ptr_conv.is_owned = false;
39170         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
39171         return ret_conv;
39172 }
39173
39174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39175         LDKUnsignedChannelUpdate this_ptr_conv;
39176         this_ptr_conv.inner = untag_ptr(this_ptr);
39177         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39179         this_ptr_conv.is_owned = false;
39180         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
39181 }
39182
39183 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
39184         LDKUnsignedChannelUpdate this_ptr_conv;
39185         this_ptr_conv.inner = untag_ptr(this_ptr);
39186         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39188         this_ptr_conv.is_owned = false;
39189         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
39190         return ret_conv;
39191 }
39192
39193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
39194         LDKUnsignedChannelUpdate this_ptr_conv;
39195         this_ptr_conv.inner = untag_ptr(this_ptr);
39196         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39198         this_ptr_conv.is_owned = false;
39199         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
39200 }
39201
39202 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
39203         LDKUnsignedChannelUpdate this_ptr_conv;
39204         this_ptr_conv.inner = untag_ptr(this_ptr);
39205         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39207         this_ptr_conv.is_owned = false;
39208         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
39209         return ret_conv;
39210 }
39211
39212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39213         LDKUnsignedChannelUpdate this_ptr_conv;
39214         this_ptr_conv.inner = untag_ptr(this_ptr);
39215         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39217         this_ptr_conv.is_owned = false;
39218         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
39219 }
39220
39221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39222         LDKUnsignedChannelUpdate this_ptr_conv;
39223         this_ptr_conv.inner = untag_ptr(this_ptr);
39224         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39226         this_ptr_conv.is_owned = false;
39227         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
39228         return ret_conv;
39229 }
39230
39231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39232         LDKUnsignedChannelUpdate this_ptr_conv;
39233         this_ptr_conv.inner = untag_ptr(this_ptr);
39234         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39236         this_ptr_conv.is_owned = false;
39237         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
39238 }
39239
39240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39241         LDKUnsignedChannelUpdate this_ptr_conv;
39242         this_ptr_conv.inner = untag_ptr(this_ptr);
39243         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39245         this_ptr_conv.is_owned = false;
39246         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
39247         return ret_conv;
39248 }
39249
39250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39251         LDKUnsignedChannelUpdate this_ptr_conv;
39252         this_ptr_conv.inner = untag_ptr(this_ptr);
39253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39255         this_ptr_conv.is_owned = false;
39256         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
39257 }
39258
39259 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39260         LDKUnsignedChannelUpdate this_ptr_conv;
39261         this_ptr_conv.inner = untag_ptr(this_ptr);
39262         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39264         this_ptr_conv.is_owned = false;
39265         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
39266         return ret_conv;
39267 }
39268
39269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39270         LDKUnsignedChannelUpdate this_ptr_conv;
39271         this_ptr_conv.inner = untag_ptr(this_ptr);
39272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39274         this_ptr_conv.is_owned = false;
39275         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
39276 }
39277
39278 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
39279         LDKUnsignedChannelUpdate this_ptr_conv;
39280         this_ptr_conv.inner = untag_ptr(this_ptr);
39281         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39283         this_ptr_conv.is_owned = false;
39284         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
39285         return ret_conv;
39286 }
39287
39288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39289         LDKUnsignedChannelUpdate this_ptr_conv;
39290         this_ptr_conv.inner = untag_ptr(this_ptr);
39291         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39293         this_ptr_conv.is_owned = false;
39294         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
39295 }
39296
39297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
39298         LDKUnsignedChannelUpdate this_ptr_conv;
39299         this_ptr_conv.inner = untag_ptr(this_ptr);
39300         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39302         this_ptr_conv.is_owned = false;
39303         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
39304         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39305         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39306         CVec_u8Z_free(ret_var);
39307         return ret_arr;
39308 }
39309
39310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39311         LDKUnsignedChannelUpdate this_ptr_conv;
39312         this_ptr_conv.inner = untag_ptr(this_ptr);
39313         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39315         this_ptr_conv.is_owned = false;
39316         LDKCVec_u8Z val_ref;
39317         val_ref.datalen = (*env)->GetArrayLength(env, val);
39318         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
39319         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
39320         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
39321 }
39322
39323 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) {
39324         LDKThirtyTwoBytes chain_hash_arg_ref;
39325         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39326         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39327         LDKCVec_u8Z excess_data_arg_ref;
39328         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
39329         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
39330         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
39331         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);
39332         int64_t ret_ref = 0;
39333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39334         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39335         return ret_ref;
39336 }
39337
39338 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
39339         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
39340         int64_t ret_ref = 0;
39341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39342         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39343         return ret_ref;
39344 }
39345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39346         LDKUnsignedChannelUpdate arg_conv;
39347         arg_conv.inner = untag_ptr(arg);
39348         arg_conv.is_owned = ptr_is_owned(arg);
39349         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39350         arg_conv.is_owned = false;
39351         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
39352         return ret_conv;
39353 }
39354
39355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39356         LDKUnsignedChannelUpdate orig_conv;
39357         orig_conv.inner = untag_ptr(orig);
39358         orig_conv.is_owned = ptr_is_owned(orig);
39359         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39360         orig_conv.is_owned = false;
39361         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
39362         int64_t ret_ref = 0;
39363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39364         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39365         return ret_ref;
39366 }
39367
39368 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39369         LDKUnsignedChannelUpdate a_conv;
39370         a_conv.inner = untag_ptr(a);
39371         a_conv.is_owned = ptr_is_owned(a);
39372         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39373         a_conv.is_owned = false;
39374         LDKUnsignedChannelUpdate b_conv;
39375         b_conv.inner = untag_ptr(b);
39376         b_conv.is_owned = ptr_is_owned(b);
39377         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39378         b_conv.is_owned = false;
39379         jboolean ret_conv = UnsignedChannelUpdate_eq(&a_conv, &b_conv);
39380         return ret_conv;
39381 }
39382
39383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39384         LDKChannelUpdate this_obj_conv;
39385         this_obj_conv.inner = untag_ptr(this_obj);
39386         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39388         ChannelUpdate_free(this_obj_conv);
39389 }
39390
39391 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
39392         LDKChannelUpdate this_ptr_conv;
39393         this_ptr_conv.inner = untag_ptr(this_ptr);
39394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39396         this_ptr_conv.is_owned = false;
39397         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39398         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
39399         return ret_arr;
39400 }
39401
39402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39403         LDKChannelUpdate this_ptr_conv;
39404         this_ptr_conv.inner = untag_ptr(this_ptr);
39405         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39407         this_ptr_conv.is_owned = false;
39408         LDKSignature val_ref;
39409         CHECK((*env)->GetArrayLength(env, val) == 64);
39410         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
39411         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
39412 }
39413
39414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
39415         LDKChannelUpdate this_ptr_conv;
39416         this_ptr_conv.inner = untag_ptr(this_ptr);
39417         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39419         this_ptr_conv.is_owned = false;
39420         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
39421         int64_t ret_ref = 0;
39422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39423         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39424         return ret_ref;
39425 }
39426
39427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39428         LDKChannelUpdate this_ptr_conv;
39429         this_ptr_conv.inner = untag_ptr(this_ptr);
39430         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39432         this_ptr_conv.is_owned = false;
39433         LDKUnsignedChannelUpdate val_conv;
39434         val_conv.inner = untag_ptr(val);
39435         val_conv.is_owned = ptr_is_owned(val);
39436         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39437         val_conv = UnsignedChannelUpdate_clone(&val_conv);
39438         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
39439 }
39440
39441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
39442         LDKSignature signature_arg_ref;
39443         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
39444         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
39445         LDKUnsignedChannelUpdate contents_arg_conv;
39446         contents_arg_conv.inner = untag_ptr(contents_arg);
39447         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
39448         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
39449         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
39450         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
39451         int64_t ret_ref = 0;
39452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39453         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39454         return ret_ref;
39455 }
39456
39457 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
39458         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
39459         int64_t ret_ref = 0;
39460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39461         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39462         return ret_ref;
39463 }
39464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39465         LDKChannelUpdate arg_conv;
39466         arg_conv.inner = untag_ptr(arg);
39467         arg_conv.is_owned = ptr_is_owned(arg);
39468         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39469         arg_conv.is_owned = false;
39470         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
39471         return ret_conv;
39472 }
39473
39474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39475         LDKChannelUpdate orig_conv;
39476         orig_conv.inner = untag_ptr(orig);
39477         orig_conv.is_owned = ptr_is_owned(orig);
39478         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39479         orig_conv.is_owned = false;
39480         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
39481         int64_t ret_ref = 0;
39482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39483         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39484         return ret_ref;
39485 }
39486
39487 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39488         LDKChannelUpdate a_conv;
39489         a_conv.inner = untag_ptr(a);
39490         a_conv.is_owned = ptr_is_owned(a);
39491         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39492         a_conv.is_owned = false;
39493         LDKChannelUpdate b_conv;
39494         b_conv.inner = untag_ptr(b);
39495         b_conv.is_owned = ptr_is_owned(b);
39496         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39497         b_conv.is_owned = false;
39498         jboolean ret_conv = ChannelUpdate_eq(&a_conv, &b_conv);
39499         return ret_conv;
39500 }
39501
39502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39503         LDKQueryChannelRange this_obj_conv;
39504         this_obj_conv.inner = untag_ptr(this_obj);
39505         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39507         QueryChannelRange_free(this_obj_conv);
39508 }
39509
39510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39511         LDKQueryChannelRange this_ptr_conv;
39512         this_ptr_conv.inner = untag_ptr(this_ptr);
39513         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39515         this_ptr_conv.is_owned = false;
39516         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39517         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
39518         return ret_arr;
39519 }
39520
39521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39522         LDKQueryChannelRange this_ptr_conv;
39523         this_ptr_conv.inner = untag_ptr(this_ptr);
39524         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39526         this_ptr_conv.is_owned = false;
39527         LDKThirtyTwoBytes val_ref;
39528         CHECK((*env)->GetArrayLength(env, val) == 32);
39529         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39530         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
39531 }
39532
39533 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
39534         LDKQueryChannelRange this_ptr_conv;
39535         this_ptr_conv.inner = untag_ptr(this_ptr);
39536         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39538         this_ptr_conv.is_owned = false;
39539         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
39540         return ret_conv;
39541 }
39542
39543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39544         LDKQueryChannelRange this_ptr_conv;
39545         this_ptr_conv.inner = untag_ptr(this_ptr);
39546         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39548         this_ptr_conv.is_owned = false;
39549         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
39550 }
39551
39552 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
39553         LDKQueryChannelRange this_ptr_conv;
39554         this_ptr_conv.inner = untag_ptr(this_ptr);
39555         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39557         this_ptr_conv.is_owned = false;
39558         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
39559         return ret_conv;
39560 }
39561
39562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39563         LDKQueryChannelRange this_ptr_conv;
39564         this_ptr_conv.inner = untag_ptr(this_ptr);
39565         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39567         this_ptr_conv.is_owned = false;
39568         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
39569 }
39570
39571 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) {
39572         LDKThirtyTwoBytes chain_hash_arg_ref;
39573         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39574         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39575         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
39576         int64_t ret_ref = 0;
39577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39578         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39579         return ret_ref;
39580 }
39581
39582 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
39583         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
39584         int64_t ret_ref = 0;
39585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39586         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39587         return ret_ref;
39588 }
39589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39590         LDKQueryChannelRange arg_conv;
39591         arg_conv.inner = untag_ptr(arg);
39592         arg_conv.is_owned = ptr_is_owned(arg);
39593         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39594         arg_conv.is_owned = false;
39595         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
39596         return ret_conv;
39597 }
39598
39599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39600         LDKQueryChannelRange orig_conv;
39601         orig_conv.inner = untag_ptr(orig);
39602         orig_conv.is_owned = ptr_is_owned(orig);
39603         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39604         orig_conv.is_owned = false;
39605         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
39606         int64_t ret_ref = 0;
39607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39608         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39609         return ret_ref;
39610 }
39611
39612 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39613         LDKQueryChannelRange a_conv;
39614         a_conv.inner = untag_ptr(a);
39615         a_conv.is_owned = ptr_is_owned(a);
39616         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39617         a_conv.is_owned = false;
39618         LDKQueryChannelRange b_conv;
39619         b_conv.inner = untag_ptr(b);
39620         b_conv.is_owned = ptr_is_owned(b);
39621         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39622         b_conv.is_owned = false;
39623         jboolean ret_conv = QueryChannelRange_eq(&a_conv, &b_conv);
39624         return ret_conv;
39625 }
39626
39627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39628         LDKReplyChannelRange this_obj_conv;
39629         this_obj_conv.inner = untag_ptr(this_obj);
39630         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39632         ReplyChannelRange_free(this_obj_conv);
39633 }
39634
39635 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39636         LDKReplyChannelRange this_ptr_conv;
39637         this_ptr_conv.inner = untag_ptr(this_ptr);
39638         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39640         this_ptr_conv.is_owned = false;
39641         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39642         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
39643         return ret_arr;
39644 }
39645
39646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39647         LDKReplyChannelRange this_ptr_conv;
39648         this_ptr_conv.inner = untag_ptr(this_ptr);
39649         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39651         this_ptr_conv.is_owned = false;
39652         LDKThirtyTwoBytes val_ref;
39653         CHECK((*env)->GetArrayLength(env, val) == 32);
39654         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39655         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
39656 }
39657
39658 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
39659         LDKReplyChannelRange this_ptr_conv;
39660         this_ptr_conv.inner = untag_ptr(this_ptr);
39661         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39663         this_ptr_conv.is_owned = false;
39664         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
39665         return ret_conv;
39666 }
39667
39668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39669         LDKReplyChannelRange this_ptr_conv;
39670         this_ptr_conv.inner = untag_ptr(this_ptr);
39671         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39673         this_ptr_conv.is_owned = false;
39674         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
39675 }
39676
39677 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
39678         LDKReplyChannelRange this_ptr_conv;
39679         this_ptr_conv.inner = untag_ptr(this_ptr);
39680         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39682         this_ptr_conv.is_owned = false;
39683         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
39684         return ret_conv;
39685 }
39686
39687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39688         LDKReplyChannelRange this_ptr_conv;
39689         this_ptr_conv.inner = untag_ptr(this_ptr);
39690         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39692         this_ptr_conv.is_owned = false;
39693         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
39694 }
39695
39696 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
39697         LDKReplyChannelRange this_ptr_conv;
39698         this_ptr_conv.inner = untag_ptr(this_ptr);
39699         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39701         this_ptr_conv.is_owned = false;
39702         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
39703         return ret_conv;
39704 }
39705
39706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39707         LDKReplyChannelRange this_ptr_conv;
39708         this_ptr_conv.inner = untag_ptr(this_ptr);
39709         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39711         this_ptr_conv.is_owned = false;
39712         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
39713 }
39714
39715 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
39716         LDKReplyChannelRange this_ptr_conv;
39717         this_ptr_conv.inner = untag_ptr(this_ptr);
39718         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39720         this_ptr_conv.is_owned = false;
39721         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
39722         int64_tArray ret_arr = NULL;
39723         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39724         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39725         for (size_t g = 0; g < ret_var.datalen; g++) {
39726                 int64_t ret_conv_6_conv = ret_var.data[g];
39727                 ret_arr_ptr[g] = ret_conv_6_conv;
39728         }
39729         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39730         FREE(ret_var.data);
39731         return ret_arr;
39732 }
39733
39734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39735         LDKReplyChannelRange this_ptr_conv;
39736         this_ptr_conv.inner = untag_ptr(this_ptr);
39737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39739         this_ptr_conv.is_owned = false;
39740         LDKCVec_u64Z val_constr;
39741         val_constr.datalen = (*env)->GetArrayLength(env, val);
39742         if (val_constr.datalen > 0)
39743                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39744         else
39745                 val_constr.data = NULL;
39746         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39747         for (size_t g = 0; g < val_constr.datalen; g++) {
39748                 int64_t val_conv_6 = val_vals[g];
39749                 val_constr.data[g] = val_conv_6;
39750         }
39751         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39752         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
39753 }
39754
39755 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) {
39756         LDKThirtyTwoBytes chain_hash_arg_ref;
39757         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39758         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39759         LDKCVec_u64Z short_channel_ids_arg_constr;
39760         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
39761         if (short_channel_ids_arg_constr.datalen > 0)
39762                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39763         else
39764                 short_channel_ids_arg_constr.data = NULL;
39765         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
39766         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
39767                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
39768                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
39769         }
39770         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
39771         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
39772         int64_t ret_ref = 0;
39773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39774         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39775         return ret_ref;
39776 }
39777
39778 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
39779         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
39780         int64_t ret_ref = 0;
39781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39782         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39783         return ret_ref;
39784 }
39785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39786         LDKReplyChannelRange arg_conv;
39787         arg_conv.inner = untag_ptr(arg);
39788         arg_conv.is_owned = ptr_is_owned(arg);
39789         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39790         arg_conv.is_owned = false;
39791         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
39792         return ret_conv;
39793 }
39794
39795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39796         LDKReplyChannelRange orig_conv;
39797         orig_conv.inner = untag_ptr(orig);
39798         orig_conv.is_owned = ptr_is_owned(orig);
39799         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39800         orig_conv.is_owned = false;
39801         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
39802         int64_t ret_ref = 0;
39803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39804         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39805         return ret_ref;
39806 }
39807
39808 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39809         LDKReplyChannelRange a_conv;
39810         a_conv.inner = untag_ptr(a);
39811         a_conv.is_owned = ptr_is_owned(a);
39812         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39813         a_conv.is_owned = false;
39814         LDKReplyChannelRange b_conv;
39815         b_conv.inner = untag_ptr(b);
39816         b_conv.is_owned = ptr_is_owned(b);
39817         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39818         b_conv.is_owned = false;
39819         jboolean ret_conv = ReplyChannelRange_eq(&a_conv, &b_conv);
39820         return ret_conv;
39821 }
39822
39823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39824         LDKQueryShortChannelIds this_obj_conv;
39825         this_obj_conv.inner = untag_ptr(this_obj);
39826         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39828         QueryShortChannelIds_free(this_obj_conv);
39829 }
39830
39831 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39832         LDKQueryShortChannelIds this_ptr_conv;
39833         this_ptr_conv.inner = untag_ptr(this_ptr);
39834         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39836         this_ptr_conv.is_owned = false;
39837         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39838         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
39839         return ret_arr;
39840 }
39841
39842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39843         LDKQueryShortChannelIds this_ptr_conv;
39844         this_ptr_conv.inner = untag_ptr(this_ptr);
39845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39847         this_ptr_conv.is_owned = false;
39848         LDKThirtyTwoBytes val_ref;
39849         CHECK((*env)->GetArrayLength(env, val) == 32);
39850         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39851         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
39852 }
39853
39854 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
39855         LDKQueryShortChannelIds this_ptr_conv;
39856         this_ptr_conv.inner = untag_ptr(this_ptr);
39857         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39859         this_ptr_conv.is_owned = false;
39860         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
39861         int64_tArray ret_arr = NULL;
39862         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39863         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39864         for (size_t g = 0; g < ret_var.datalen; g++) {
39865                 int64_t ret_conv_6_conv = ret_var.data[g];
39866                 ret_arr_ptr[g] = ret_conv_6_conv;
39867         }
39868         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39869         FREE(ret_var.data);
39870         return ret_arr;
39871 }
39872
39873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39874         LDKQueryShortChannelIds this_ptr_conv;
39875         this_ptr_conv.inner = untag_ptr(this_ptr);
39876         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39878         this_ptr_conv.is_owned = false;
39879         LDKCVec_u64Z val_constr;
39880         val_constr.datalen = (*env)->GetArrayLength(env, val);
39881         if (val_constr.datalen > 0)
39882                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39883         else
39884                 val_constr.data = NULL;
39885         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39886         for (size_t g = 0; g < val_constr.datalen; g++) {
39887                 int64_t val_conv_6 = val_vals[g];
39888                 val_constr.data[g] = val_conv_6;
39889         }
39890         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39891         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
39892 }
39893
39894 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) {
39895         LDKThirtyTwoBytes chain_hash_arg_ref;
39896         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39897         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39898         LDKCVec_u64Z short_channel_ids_arg_constr;
39899         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
39900         if (short_channel_ids_arg_constr.datalen > 0)
39901                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39902         else
39903                 short_channel_ids_arg_constr.data = NULL;
39904         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
39905         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
39906                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
39907                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
39908         }
39909         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
39910         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
39911         int64_t ret_ref = 0;
39912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39913         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39914         return ret_ref;
39915 }
39916
39917 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
39918         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
39919         int64_t ret_ref = 0;
39920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39921         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39922         return ret_ref;
39923 }
39924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39925         LDKQueryShortChannelIds arg_conv;
39926         arg_conv.inner = untag_ptr(arg);
39927         arg_conv.is_owned = ptr_is_owned(arg);
39928         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39929         arg_conv.is_owned = false;
39930         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
39931         return ret_conv;
39932 }
39933
39934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39935         LDKQueryShortChannelIds orig_conv;
39936         orig_conv.inner = untag_ptr(orig);
39937         orig_conv.is_owned = ptr_is_owned(orig);
39938         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39939         orig_conv.is_owned = false;
39940         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
39941         int64_t ret_ref = 0;
39942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39943         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39944         return ret_ref;
39945 }
39946
39947 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39948         LDKQueryShortChannelIds a_conv;
39949         a_conv.inner = untag_ptr(a);
39950         a_conv.is_owned = ptr_is_owned(a);
39951         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39952         a_conv.is_owned = false;
39953         LDKQueryShortChannelIds b_conv;
39954         b_conv.inner = untag_ptr(b);
39955         b_conv.is_owned = ptr_is_owned(b);
39956         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39957         b_conv.is_owned = false;
39958         jboolean ret_conv = QueryShortChannelIds_eq(&a_conv, &b_conv);
39959         return ret_conv;
39960 }
39961
39962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39963         LDKReplyShortChannelIdsEnd this_obj_conv;
39964         this_obj_conv.inner = untag_ptr(this_obj);
39965         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39967         ReplyShortChannelIdsEnd_free(this_obj_conv);
39968 }
39969
39970 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39971         LDKReplyShortChannelIdsEnd this_ptr_conv;
39972         this_ptr_conv.inner = untag_ptr(this_ptr);
39973         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39975         this_ptr_conv.is_owned = false;
39976         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39977         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
39978         return ret_arr;
39979 }
39980
39981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39982         LDKReplyShortChannelIdsEnd this_ptr_conv;
39983         this_ptr_conv.inner = untag_ptr(this_ptr);
39984         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39986         this_ptr_conv.is_owned = false;
39987         LDKThirtyTwoBytes val_ref;
39988         CHECK((*env)->GetArrayLength(env, val) == 32);
39989         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39990         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
39991 }
39992
39993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
39994         LDKReplyShortChannelIdsEnd this_ptr_conv;
39995         this_ptr_conv.inner = untag_ptr(this_ptr);
39996         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39998         this_ptr_conv.is_owned = false;
39999         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
40000         return ret_conv;
40001 }
40002
40003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
40004         LDKReplyShortChannelIdsEnd this_ptr_conv;
40005         this_ptr_conv.inner = untag_ptr(this_ptr);
40006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40008         this_ptr_conv.is_owned = false;
40009         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
40010 }
40011
40012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
40013         LDKThirtyTwoBytes chain_hash_arg_ref;
40014         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
40015         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
40016         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
40017         int64_t ret_ref = 0;
40018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40019         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40020         return ret_ref;
40021 }
40022
40023 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
40024         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
40025         int64_t ret_ref = 0;
40026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40027         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40028         return ret_ref;
40029 }
40030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40031         LDKReplyShortChannelIdsEnd arg_conv;
40032         arg_conv.inner = untag_ptr(arg);
40033         arg_conv.is_owned = ptr_is_owned(arg);
40034         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40035         arg_conv.is_owned = false;
40036         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
40037         return ret_conv;
40038 }
40039
40040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40041         LDKReplyShortChannelIdsEnd orig_conv;
40042         orig_conv.inner = untag_ptr(orig);
40043         orig_conv.is_owned = ptr_is_owned(orig);
40044         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40045         orig_conv.is_owned = false;
40046         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
40047         int64_t ret_ref = 0;
40048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40050         return ret_ref;
40051 }
40052
40053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40054         LDKReplyShortChannelIdsEnd a_conv;
40055         a_conv.inner = untag_ptr(a);
40056         a_conv.is_owned = ptr_is_owned(a);
40057         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40058         a_conv.is_owned = false;
40059         LDKReplyShortChannelIdsEnd b_conv;
40060         b_conv.inner = untag_ptr(b);
40061         b_conv.is_owned = ptr_is_owned(b);
40062         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40063         b_conv.is_owned = false;
40064         jboolean ret_conv = ReplyShortChannelIdsEnd_eq(&a_conv, &b_conv);
40065         return ret_conv;
40066 }
40067
40068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40069         LDKGossipTimestampFilter this_obj_conv;
40070         this_obj_conv.inner = untag_ptr(this_obj);
40071         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40073         GossipTimestampFilter_free(this_obj_conv);
40074 }
40075
40076 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
40077         LDKGossipTimestampFilter this_ptr_conv;
40078         this_ptr_conv.inner = untag_ptr(this_ptr);
40079         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40081         this_ptr_conv.is_owned = false;
40082         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40083         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
40084         return ret_arr;
40085 }
40086
40087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40088         LDKGossipTimestampFilter this_ptr_conv;
40089         this_ptr_conv.inner = untag_ptr(this_ptr);
40090         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40092         this_ptr_conv.is_owned = false;
40093         LDKThirtyTwoBytes val_ref;
40094         CHECK((*env)->GetArrayLength(env, val) == 32);
40095         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40096         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
40097 }
40098
40099 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
40100         LDKGossipTimestampFilter this_ptr_conv;
40101         this_ptr_conv.inner = untag_ptr(this_ptr);
40102         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40104         this_ptr_conv.is_owned = false;
40105         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
40106         return ret_conv;
40107 }
40108
40109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40110         LDKGossipTimestampFilter this_ptr_conv;
40111         this_ptr_conv.inner = untag_ptr(this_ptr);
40112         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40114         this_ptr_conv.is_owned = false;
40115         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
40116 }
40117
40118 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
40119         LDKGossipTimestampFilter this_ptr_conv;
40120         this_ptr_conv.inner = untag_ptr(this_ptr);
40121         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40123         this_ptr_conv.is_owned = false;
40124         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
40125         return ret_conv;
40126 }
40127
40128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40129         LDKGossipTimestampFilter this_ptr_conv;
40130         this_ptr_conv.inner = untag_ptr(this_ptr);
40131         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40133         this_ptr_conv.is_owned = false;
40134         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
40135 }
40136
40137 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) {
40138         LDKThirtyTwoBytes chain_hash_arg_ref;
40139         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
40140         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
40141         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
40142         int64_t ret_ref = 0;
40143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40144         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40145         return ret_ref;
40146 }
40147
40148 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
40149         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
40150         int64_t ret_ref = 0;
40151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40152         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40153         return ret_ref;
40154 }
40155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40156         LDKGossipTimestampFilter arg_conv;
40157         arg_conv.inner = untag_ptr(arg);
40158         arg_conv.is_owned = ptr_is_owned(arg);
40159         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40160         arg_conv.is_owned = false;
40161         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
40162         return ret_conv;
40163 }
40164
40165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40166         LDKGossipTimestampFilter orig_conv;
40167         orig_conv.inner = untag_ptr(orig);
40168         orig_conv.is_owned = ptr_is_owned(orig);
40169         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40170         orig_conv.is_owned = false;
40171         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
40172         int64_t ret_ref = 0;
40173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40174         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40175         return ret_ref;
40176 }
40177
40178 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40179         LDKGossipTimestampFilter a_conv;
40180         a_conv.inner = untag_ptr(a);
40181         a_conv.is_owned = ptr_is_owned(a);
40182         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40183         a_conv.is_owned = false;
40184         LDKGossipTimestampFilter b_conv;
40185         b_conv.inner = untag_ptr(b);
40186         b_conv.is_owned = ptr_is_owned(b);
40187         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40188         b_conv.is_owned = false;
40189         jboolean ret_conv = GossipTimestampFilter_eq(&a_conv, &b_conv);
40190         return ret_conv;
40191 }
40192
40193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40194         if (!ptr_is_owned(this_ptr)) return;
40195         void* this_ptr_ptr = untag_ptr(this_ptr);
40196         CHECK_ACCESS(this_ptr_ptr);
40197         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
40198         FREE(untag_ptr(this_ptr));
40199         ErrorAction_free(this_ptr_conv);
40200 }
40201
40202 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
40203         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40204         *ret_copy = ErrorAction_clone(arg);
40205         int64_t ret_ref = tag_ptr(ret_copy, true);
40206         return ret_ref;
40207 }
40208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40209         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
40210         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
40211         return ret_conv;
40212 }
40213
40214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40215         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
40216         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40217         *ret_copy = ErrorAction_clone(orig_conv);
40218         int64_t ret_ref = tag_ptr(ret_copy, true);
40219         return ret_ref;
40220 }
40221
40222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
40223         LDKErrorMessage msg_conv;
40224         msg_conv.inner = untag_ptr(msg);
40225         msg_conv.is_owned = ptr_is_owned(msg);
40226         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40227         msg_conv = ErrorMessage_clone(&msg_conv);
40228         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40229         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
40230         int64_t ret_ref = tag_ptr(ret_copy, true);
40231         return ret_ref;
40232 }
40233
40234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
40235         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40236         *ret_copy = ErrorAction_ignore_error();
40237         int64_t ret_ref = tag_ptr(ret_copy, true);
40238         return ret_ref;
40239 }
40240
40241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
40242         LDKLevel a_conv = LDKLevel_from_java(env, a);
40243         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40244         *ret_copy = ErrorAction_ignore_and_log(a_conv);
40245         int64_t ret_ref = tag_ptr(ret_copy, true);
40246         return ret_ref;
40247 }
40248
40249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
40250         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40251         *ret_copy = ErrorAction_ignore_duplicate_gossip();
40252         int64_t ret_ref = tag_ptr(ret_copy, true);
40253         return ret_ref;
40254 }
40255
40256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
40257         LDKErrorMessage msg_conv;
40258         msg_conv.inner = untag_ptr(msg);
40259         msg_conv.is_owned = ptr_is_owned(msg);
40260         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40261         msg_conv = ErrorMessage_clone(&msg_conv);
40262         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40263         *ret_copy = ErrorAction_send_error_message(msg_conv);
40264         int64_t ret_ref = tag_ptr(ret_copy, true);
40265         return ret_ref;
40266 }
40267
40268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
40269         LDKWarningMessage msg_conv;
40270         msg_conv.inner = untag_ptr(msg);
40271         msg_conv.is_owned = ptr_is_owned(msg);
40272         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40273         msg_conv = WarningMessage_clone(&msg_conv);
40274         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
40275         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40276         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
40277         int64_t ret_ref = tag_ptr(ret_copy, true);
40278         return ret_ref;
40279 }
40280
40281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40282         LDKLightningError this_obj_conv;
40283         this_obj_conv.inner = untag_ptr(this_obj);
40284         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40286         LightningError_free(this_obj_conv);
40287 }
40288
40289 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
40290         LDKLightningError this_ptr_conv;
40291         this_ptr_conv.inner = untag_ptr(this_ptr);
40292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40294         this_ptr_conv.is_owned = false;
40295         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
40296         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40297         Str_free(ret_str);
40298         return ret_conv;
40299 }
40300
40301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
40302         LDKLightningError this_ptr_conv;
40303         this_ptr_conv.inner = untag_ptr(this_ptr);
40304         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40306         this_ptr_conv.is_owned = false;
40307         LDKStr val_conv = java_to_owned_str(env, val);
40308         LightningError_set_err(&this_ptr_conv, val_conv);
40309 }
40310
40311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
40312         LDKLightningError this_ptr_conv;
40313         this_ptr_conv.inner = untag_ptr(this_ptr);
40314         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40316         this_ptr_conv.is_owned = false;
40317         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
40318         *ret_copy = LightningError_get_action(&this_ptr_conv);
40319         int64_t ret_ref = tag_ptr(ret_copy, true);
40320         return ret_ref;
40321 }
40322
40323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40324         LDKLightningError this_ptr_conv;
40325         this_ptr_conv.inner = untag_ptr(this_ptr);
40326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40328         this_ptr_conv.is_owned = false;
40329         void* val_ptr = untag_ptr(val);
40330         CHECK_ACCESS(val_ptr);
40331         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
40332         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
40333         LightningError_set_action(&this_ptr_conv, val_conv);
40334 }
40335
40336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
40337         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
40338         void* action_arg_ptr = untag_ptr(action_arg);
40339         CHECK_ACCESS(action_arg_ptr);
40340         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
40341         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
40342         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
40343         int64_t ret_ref = 0;
40344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40345         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40346         return ret_ref;
40347 }
40348
40349 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
40350         LDKLightningError ret_var = LightningError_clone(arg);
40351         int64_t ret_ref = 0;
40352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40353         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40354         return ret_ref;
40355 }
40356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40357         LDKLightningError arg_conv;
40358         arg_conv.inner = untag_ptr(arg);
40359         arg_conv.is_owned = ptr_is_owned(arg);
40360         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40361         arg_conv.is_owned = false;
40362         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
40363         return ret_conv;
40364 }
40365
40366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40367         LDKLightningError orig_conv;
40368         orig_conv.inner = untag_ptr(orig);
40369         orig_conv.is_owned = ptr_is_owned(orig);
40370         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40371         orig_conv.is_owned = false;
40372         LDKLightningError ret_var = LightningError_clone(&orig_conv);
40373         int64_t ret_ref = 0;
40374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40375         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40376         return ret_ref;
40377 }
40378
40379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40380         LDKCommitmentUpdate this_obj_conv;
40381         this_obj_conv.inner = untag_ptr(this_obj);
40382         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40384         CommitmentUpdate_free(this_obj_conv);
40385 }
40386
40387 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40388         LDKCommitmentUpdate this_ptr_conv;
40389         this_ptr_conv.inner = untag_ptr(this_ptr);
40390         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40392         this_ptr_conv.is_owned = false;
40393         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
40394         int64_tArray ret_arr = NULL;
40395         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40396         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40397         for (size_t p = 0; p < ret_var.datalen; p++) {
40398                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
40399                 int64_t ret_conv_15_ref = 0;
40400                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
40401                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
40402                 ret_arr_ptr[p] = ret_conv_15_ref;
40403         }
40404         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40405         FREE(ret_var.data);
40406         return ret_arr;
40407 }
40408
40409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40410         LDKCommitmentUpdate this_ptr_conv;
40411         this_ptr_conv.inner = untag_ptr(this_ptr);
40412         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40414         this_ptr_conv.is_owned = false;
40415         LDKCVec_UpdateAddHTLCZ val_constr;
40416         val_constr.datalen = (*env)->GetArrayLength(env, val);
40417         if (val_constr.datalen > 0)
40418                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
40419         else
40420                 val_constr.data = NULL;
40421         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40422         for (size_t p = 0; p < val_constr.datalen; p++) {
40423                 int64_t val_conv_15 = val_vals[p];
40424                 LDKUpdateAddHTLC val_conv_15_conv;
40425                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
40426                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
40427                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
40428                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
40429                 val_constr.data[p] = val_conv_15_conv;
40430         }
40431         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40432         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
40433 }
40434
40435 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40436         LDKCommitmentUpdate this_ptr_conv;
40437         this_ptr_conv.inner = untag_ptr(this_ptr);
40438         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40440         this_ptr_conv.is_owned = false;
40441         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
40442         int64_tArray ret_arr = NULL;
40443         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40444         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40445         for (size_t t = 0; t < ret_var.datalen; t++) {
40446                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
40447                 int64_t ret_conv_19_ref = 0;
40448                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
40449                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
40450                 ret_arr_ptr[t] = ret_conv_19_ref;
40451         }
40452         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40453         FREE(ret_var.data);
40454         return ret_arr;
40455 }
40456
40457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40458         LDKCommitmentUpdate this_ptr_conv;
40459         this_ptr_conv.inner = untag_ptr(this_ptr);
40460         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40462         this_ptr_conv.is_owned = false;
40463         LDKCVec_UpdateFulfillHTLCZ val_constr;
40464         val_constr.datalen = (*env)->GetArrayLength(env, val);
40465         if (val_constr.datalen > 0)
40466                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
40467         else
40468                 val_constr.data = NULL;
40469         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40470         for (size_t t = 0; t < val_constr.datalen; t++) {
40471                 int64_t val_conv_19 = val_vals[t];
40472                 LDKUpdateFulfillHTLC val_conv_19_conv;
40473                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
40474                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
40475                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
40476                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
40477                 val_constr.data[t] = val_conv_19_conv;
40478         }
40479         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40480         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
40481 }
40482
40483 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40484         LDKCommitmentUpdate this_ptr_conv;
40485         this_ptr_conv.inner = untag_ptr(this_ptr);
40486         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40488         this_ptr_conv.is_owned = false;
40489         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
40490         int64_tArray ret_arr = NULL;
40491         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40492         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40493         for (size_t q = 0; q < ret_var.datalen; q++) {
40494                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
40495                 int64_t ret_conv_16_ref = 0;
40496                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
40497                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
40498                 ret_arr_ptr[q] = ret_conv_16_ref;
40499         }
40500         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40501         FREE(ret_var.data);
40502         return ret_arr;
40503 }
40504
40505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40506         LDKCommitmentUpdate this_ptr_conv;
40507         this_ptr_conv.inner = untag_ptr(this_ptr);
40508         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40510         this_ptr_conv.is_owned = false;
40511         LDKCVec_UpdateFailHTLCZ val_constr;
40512         val_constr.datalen = (*env)->GetArrayLength(env, val);
40513         if (val_constr.datalen > 0)
40514                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
40515         else
40516                 val_constr.data = NULL;
40517         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40518         for (size_t q = 0; q < val_constr.datalen; q++) {
40519                 int64_t val_conv_16 = val_vals[q];
40520                 LDKUpdateFailHTLC val_conv_16_conv;
40521                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
40522                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
40523                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
40524                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
40525                 val_constr.data[q] = val_conv_16_conv;
40526         }
40527         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40528         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
40529 }
40530
40531 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40532         LDKCommitmentUpdate this_ptr_conv;
40533         this_ptr_conv.inner = untag_ptr(this_ptr);
40534         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40536         this_ptr_conv.is_owned = false;
40537         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
40538         int64_tArray ret_arr = NULL;
40539         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
40540         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
40541         for (size_t z = 0; z < ret_var.datalen; z++) {
40542                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
40543                 int64_t ret_conv_25_ref = 0;
40544                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
40545                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
40546                 ret_arr_ptr[z] = ret_conv_25_ref;
40547         }
40548         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
40549         FREE(ret_var.data);
40550         return ret_arr;
40551 }
40552
40553 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) {
40554         LDKCommitmentUpdate this_ptr_conv;
40555         this_ptr_conv.inner = untag_ptr(this_ptr);
40556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40558         this_ptr_conv.is_owned = false;
40559         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
40560         val_constr.datalen = (*env)->GetArrayLength(env, val);
40561         if (val_constr.datalen > 0)
40562                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
40563         else
40564                 val_constr.data = NULL;
40565         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40566         for (size_t z = 0; z < val_constr.datalen; z++) {
40567                 int64_t val_conv_25 = val_vals[z];
40568                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
40569                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
40570                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
40571                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
40572                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
40573                 val_constr.data[z] = val_conv_25_conv;
40574         }
40575         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40576         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
40577 }
40578
40579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
40580         LDKCommitmentUpdate this_ptr_conv;
40581         this_ptr_conv.inner = untag_ptr(this_ptr);
40582         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40584         this_ptr_conv.is_owned = false;
40585         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
40586         int64_t ret_ref = 0;
40587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40588         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40589         return ret_ref;
40590 }
40591
40592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40593         LDKCommitmentUpdate this_ptr_conv;
40594         this_ptr_conv.inner = untag_ptr(this_ptr);
40595         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40597         this_ptr_conv.is_owned = false;
40598         LDKUpdateFee val_conv;
40599         val_conv.inner = untag_ptr(val);
40600         val_conv.is_owned = ptr_is_owned(val);
40601         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40602         val_conv = UpdateFee_clone(&val_conv);
40603         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
40604 }
40605
40606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
40607         LDKCommitmentUpdate this_ptr_conv;
40608         this_ptr_conv.inner = untag_ptr(this_ptr);
40609         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40611         this_ptr_conv.is_owned = false;
40612         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
40613         int64_t ret_ref = 0;
40614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40615         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40616         return ret_ref;
40617 }
40618
40619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40620         LDKCommitmentUpdate this_ptr_conv;
40621         this_ptr_conv.inner = untag_ptr(this_ptr);
40622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40624         this_ptr_conv.is_owned = false;
40625         LDKCommitmentSigned val_conv;
40626         val_conv.inner = untag_ptr(val);
40627         val_conv.is_owned = ptr_is_owned(val);
40628         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40629         val_conv = CommitmentSigned_clone(&val_conv);
40630         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
40631 }
40632
40633 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) {
40634         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
40635         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
40636         if (update_add_htlcs_arg_constr.datalen > 0)
40637                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
40638         else
40639                 update_add_htlcs_arg_constr.data = NULL;
40640         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
40641         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
40642                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
40643                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
40644                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
40645                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
40646                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
40647                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
40648                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
40649         }
40650         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
40651         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
40652         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
40653         if (update_fulfill_htlcs_arg_constr.datalen > 0)
40654                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
40655         else
40656                 update_fulfill_htlcs_arg_constr.data = NULL;
40657         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
40658         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
40659                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
40660                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
40661                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
40662                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
40663                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
40664                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
40665                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
40666         }
40667         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
40668         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
40669         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
40670         if (update_fail_htlcs_arg_constr.datalen > 0)
40671                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
40672         else
40673                 update_fail_htlcs_arg_constr.data = NULL;
40674         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
40675         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
40676                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
40677                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
40678                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
40679                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
40680                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
40681                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
40682                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
40683         }
40684         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
40685         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
40686         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
40687         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
40688                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
40689         else
40690                 update_fail_malformed_htlcs_arg_constr.data = NULL;
40691         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
40692         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
40693                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
40694                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
40695                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
40696                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
40697                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
40698                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
40699                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
40700         }
40701         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
40702         LDKUpdateFee update_fee_arg_conv;
40703         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
40704         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
40705         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
40706         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
40707         LDKCommitmentSigned commitment_signed_arg_conv;
40708         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
40709         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
40710         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
40711         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
40712         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);
40713         int64_t ret_ref = 0;
40714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40715         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40716         return ret_ref;
40717 }
40718
40719 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
40720         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
40721         int64_t ret_ref = 0;
40722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40723         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40724         return ret_ref;
40725 }
40726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40727         LDKCommitmentUpdate arg_conv;
40728         arg_conv.inner = untag_ptr(arg);
40729         arg_conv.is_owned = ptr_is_owned(arg);
40730         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40731         arg_conv.is_owned = false;
40732         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
40733         return ret_conv;
40734 }
40735
40736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40737         LDKCommitmentUpdate orig_conv;
40738         orig_conv.inner = untag_ptr(orig);
40739         orig_conv.is_owned = ptr_is_owned(orig);
40740         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40741         orig_conv.is_owned = false;
40742         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
40743         int64_t ret_ref = 0;
40744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40745         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40746         return ret_ref;
40747 }
40748
40749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40750         LDKCommitmentUpdate a_conv;
40751         a_conv.inner = untag_ptr(a);
40752         a_conv.is_owned = ptr_is_owned(a);
40753         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40754         a_conv.is_owned = false;
40755         LDKCommitmentUpdate b_conv;
40756         b_conv.inner = untag_ptr(b);
40757         b_conv.is_owned = ptr_is_owned(b);
40758         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40759         b_conv.is_owned = false;
40760         jboolean ret_conv = CommitmentUpdate_eq(&a_conv, &b_conv);
40761         return ret_conv;
40762 }
40763
40764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40765         if (!ptr_is_owned(this_ptr)) return;
40766         void* this_ptr_ptr = untag_ptr(this_ptr);
40767         CHECK_ACCESS(this_ptr_ptr);
40768         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
40769         FREE(untag_ptr(this_ptr));
40770         ChannelMessageHandler_free(this_ptr_conv);
40771 }
40772
40773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40774         if (!ptr_is_owned(this_ptr)) return;
40775         void* this_ptr_ptr = untag_ptr(this_ptr);
40776         CHECK_ACCESS(this_ptr_ptr);
40777         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
40778         FREE(untag_ptr(this_ptr));
40779         RoutingMessageHandler_free(this_ptr_conv);
40780 }
40781
40782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40783         if (!ptr_is_owned(this_ptr)) return;
40784         void* this_ptr_ptr = untag_ptr(this_ptr);
40785         CHECK_ACCESS(this_ptr_ptr);
40786         LDKOnionMessageHandler this_ptr_conv = *(LDKOnionMessageHandler*)(this_ptr_ptr);
40787         FREE(untag_ptr(this_ptr));
40788         OnionMessageHandler_free(this_ptr_conv);
40789 }
40790
40791 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
40792         LDKAcceptChannel obj_conv;
40793         obj_conv.inner = untag_ptr(obj);
40794         obj_conv.is_owned = ptr_is_owned(obj);
40795         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40796         obj_conv.is_owned = false;
40797         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
40798         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40799         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40800         CVec_u8Z_free(ret_var);
40801         return ret_arr;
40802 }
40803
40804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40805         LDKu8slice ser_ref;
40806         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40807         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40808         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
40809         *ret_conv = AcceptChannel_read(ser_ref);
40810         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40811         return tag_ptr(ret_conv, true);
40812 }
40813
40814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40815         LDKAnnouncementSignatures obj_conv;
40816         obj_conv.inner = untag_ptr(obj);
40817         obj_conv.is_owned = ptr_is_owned(obj);
40818         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40819         obj_conv.is_owned = false;
40820         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
40821         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40822         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40823         CVec_u8Z_free(ret_var);
40824         return ret_arr;
40825 }
40826
40827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40828         LDKu8slice ser_ref;
40829         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40830         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40831         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
40832         *ret_conv = AnnouncementSignatures_read(ser_ref);
40833         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40834         return tag_ptr(ret_conv, true);
40835 }
40836
40837 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
40838         LDKChannelReestablish obj_conv;
40839         obj_conv.inner = untag_ptr(obj);
40840         obj_conv.is_owned = ptr_is_owned(obj);
40841         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40842         obj_conv.is_owned = false;
40843         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
40844         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40845         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40846         CVec_u8Z_free(ret_var);
40847         return ret_arr;
40848 }
40849
40850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40851         LDKu8slice ser_ref;
40852         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40853         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40854         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
40855         *ret_conv = ChannelReestablish_read(ser_ref);
40856         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40857         return tag_ptr(ret_conv, true);
40858 }
40859
40860 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40861         LDKClosingSigned obj_conv;
40862         obj_conv.inner = untag_ptr(obj);
40863         obj_conv.is_owned = ptr_is_owned(obj);
40864         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40865         obj_conv.is_owned = false;
40866         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
40867         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40868         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40869         CVec_u8Z_free(ret_var);
40870         return ret_arr;
40871 }
40872
40873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40874         LDKu8slice ser_ref;
40875         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40876         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40877         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
40878         *ret_conv = ClosingSigned_read(ser_ref);
40879         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40880         return tag_ptr(ret_conv, true);
40881 }
40882
40883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
40884         LDKClosingSignedFeeRange obj_conv;
40885         obj_conv.inner = untag_ptr(obj);
40886         obj_conv.is_owned = ptr_is_owned(obj);
40887         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40888         obj_conv.is_owned = false;
40889         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
40890         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40891         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40892         CVec_u8Z_free(ret_var);
40893         return ret_arr;
40894 }
40895
40896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40897         LDKu8slice ser_ref;
40898         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40899         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40900         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
40901         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
40902         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40903         return tag_ptr(ret_conv, true);
40904 }
40905
40906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40907         LDKCommitmentSigned obj_conv;
40908         obj_conv.inner = untag_ptr(obj);
40909         obj_conv.is_owned = ptr_is_owned(obj);
40910         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40911         obj_conv.is_owned = false;
40912         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
40913         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40914         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40915         CVec_u8Z_free(ret_var);
40916         return ret_arr;
40917 }
40918
40919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40920         LDKu8slice ser_ref;
40921         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40922         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40923         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
40924         *ret_conv = CommitmentSigned_read(ser_ref);
40925         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40926         return tag_ptr(ret_conv, true);
40927 }
40928
40929 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
40930         LDKFundingCreated obj_conv;
40931         obj_conv.inner = untag_ptr(obj);
40932         obj_conv.is_owned = ptr_is_owned(obj);
40933         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40934         obj_conv.is_owned = false;
40935         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
40936         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40937         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40938         CVec_u8Z_free(ret_var);
40939         return ret_arr;
40940 }
40941
40942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40943         LDKu8slice ser_ref;
40944         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40945         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40946         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
40947         *ret_conv = FundingCreated_read(ser_ref);
40948         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40949         return tag_ptr(ret_conv, true);
40950 }
40951
40952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40953         LDKFundingSigned obj_conv;
40954         obj_conv.inner = untag_ptr(obj);
40955         obj_conv.is_owned = ptr_is_owned(obj);
40956         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40957         obj_conv.is_owned = false;
40958         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
40959         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40960         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40961         CVec_u8Z_free(ret_var);
40962         return ret_arr;
40963 }
40964
40965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40966         LDKu8slice ser_ref;
40967         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40968         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40969         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
40970         *ret_conv = FundingSigned_read(ser_ref);
40971         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40972         return tag_ptr(ret_conv, true);
40973 }
40974
40975 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
40976         LDKChannelReady obj_conv;
40977         obj_conv.inner = untag_ptr(obj);
40978         obj_conv.is_owned = ptr_is_owned(obj);
40979         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40980         obj_conv.is_owned = false;
40981         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
40982         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40983         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40984         CVec_u8Z_free(ret_var);
40985         return ret_arr;
40986 }
40987
40988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40989         LDKu8slice ser_ref;
40990         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40991         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40992         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
40993         *ret_conv = ChannelReady_read(ser_ref);
40994         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40995         return tag_ptr(ret_conv, true);
40996 }
40997
40998 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
40999         LDKInit obj_conv;
41000         obj_conv.inner = untag_ptr(obj);
41001         obj_conv.is_owned = ptr_is_owned(obj);
41002         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41003         obj_conv.is_owned = false;
41004         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
41005         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41006         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41007         CVec_u8Z_free(ret_var);
41008         return ret_arr;
41009 }
41010
41011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41012         LDKu8slice ser_ref;
41013         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41014         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41015         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
41016         *ret_conv = Init_read(ser_ref);
41017         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41018         return tag_ptr(ret_conv, true);
41019 }
41020
41021 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
41022         LDKOpenChannel obj_conv;
41023         obj_conv.inner = untag_ptr(obj);
41024         obj_conv.is_owned = ptr_is_owned(obj);
41025         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41026         obj_conv.is_owned = false;
41027         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
41028         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41029         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41030         CVec_u8Z_free(ret_var);
41031         return ret_arr;
41032 }
41033
41034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41035         LDKu8slice ser_ref;
41036         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41037         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41038         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
41039         *ret_conv = OpenChannel_read(ser_ref);
41040         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41041         return tag_ptr(ret_conv, true);
41042 }
41043
41044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
41045         LDKRevokeAndACK obj_conv;
41046         obj_conv.inner = untag_ptr(obj);
41047         obj_conv.is_owned = ptr_is_owned(obj);
41048         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41049         obj_conv.is_owned = false;
41050         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
41051         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41052         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41053         CVec_u8Z_free(ret_var);
41054         return ret_arr;
41055 }
41056
41057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41058         LDKu8slice ser_ref;
41059         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41060         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41061         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
41062         *ret_conv = RevokeAndACK_read(ser_ref);
41063         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41064         return tag_ptr(ret_conv, true);
41065 }
41066
41067 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
41068         LDKShutdown obj_conv;
41069         obj_conv.inner = untag_ptr(obj);
41070         obj_conv.is_owned = ptr_is_owned(obj);
41071         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41072         obj_conv.is_owned = false;
41073         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
41074         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41075         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41076         CVec_u8Z_free(ret_var);
41077         return ret_arr;
41078 }
41079
41080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41081         LDKu8slice ser_ref;
41082         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41083         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41084         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
41085         *ret_conv = Shutdown_read(ser_ref);
41086         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41087         return tag_ptr(ret_conv, true);
41088 }
41089
41090 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41091         LDKUpdateFailHTLC obj_conv;
41092         obj_conv.inner = untag_ptr(obj);
41093         obj_conv.is_owned = ptr_is_owned(obj);
41094         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41095         obj_conv.is_owned = false;
41096         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
41097         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41098         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41099         CVec_u8Z_free(ret_var);
41100         return ret_arr;
41101 }
41102
41103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41104         LDKu8slice ser_ref;
41105         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41106         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41107         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
41108         *ret_conv = UpdateFailHTLC_read(ser_ref);
41109         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41110         return tag_ptr(ret_conv, true);
41111 }
41112
41113 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41114         LDKUpdateFailMalformedHTLC obj_conv;
41115         obj_conv.inner = untag_ptr(obj);
41116         obj_conv.is_owned = ptr_is_owned(obj);
41117         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41118         obj_conv.is_owned = false;
41119         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
41120         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41121         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41122         CVec_u8Z_free(ret_var);
41123         return ret_arr;
41124 }
41125
41126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41127         LDKu8slice ser_ref;
41128         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41129         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41130         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
41131         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
41132         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41133         return tag_ptr(ret_conv, true);
41134 }
41135
41136 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
41137         LDKUpdateFee obj_conv;
41138         obj_conv.inner = untag_ptr(obj);
41139         obj_conv.is_owned = ptr_is_owned(obj);
41140         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41141         obj_conv.is_owned = false;
41142         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
41143         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41144         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41145         CVec_u8Z_free(ret_var);
41146         return ret_arr;
41147 }
41148
41149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41150         LDKu8slice ser_ref;
41151         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41152         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41153         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
41154         *ret_conv = UpdateFee_read(ser_ref);
41155         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41156         return tag_ptr(ret_conv, true);
41157 }
41158
41159 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41160         LDKUpdateFulfillHTLC obj_conv;
41161         obj_conv.inner = untag_ptr(obj);
41162         obj_conv.is_owned = ptr_is_owned(obj);
41163         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41164         obj_conv.is_owned = false;
41165         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
41166         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41167         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41168         CVec_u8Z_free(ret_var);
41169         return ret_arr;
41170 }
41171
41172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41173         LDKu8slice ser_ref;
41174         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41175         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41176         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
41177         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
41178         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41179         return tag_ptr(ret_conv, true);
41180 }
41181
41182 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
41183         LDKUpdateAddHTLC obj_conv;
41184         obj_conv.inner = untag_ptr(obj);
41185         obj_conv.is_owned = ptr_is_owned(obj);
41186         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41187         obj_conv.is_owned = false;
41188         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
41189         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41190         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41191         CVec_u8Z_free(ret_var);
41192         return ret_arr;
41193 }
41194
41195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41196         LDKu8slice ser_ref;
41197         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41198         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41199         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
41200         *ret_conv = UpdateAddHTLC_read(ser_ref);
41201         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41202         return tag_ptr(ret_conv, true);
41203 }
41204
41205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41206         LDKu8slice ser_ref;
41207         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41208         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41209         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
41210         *ret_conv = OnionMessage_read(ser_ref);
41211         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41212         return tag_ptr(ret_conv, true);
41213 }
41214
41215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41216         LDKOnionMessage obj_conv;
41217         obj_conv.inner = untag_ptr(obj);
41218         obj_conv.is_owned = ptr_is_owned(obj);
41219         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41220         obj_conv.is_owned = false;
41221         LDKCVec_u8Z ret_var = OnionMessage_write(&obj_conv);
41222         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41223         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41224         CVec_u8Z_free(ret_var);
41225         return ret_arr;
41226 }
41227
41228 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
41229         LDKPing obj_conv;
41230         obj_conv.inner = untag_ptr(obj);
41231         obj_conv.is_owned = ptr_is_owned(obj);
41232         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41233         obj_conv.is_owned = false;
41234         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
41235         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41236         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41237         CVec_u8Z_free(ret_var);
41238         return ret_arr;
41239 }
41240
41241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41242         LDKu8slice ser_ref;
41243         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41244         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41245         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
41246         *ret_conv = Ping_read(ser_ref);
41247         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41248         return tag_ptr(ret_conv, true);
41249 }
41250
41251 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
41252         LDKPong obj_conv;
41253         obj_conv.inner = untag_ptr(obj);
41254         obj_conv.is_owned = ptr_is_owned(obj);
41255         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41256         obj_conv.is_owned = false;
41257         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
41258         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41259         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41260         CVec_u8Z_free(ret_var);
41261         return ret_arr;
41262 }
41263
41264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41265         LDKu8slice ser_ref;
41266         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41267         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41268         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
41269         *ret_conv = Pong_read(ser_ref);
41270         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41271         return tag_ptr(ret_conv, true);
41272 }
41273
41274 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41275         LDKUnsignedChannelAnnouncement obj_conv;
41276         obj_conv.inner = untag_ptr(obj);
41277         obj_conv.is_owned = ptr_is_owned(obj);
41278         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41279         obj_conv.is_owned = false;
41280         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
41281         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41282         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41283         CVec_u8Z_free(ret_var);
41284         return ret_arr;
41285 }
41286
41287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41288         LDKu8slice ser_ref;
41289         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41290         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41291         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
41292         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
41293         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41294         return tag_ptr(ret_conv, true);
41295 }
41296
41297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41298         LDKChannelAnnouncement obj_conv;
41299         obj_conv.inner = untag_ptr(obj);
41300         obj_conv.is_owned = ptr_is_owned(obj);
41301         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41302         obj_conv.is_owned = false;
41303         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
41304         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41305         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41306         CVec_u8Z_free(ret_var);
41307         return ret_arr;
41308 }
41309
41310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41311         LDKu8slice ser_ref;
41312         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41313         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41314         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
41315         *ret_conv = ChannelAnnouncement_read(ser_ref);
41316         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41317         return tag_ptr(ret_conv, true);
41318 }
41319
41320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
41321         LDKUnsignedChannelUpdate obj_conv;
41322         obj_conv.inner = untag_ptr(obj);
41323         obj_conv.is_owned = ptr_is_owned(obj);
41324         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41325         obj_conv.is_owned = false;
41326         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
41327         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41328         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41329         CVec_u8Z_free(ret_var);
41330         return ret_arr;
41331 }
41332
41333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41334         LDKu8slice ser_ref;
41335         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41336         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41337         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
41338         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
41339         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41340         return tag_ptr(ret_conv, true);
41341 }
41342
41343 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
41344         LDKChannelUpdate obj_conv;
41345         obj_conv.inner = untag_ptr(obj);
41346         obj_conv.is_owned = ptr_is_owned(obj);
41347         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41348         obj_conv.is_owned = false;
41349         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
41350         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41351         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41352         CVec_u8Z_free(ret_var);
41353         return ret_arr;
41354 }
41355
41356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41357         LDKu8slice ser_ref;
41358         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41359         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41360         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
41361         *ret_conv = ChannelUpdate_read(ser_ref);
41362         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41363         return tag_ptr(ret_conv, true);
41364 }
41365
41366 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41367         LDKErrorMessage obj_conv;
41368         obj_conv.inner = untag_ptr(obj);
41369         obj_conv.is_owned = ptr_is_owned(obj);
41370         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41371         obj_conv.is_owned = false;
41372         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
41373         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41374         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41375         CVec_u8Z_free(ret_var);
41376         return ret_arr;
41377 }
41378
41379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41380         LDKu8slice ser_ref;
41381         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41382         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41383         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
41384         *ret_conv = ErrorMessage_read(ser_ref);
41385         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41386         return tag_ptr(ret_conv, true);
41387 }
41388
41389 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
41390         LDKWarningMessage obj_conv;
41391         obj_conv.inner = untag_ptr(obj);
41392         obj_conv.is_owned = ptr_is_owned(obj);
41393         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41394         obj_conv.is_owned = false;
41395         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
41396         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41397         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41398         CVec_u8Z_free(ret_var);
41399         return ret_arr;
41400 }
41401
41402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41403         LDKu8slice ser_ref;
41404         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41405         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41406         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
41407         *ret_conv = WarningMessage_read(ser_ref);
41408         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41409         return tag_ptr(ret_conv, true);
41410 }
41411
41412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41413         LDKUnsignedNodeAnnouncement obj_conv;
41414         obj_conv.inner = untag_ptr(obj);
41415         obj_conv.is_owned = ptr_is_owned(obj);
41416         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41417         obj_conv.is_owned = false;
41418         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
41419         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41420         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41421         CVec_u8Z_free(ret_var);
41422         return ret_arr;
41423 }
41424
41425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41426         LDKu8slice ser_ref;
41427         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41428         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41429         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
41430         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
41431         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41432         return tag_ptr(ret_conv, true);
41433 }
41434
41435 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
41436         LDKNodeAnnouncement obj_conv;
41437         obj_conv.inner = untag_ptr(obj);
41438         obj_conv.is_owned = ptr_is_owned(obj);
41439         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41440         obj_conv.is_owned = false;
41441         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
41442         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41443         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41444         CVec_u8Z_free(ret_var);
41445         return ret_arr;
41446 }
41447
41448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41449         LDKu8slice ser_ref;
41450         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41451         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41452         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
41453         *ret_conv = NodeAnnouncement_read(ser_ref);
41454         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41455         return tag_ptr(ret_conv, true);
41456 }
41457
41458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41459         LDKu8slice ser_ref;
41460         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41461         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41462         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
41463         *ret_conv = QueryShortChannelIds_read(ser_ref);
41464         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41465         return tag_ptr(ret_conv, true);
41466 }
41467
41468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
41469         LDKQueryShortChannelIds obj_conv;
41470         obj_conv.inner = untag_ptr(obj);
41471         obj_conv.is_owned = ptr_is_owned(obj);
41472         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41473         obj_conv.is_owned = false;
41474         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
41475         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41476         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41477         CVec_u8Z_free(ret_var);
41478         return ret_arr;
41479 }
41480
41481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
41482         LDKReplyShortChannelIdsEnd obj_conv;
41483         obj_conv.inner = untag_ptr(obj);
41484         obj_conv.is_owned = ptr_is_owned(obj);
41485         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41486         obj_conv.is_owned = false;
41487         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
41488         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41489         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41490         CVec_u8Z_free(ret_var);
41491         return ret_arr;
41492 }
41493
41494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41495         LDKu8slice ser_ref;
41496         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41497         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41498         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
41499         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
41500         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41501         return tag_ptr(ret_conv, true);
41502 }
41503
41504 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
41505         LDKQueryChannelRange this_arg_conv;
41506         this_arg_conv.inner = untag_ptr(this_arg);
41507         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41509         this_arg_conv.is_owned = false;
41510         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
41511         return ret_conv;
41512 }
41513
41514 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
41515         LDKQueryChannelRange obj_conv;
41516         obj_conv.inner = untag_ptr(obj);
41517         obj_conv.is_owned = ptr_is_owned(obj);
41518         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41519         obj_conv.is_owned = false;
41520         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
41521         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41522         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41523         CVec_u8Z_free(ret_var);
41524         return ret_arr;
41525 }
41526
41527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41528         LDKu8slice ser_ref;
41529         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41530         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41531         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
41532         *ret_conv = QueryChannelRange_read(ser_ref);
41533         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41534         return tag_ptr(ret_conv, true);
41535 }
41536
41537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41538         LDKu8slice ser_ref;
41539         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41540         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41541         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
41542         *ret_conv = ReplyChannelRange_read(ser_ref);
41543         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41544         return tag_ptr(ret_conv, true);
41545 }
41546
41547 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
41548         LDKReplyChannelRange obj_conv;
41549         obj_conv.inner = untag_ptr(obj);
41550         obj_conv.is_owned = ptr_is_owned(obj);
41551         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41552         obj_conv.is_owned = false;
41553         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
41554         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41555         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41556         CVec_u8Z_free(ret_var);
41557         return ret_arr;
41558 }
41559
41560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
41561         LDKGossipTimestampFilter obj_conv;
41562         obj_conv.inner = untag_ptr(obj);
41563         obj_conv.is_owned = ptr_is_owned(obj);
41564         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41565         obj_conv.is_owned = false;
41566         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
41567         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41568         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41569         CVec_u8Z_free(ret_var);
41570         return ret_arr;
41571 }
41572
41573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41574         LDKu8slice ser_ref;
41575         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41576         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41577         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
41578         *ret_conv = GossipTimestampFilter_read(ser_ref);
41579         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41580         return tag_ptr(ret_conv, true);
41581 }
41582
41583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41584         if (!ptr_is_owned(this_ptr)) return;
41585         void* this_ptr_ptr = untag_ptr(this_ptr);
41586         CHECK_ACCESS(this_ptr_ptr);
41587         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
41588         FREE(untag_ptr(this_ptr));
41589         CustomMessageHandler_free(this_ptr_conv);
41590 }
41591
41592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41593         LDKIgnoringMessageHandler this_obj_conv;
41594         this_obj_conv.inner = untag_ptr(this_obj);
41595         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41597         IgnoringMessageHandler_free(this_obj_conv);
41598 }
41599
41600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
41601         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
41602         int64_t ret_ref = 0;
41603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41604         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41605         return ret_ref;
41606 }
41607
41608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41609         LDKIgnoringMessageHandler this_arg_conv;
41610         this_arg_conv.inner = untag_ptr(this_arg);
41611         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41613         this_arg_conv.is_owned = false;
41614         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
41615         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
41616         return tag_ptr(ret_ret, true);
41617 }
41618
41619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41620         LDKIgnoringMessageHandler this_arg_conv;
41621         this_arg_conv.inner = untag_ptr(this_arg);
41622         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41624         this_arg_conv.is_owned = false;
41625         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
41626         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
41627         return tag_ptr(ret_ret, true);
41628 }
41629
41630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41631         LDKIgnoringMessageHandler this_arg_conv;
41632         this_arg_conv.inner = untag_ptr(this_arg);
41633         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41635         this_arg_conv.is_owned = false;
41636         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
41637         *ret_ret = IgnoringMessageHandler_as_OnionMessageProvider(&this_arg_conv);
41638         return tag_ptr(ret_ret, true);
41639 }
41640
41641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41642         LDKIgnoringMessageHandler this_arg_conv;
41643         this_arg_conv.inner = untag_ptr(this_arg);
41644         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41646         this_arg_conv.is_owned = false;
41647         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
41648         *ret_ret = IgnoringMessageHandler_as_OnionMessageHandler(&this_arg_conv);
41649         return tag_ptr(ret_ret, true);
41650 }
41651
41652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomOnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41653         LDKIgnoringMessageHandler this_arg_conv;
41654         this_arg_conv.inner = untag_ptr(this_arg);
41655         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41657         this_arg_conv.is_owned = false;
41658         LDKCustomOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
41659         *ret_ret = IgnoringMessageHandler_as_CustomOnionMessageHandler(&this_arg_conv);
41660         return tag_ptr(ret_ret, true);
41661 }
41662
41663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
41664         LDKIgnoringMessageHandler this_arg_conv;
41665         this_arg_conv.inner = untag_ptr(this_arg);
41666         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41668         this_arg_conv.is_owned = false;
41669         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
41670         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
41671         return tag_ptr(ret_ret, true);
41672 }
41673
41674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41675         LDKIgnoringMessageHandler this_arg_conv;
41676         this_arg_conv.inner = untag_ptr(this_arg);
41677         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41679         this_arg_conv.is_owned = false;
41680         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
41681         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
41682         return tag_ptr(ret_ret, true);
41683 }
41684
41685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41686         LDKErroringMessageHandler this_obj_conv;
41687         this_obj_conv.inner = untag_ptr(this_obj);
41688         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41690         ErroringMessageHandler_free(this_obj_conv);
41691 }
41692
41693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
41694         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
41695         int64_t ret_ref = 0;
41696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41697         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41698         return ret_ref;
41699 }
41700
41701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41702         LDKErroringMessageHandler this_arg_conv;
41703         this_arg_conv.inner = untag_ptr(this_arg);
41704         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41706         this_arg_conv.is_owned = false;
41707         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
41708         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
41709         return tag_ptr(ret_ret, true);
41710 }
41711
41712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41713         LDKErroringMessageHandler this_arg_conv;
41714         this_arg_conv.inner = untag_ptr(this_arg);
41715         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41717         this_arg_conv.is_owned = false;
41718         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
41719         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
41720         return tag_ptr(ret_ret, true);
41721 }
41722
41723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41724         LDKMessageHandler this_obj_conv;
41725         this_obj_conv.inner = untag_ptr(this_obj);
41726         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41728         MessageHandler_free(this_obj_conv);
41729 }
41730
41731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41732         LDKMessageHandler this_ptr_conv;
41733         this_ptr_conv.inner = untag_ptr(this_ptr);
41734         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41736         this_ptr_conv.is_owned = false;
41737         // WARNING: This object doesn't live past this scope, needs clone!
41738         int64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
41739         return ret_ret;
41740 }
41741
41742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41743         LDKMessageHandler this_ptr_conv;
41744         this_ptr_conv.inner = untag_ptr(this_ptr);
41745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41747         this_ptr_conv.is_owned = false;
41748         void* val_ptr = untag_ptr(val);
41749         CHECK_ACCESS(val_ptr);
41750         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
41751         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
41752                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41753                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
41754         }
41755         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
41756 }
41757
41758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41759         LDKMessageHandler this_ptr_conv;
41760         this_ptr_conv.inner = untag_ptr(this_ptr);
41761         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41763         this_ptr_conv.is_owned = false;
41764         // WARNING: This object doesn't live past this scope, needs clone!
41765         int64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
41766         return ret_ret;
41767 }
41768
41769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41770         LDKMessageHandler this_ptr_conv;
41771         this_ptr_conv.inner = untag_ptr(this_ptr);
41772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41774         this_ptr_conv.is_owned = false;
41775         void* val_ptr = untag_ptr(val);
41776         CHECK_ACCESS(val_ptr);
41777         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
41778         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
41779                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41780                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
41781         }
41782         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
41783 }
41784
41785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
41786         LDKMessageHandler this_ptr_conv;
41787         this_ptr_conv.inner = untag_ptr(this_ptr);
41788         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41790         this_ptr_conv.is_owned = false;
41791         // WARNING: This object doesn't live past this scope, needs clone!
41792         int64_t ret_ret = tag_ptr(MessageHandler_get_onion_message_handler(&this_ptr_conv), false);
41793         return ret_ret;
41794 }
41795
41796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41797         LDKMessageHandler this_ptr_conv;
41798         this_ptr_conv.inner = untag_ptr(this_ptr);
41799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41801         this_ptr_conv.is_owned = false;
41802         void* val_ptr = untag_ptr(val);
41803         CHECK_ACCESS(val_ptr);
41804         LDKOnionMessageHandler val_conv = *(LDKOnionMessageHandler*)(val_ptr);
41805         if (val_conv.free == LDKOnionMessageHandler_JCalls_free) {
41806                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41807                 LDKOnionMessageHandler_JCalls_cloned(&val_conv);
41808         }
41809         MessageHandler_set_onion_message_handler(&this_ptr_conv, val_conv);
41810 }
41811
41812 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) {
41813         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
41814         CHECK_ACCESS(chan_handler_arg_ptr);
41815         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
41816         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
41817                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41818                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
41819         }
41820         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
41821         CHECK_ACCESS(route_handler_arg_ptr);
41822         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
41823         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
41824                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41825                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
41826         }
41827         void* onion_message_handler_arg_ptr = untag_ptr(onion_message_handler_arg);
41828         CHECK_ACCESS(onion_message_handler_arg_ptr);
41829         LDKOnionMessageHandler onion_message_handler_arg_conv = *(LDKOnionMessageHandler*)(onion_message_handler_arg_ptr);
41830         if (onion_message_handler_arg_conv.free == LDKOnionMessageHandler_JCalls_free) {
41831                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41832                 LDKOnionMessageHandler_JCalls_cloned(&onion_message_handler_arg_conv);
41833         }
41834         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv, onion_message_handler_arg_conv);
41835         int64_t ret_ref = 0;
41836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41837         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41838         return ret_ref;
41839 }
41840
41841 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
41842         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41843         *ret_ret = SocketDescriptor_clone(arg);
41844         return tag_ptr(ret_ret, true);
41845 }
41846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41847         void* arg_ptr = untag_ptr(arg);
41848         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
41849         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
41850         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
41851         return ret_conv;
41852 }
41853
41854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41855         void* orig_ptr = untag_ptr(orig);
41856         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
41857         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
41858         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41859         *ret_ret = SocketDescriptor_clone(orig_conv);
41860         return tag_ptr(ret_ret, true);
41861 }
41862
41863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41864         if (!ptr_is_owned(this_ptr)) return;
41865         void* this_ptr_ptr = untag_ptr(this_ptr);
41866         CHECK_ACCESS(this_ptr_ptr);
41867         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
41868         FREE(untag_ptr(this_ptr));
41869         SocketDescriptor_free(this_ptr_conv);
41870 }
41871
41872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41873         LDKPeerHandleError this_obj_conv;
41874         this_obj_conv.inner = untag_ptr(this_obj);
41875         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41877         PeerHandleError_free(this_obj_conv);
41878 }
41879
41880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz) {
41881         LDKPeerHandleError ret_var = PeerHandleError_new();
41882         int64_t ret_ref = 0;
41883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41884         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41885         return ret_ref;
41886 }
41887
41888 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
41889         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
41890         int64_t ret_ref = 0;
41891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41892         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41893         return ret_ref;
41894 }
41895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41896         LDKPeerHandleError arg_conv;
41897         arg_conv.inner = untag_ptr(arg);
41898         arg_conv.is_owned = ptr_is_owned(arg);
41899         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41900         arg_conv.is_owned = false;
41901         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
41902         return ret_conv;
41903 }
41904
41905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41906         LDKPeerHandleError orig_conv;
41907         orig_conv.inner = untag_ptr(orig);
41908         orig_conv.is_owned = ptr_is_owned(orig);
41909         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41910         orig_conv.is_owned = false;
41911         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
41912         int64_t ret_ref = 0;
41913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41914         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41915         return ret_ref;
41916 }
41917
41918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41919         LDKPeerManager this_obj_conv;
41920         this_obj_conv.inner = untag_ptr(this_obj);
41921         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41923         PeerManager_free(this_obj_conv);
41924 }
41925
41926 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) {
41927         LDKMessageHandler message_handler_conv;
41928         message_handler_conv.inner = untag_ptr(message_handler);
41929         message_handler_conv.is_owned = ptr_is_owned(message_handler);
41930         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
41931         // WARNING: we need a move here but no clone is available for LDKMessageHandler
41932         
41933         uint8_t ephemeral_random_data_arr[32];
41934         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
41935         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
41936         uint8_t (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
41937         void* logger_ptr = untag_ptr(logger);
41938         CHECK_ACCESS(logger_ptr);
41939         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41940         if (logger_conv.free == LDKLogger_JCalls_free) {
41941                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41942                 LDKLogger_JCalls_cloned(&logger_conv);
41943         }
41944         void* custom_message_handler_ptr = untag_ptr(custom_message_handler);
41945         CHECK_ACCESS(custom_message_handler_ptr);
41946         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
41947         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
41948                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41949                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
41950         }
41951         void* node_signer_ptr = untag_ptr(node_signer);
41952         CHECK_ACCESS(node_signer_ptr);
41953         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
41954         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
41955                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41956                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
41957         }
41958         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, current_time, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv, node_signer_conv);
41959         int64_t ret_ref = 0;
41960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41961         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41962         return ret_ref;
41963 }
41964
41965 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
41966         LDKPeerManager this_arg_conv;
41967         this_arg_conv.inner = untag_ptr(this_arg);
41968         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41970         this_arg_conv.is_owned = false;
41971         LDKCVec_C2Tuple_PublicKeyCOption_NetAddressZZZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
41972         int64_tArray ret_arr = NULL;
41973         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
41974         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
41975         for (size_t o = 0; o < ret_var.datalen; o++) {
41976                 LDKC2Tuple_PublicKeyCOption_NetAddressZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_NetAddressZZ), "LDKC2Tuple_PublicKeyCOption_NetAddressZZ");
41977                 *ret_conv_40_conv = ret_var.data[o];
41978                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
41979         }
41980         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
41981         FREE(ret_var.data);
41982         return ret_arr;
41983 }
41984
41985 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) {
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         LDKPublicKey their_node_id_ref;
41992         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
41993         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
41994         void* descriptor_ptr = untag_ptr(descriptor);
41995         CHECK_ACCESS(descriptor_ptr);
41996         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
41997         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
41998                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41999                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
42000         }
42001         void* remote_network_address_ptr = untag_ptr(remote_network_address);
42002         CHECK_ACCESS(remote_network_address_ptr);
42003         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
42004         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
42005         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
42006         return tag_ptr(ret_conv, true);
42007 }
42008
42009 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) {
42010         LDKPeerManager this_arg_conv;
42011         this_arg_conv.inner = untag_ptr(this_arg);
42012         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42014         this_arg_conv.is_owned = false;
42015         void* descriptor_ptr = untag_ptr(descriptor);
42016         CHECK_ACCESS(descriptor_ptr);
42017         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
42018         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
42019                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42020                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
42021         }
42022         void* remote_network_address_ptr = untag_ptr(remote_network_address);
42023         CHECK_ACCESS(remote_network_address_ptr);
42024         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
42025         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
42026         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
42027         return tag_ptr(ret_conv, true);
42028 }
42029
42030 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) {
42031         LDKPeerManager this_arg_conv;
42032         this_arg_conv.inner = untag_ptr(this_arg);
42033         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42035         this_arg_conv.is_owned = false;
42036         void* descriptor_ptr = untag_ptr(descriptor);
42037         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
42038         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
42039         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
42040         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
42041         return tag_ptr(ret_conv, true);
42042 }
42043
42044 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) {
42045         LDKPeerManager this_arg_conv;
42046         this_arg_conv.inner = untag_ptr(this_arg);
42047         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42049         this_arg_conv.is_owned = false;
42050         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
42051         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
42052         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
42053         LDKu8slice data_ref;
42054         data_ref.datalen = (*env)->GetArrayLength(env, data);
42055         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
42056         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
42057         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
42058         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
42059         return tag_ptr(ret_conv, true);
42060 }
42061
42062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
42063         LDKPeerManager this_arg_conv;
42064         this_arg_conv.inner = untag_ptr(this_arg);
42065         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42067         this_arg_conv.is_owned = false;
42068         PeerManager_process_events(&this_arg_conv);
42069 }
42070
42071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
42072         LDKPeerManager this_arg_conv;
42073         this_arg_conv.inner = untag_ptr(this_arg);
42074         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42076         this_arg_conv.is_owned = false;
42077         void* descriptor_ptr = untag_ptr(descriptor);
42078         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
42079         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
42080         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
42081 }
42082
42083 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) {
42084         LDKPeerManager this_arg_conv;
42085         this_arg_conv.inner = untag_ptr(this_arg);
42086         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42088         this_arg_conv.is_owned = false;
42089         LDKPublicKey node_id_ref;
42090         CHECK((*env)->GetArrayLength(env, node_id) == 33);
42091         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
42092         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref);
42093 }
42094
42095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
42096         LDKPeerManager this_arg_conv;
42097         this_arg_conv.inner = untag_ptr(this_arg);
42098         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42100         this_arg_conv.is_owned = false;
42101         PeerManager_disconnect_all_peers(&this_arg_conv);
42102 }
42103
42104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
42105         LDKPeerManager this_arg_conv;
42106         this_arg_conv.inner = untag_ptr(this_arg);
42107         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42109         this_arg_conv.is_owned = false;
42110         PeerManager_timer_tick_occurred(&this_arg_conv);
42111 }
42112
42113 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) {
42114         LDKPeerManager this_arg_conv;
42115         this_arg_conv.inner = untag_ptr(this_arg);
42116         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42118         this_arg_conv.is_owned = false;
42119         LDKThreeBytes rgb_ref;
42120         CHECK((*env)->GetArrayLength(env, rgb) == 3);
42121         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
42122         LDKThirtyTwoBytes alias_ref;
42123         CHECK((*env)->GetArrayLength(env, alias) == 32);
42124         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
42125         LDKCVec_NetAddressZ addresses_constr;
42126         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
42127         if (addresses_constr.datalen > 0)
42128                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
42129         else
42130                 addresses_constr.data = NULL;
42131         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
42132         for (size_t m = 0; m < addresses_constr.datalen; m++) {
42133                 int64_t addresses_conv_12 = addresses_vals[m];
42134                 void* addresses_conv_12_ptr = untag_ptr(addresses_conv_12);
42135                 CHECK_ACCESS(addresses_conv_12_ptr);
42136                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
42137                 addresses_constr.data[m] = addresses_conv_12_conv;
42138         }
42139         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
42140         PeerManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
42141 }
42142
42143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
42144         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
42145         return ret_conv;
42146 }
42147
42148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
42149         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
42150         return ret_conv;
42151 }
42152
42153 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42154         LDKHTLCClaim* orig_conv = (LDKHTLCClaim*)untag_ptr(orig);
42155         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_clone(orig_conv));
42156         return ret_conv;
42157 }
42158
42159 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1timeout(JNIEnv *env, jclass clz) {
42160         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_timeout());
42161         return ret_conv;
42162 }
42163
42164 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1preimage(JNIEnv *env, jclass clz) {
42165         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_preimage());
42166         return ret_conv;
42167 }
42168
42169 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1timeout(JNIEnv *env, jclass clz) {
42170         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_timeout());
42171         return ret_conv;
42172 }
42173
42174 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1preimage(JNIEnv *env, jclass clz) {
42175         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_preimage());
42176         return ret_conv;
42177 }
42178
42179 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1revocation(JNIEnv *env, jclass clz) {
42180         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_revocation());
42181         return ret_conv;
42182 }
42183
42184 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42185         LDKHTLCClaim* a_conv = (LDKHTLCClaim*)untag_ptr(a);
42186         LDKHTLCClaim* b_conv = (LDKHTLCClaim*)untag_ptr(b);
42187         jboolean ret_conv = HTLCClaim_eq(a_conv, b_conv);
42188         return ret_conv;
42189 }
42190
42191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1from_1witness(JNIEnv *env, jclass clz, int8_tArray witness) {
42192         LDKWitness witness_ref;
42193         witness_ref.datalen = (*env)->GetArrayLength(env, witness);
42194         witness_ref.data = MALLOC(witness_ref.datalen, "LDKWitness Bytes");
42195         (*env)->GetByteArrayRegion(env, witness, 0, witness_ref.datalen, witness_ref.data);
42196         witness_ref.data_is_owned = true;
42197         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
42198         *ret_copy = HTLCClaim_from_witness(witness_ref);
42199         int64_t ret_ref = tag_ptr(ret_copy, true);
42200         return ret_ref;
42201 }
42202
42203 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
42204         uint8_t commitment_seed_arr[32];
42205         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
42206         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
42207         uint8_t (*commitment_seed_ref)[32] = &commitment_seed_arr;
42208         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42209         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
42210         return ret_arr;
42211 }
42212
42213 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) {
42214         LDKCVec_u8Z to_holder_script_ref;
42215         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
42216         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
42217         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
42218         LDKCVec_u8Z to_counterparty_script_ref;
42219         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
42220         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
42221         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
42222         LDKOutPoint funding_outpoint_conv;
42223         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
42224         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
42225         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
42226         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
42227         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);
42228         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42229         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42230         Transaction_free(ret_var);
42231         return ret_arr;
42232 }
42233
42234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42235         LDKCounterpartyCommitmentSecrets this_obj_conv;
42236         this_obj_conv.inner = untag_ptr(this_obj);
42237         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42239         CounterpartyCommitmentSecrets_free(this_obj_conv);
42240 }
42241
42242 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
42243         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
42244         int64_t ret_ref = 0;
42245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42246         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42247         return ret_ref;
42248 }
42249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42250         LDKCounterpartyCommitmentSecrets arg_conv;
42251         arg_conv.inner = untag_ptr(arg);
42252         arg_conv.is_owned = ptr_is_owned(arg);
42253         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42254         arg_conv.is_owned = false;
42255         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
42256         return ret_conv;
42257 }
42258
42259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42260         LDKCounterpartyCommitmentSecrets orig_conv;
42261         orig_conv.inner = untag_ptr(orig);
42262         orig_conv.is_owned = ptr_is_owned(orig);
42263         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42264         orig_conv.is_owned = false;
42265         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
42266         int64_t ret_ref = 0;
42267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42268         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42269         return ret_ref;
42270 }
42271
42272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
42273         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
42274         int64_t ret_ref = 0;
42275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42276         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42277         return ret_ref;
42278 }
42279
42280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42281         LDKCounterpartyCommitmentSecrets this_arg_conv;
42282         this_arg_conv.inner = untag_ptr(this_arg);
42283         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42285         this_arg_conv.is_owned = false;
42286         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
42287         return ret_conv;
42288 }
42289
42290 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) {
42291         LDKCounterpartyCommitmentSecrets this_arg_conv;
42292         this_arg_conv.inner = untag_ptr(this_arg);
42293         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42295         this_arg_conv.is_owned = false;
42296         LDKThirtyTwoBytes secret_ref;
42297         CHECK((*env)->GetArrayLength(env, secret) == 32);
42298         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
42299         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
42300         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
42301         return tag_ptr(ret_conv, true);
42302 }
42303
42304 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
42305         LDKCounterpartyCommitmentSecrets this_arg_conv;
42306         this_arg_conv.inner = untag_ptr(this_arg);
42307         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42309         this_arg_conv.is_owned = false;
42310         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42311         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
42312         return ret_arr;
42313 }
42314
42315 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
42316         LDKCounterpartyCommitmentSecrets obj_conv;
42317         obj_conv.inner = untag_ptr(obj);
42318         obj_conv.is_owned = ptr_is_owned(obj);
42319         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42320         obj_conv.is_owned = false;
42321         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
42322         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42323         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42324         CVec_u8Z_free(ret_var);
42325         return ret_arr;
42326 }
42327
42328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42329         LDKu8slice ser_ref;
42330         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42331         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42332         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
42333         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
42334         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42335         return tag_ptr(ret_conv, true);
42336 }
42337
42338 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) {
42339         LDKPublicKey per_commitment_point_ref;
42340         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42341         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42342         uint8_t base_secret_arr[32];
42343         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
42344         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
42345         uint8_t (*base_secret_ref)[32] = &base_secret_arr;
42346         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42347         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_key(per_commitment_point_ref, base_secret_ref).bytes);
42348         return ret_arr;
42349 }
42350
42351 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) {
42352         LDKPublicKey per_commitment_point_ref;
42353         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42354         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42355         LDKPublicKey base_point_ref;
42356         CHECK((*env)->GetArrayLength(env, base_point) == 33);
42357         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
42358         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42359         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_key(per_commitment_point_ref, base_point_ref).compressed_form);
42360         return ret_arr;
42361 }
42362
42363 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) {
42364         uint8_t per_commitment_secret_arr[32];
42365         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
42366         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
42367         uint8_t (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
42368         uint8_t countersignatory_revocation_base_secret_arr[32];
42369         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
42370         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
42371         uint8_t (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
42372         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42373         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref).bytes);
42374         return ret_arr;
42375 }
42376
42377 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) {
42378         LDKPublicKey per_commitment_point_ref;
42379         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42380         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42381         LDKPublicKey countersignatory_revocation_base_point_ref;
42382         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
42383         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
42384         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42385         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref).compressed_form);
42386         return ret_arr;
42387 }
42388
42389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42390         LDKTxCreationKeys this_obj_conv;
42391         this_obj_conv.inner = untag_ptr(this_obj);
42392         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42394         TxCreationKeys_free(this_obj_conv);
42395 }
42396
42397 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
42398         LDKTxCreationKeys this_ptr_conv;
42399         this_ptr_conv.inner = untag_ptr(this_ptr);
42400         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42402         this_ptr_conv.is_owned = false;
42403         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42404         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
42405         return ret_arr;
42406 }
42407
42408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42409         LDKTxCreationKeys this_ptr_conv;
42410         this_ptr_conv.inner = untag_ptr(this_ptr);
42411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42413         this_ptr_conv.is_owned = false;
42414         LDKPublicKey val_ref;
42415         CHECK((*env)->GetArrayLength(env, val) == 33);
42416         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42417         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
42418 }
42419
42420 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42421         LDKTxCreationKeys this_ptr_conv;
42422         this_ptr_conv.inner = untag_ptr(this_ptr);
42423         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42425         this_ptr_conv.is_owned = false;
42426         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42427         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
42428         return ret_arr;
42429 }
42430
42431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42432         LDKTxCreationKeys this_ptr_conv;
42433         this_ptr_conv.inner = untag_ptr(this_ptr);
42434         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42436         this_ptr_conv.is_owned = false;
42437         LDKPublicKey val_ref;
42438         CHECK((*env)->GetArrayLength(env, val) == 33);
42439         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42440         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
42441 }
42442
42443 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42444         LDKTxCreationKeys this_ptr_conv;
42445         this_ptr_conv.inner = untag_ptr(this_ptr);
42446         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42448         this_ptr_conv.is_owned = false;
42449         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42450         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
42451         return ret_arr;
42452 }
42453
42454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42455         LDKTxCreationKeys this_ptr_conv;
42456         this_ptr_conv.inner = untag_ptr(this_ptr);
42457         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42459         this_ptr_conv.is_owned = false;
42460         LDKPublicKey val_ref;
42461         CHECK((*env)->GetArrayLength(env, val) == 33);
42462         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42463         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
42464 }
42465
42466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42467         LDKTxCreationKeys this_ptr_conv;
42468         this_ptr_conv.inner = untag_ptr(this_ptr);
42469         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42471         this_ptr_conv.is_owned = false;
42472         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42473         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
42474         return ret_arr;
42475 }
42476
42477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42478         LDKTxCreationKeys this_ptr_conv;
42479         this_ptr_conv.inner = untag_ptr(this_ptr);
42480         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42482         this_ptr_conv.is_owned = false;
42483         LDKPublicKey val_ref;
42484         CHECK((*env)->GetArrayLength(env, val) == 33);
42485         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42486         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
42487 }
42488
42489 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
42490         LDKTxCreationKeys this_ptr_conv;
42491         this_ptr_conv.inner = untag_ptr(this_ptr);
42492         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42494         this_ptr_conv.is_owned = false;
42495         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42496         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
42497         return ret_arr;
42498 }
42499
42500 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) {
42501         LDKTxCreationKeys this_ptr_conv;
42502         this_ptr_conv.inner = untag_ptr(this_ptr);
42503         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42505         this_ptr_conv.is_owned = false;
42506         LDKPublicKey val_ref;
42507         CHECK((*env)->GetArrayLength(env, val) == 33);
42508         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42509         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
42510 }
42511
42512 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) {
42513         LDKPublicKey per_commitment_point_arg_ref;
42514         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
42515         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
42516         LDKPublicKey revocation_key_arg_ref;
42517         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
42518         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
42519         LDKPublicKey broadcaster_htlc_key_arg_ref;
42520         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
42521         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
42522         LDKPublicKey countersignatory_htlc_key_arg_ref;
42523         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
42524         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
42525         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
42526         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
42527         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
42528         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);
42529         int64_t ret_ref = 0;
42530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42531         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42532         return ret_ref;
42533 }
42534
42535 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42536         LDKTxCreationKeys a_conv;
42537         a_conv.inner = untag_ptr(a);
42538         a_conv.is_owned = ptr_is_owned(a);
42539         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42540         a_conv.is_owned = false;
42541         LDKTxCreationKeys b_conv;
42542         b_conv.inner = untag_ptr(b);
42543         b_conv.is_owned = ptr_is_owned(b);
42544         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42545         b_conv.is_owned = false;
42546         jboolean ret_conv = TxCreationKeys_eq(&a_conv, &b_conv);
42547         return ret_conv;
42548 }
42549
42550 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
42551         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
42552         int64_t ret_ref = 0;
42553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42554         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42555         return ret_ref;
42556 }
42557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42558         LDKTxCreationKeys arg_conv;
42559         arg_conv.inner = untag_ptr(arg);
42560         arg_conv.is_owned = ptr_is_owned(arg);
42561         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42562         arg_conv.is_owned = false;
42563         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
42564         return ret_conv;
42565 }
42566
42567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42568         LDKTxCreationKeys orig_conv;
42569         orig_conv.inner = untag_ptr(orig);
42570         orig_conv.is_owned = ptr_is_owned(orig);
42571         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42572         orig_conv.is_owned = false;
42573         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
42574         int64_t ret_ref = 0;
42575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42576         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42577         return ret_ref;
42578 }
42579
42580 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
42581         LDKTxCreationKeys obj_conv;
42582         obj_conv.inner = untag_ptr(obj);
42583         obj_conv.is_owned = ptr_is_owned(obj);
42584         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42585         obj_conv.is_owned = false;
42586         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
42587         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42588         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42589         CVec_u8Z_free(ret_var);
42590         return ret_arr;
42591 }
42592
42593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42594         LDKu8slice ser_ref;
42595         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42596         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42597         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
42598         *ret_conv = TxCreationKeys_read(ser_ref);
42599         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42600         return tag_ptr(ret_conv, true);
42601 }
42602
42603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42604         LDKChannelPublicKeys this_obj_conv;
42605         this_obj_conv.inner = untag_ptr(this_obj);
42606         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42608         ChannelPublicKeys_free(this_obj_conv);
42609 }
42610
42611 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
42612         LDKChannelPublicKeys this_ptr_conv;
42613         this_ptr_conv.inner = untag_ptr(this_ptr);
42614         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42616         this_ptr_conv.is_owned = false;
42617         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42618         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
42619         return ret_arr;
42620 }
42621
42622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42623         LDKChannelPublicKeys this_ptr_conv;
42624         this_ptr_conv.inner = untag_ptr(this_ptr);
42625         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42627         this_ptr_conv.is_owned = false;
42628         LDKPublicKey val_ref;
42629         CHECK((*env)->GetArrayLength(env, val) == 33);
42630         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42631         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
42632 }
42633
42634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42635         LDKChannelPublicKeys this_ptr_conv;
42636         this_ptr_conv.inner = untag_ptr(this_ptr);
42637         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42639         this_ptr_conv.is_owned = false;
42640         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42641         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
42642         return ret_arr;
42643 }
42644
42645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42646         LDKChannelPublicKeys this_ptr_conv;
42647         this_ptr_conv.inner = untag_ptr(this_ptr);
42648         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42650         this_ptr_conv.is_owned = false;
42651         LDKPublicKey val_ref;
42652         CHECK((*env)->GetArrayLength(env, val) == 33);
42653         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42654         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
42655 }
42656
42657 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
42658         LDKChannelPublicKeys this_ptr_conv;
42659         this_ptr_conv.inner = untag_ptr(this_ptr);
42660         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42662         this_ptr_conv.is_owned = false;
42663         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42664         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
42665         return ret_arr;
42666 }
42667
42668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42669         LDKChannelPublicKeys this_ptr_conv;
42670         this_ptr_conv.inner = untag_ptr(this_ptr);
42671         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42673         this_ptr_conv.is_owned = false;
42674         LDKPublicKey val_ref;
42675         CHECK((*env)->GetArrayLength(env, val) == 33);
42676         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42677         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
42678 }
42679
42680 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42681         LDKChannelPublicKeys this_ptr_conv;
42682         this_ptr_conv.inner = untag_ptr(this_ptr);
42683         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42685         this_ptr_conv.is_owned = false;
42686         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42687         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
42688         return ret_arr;
42689 }
42690
42691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42692         LDKChannelPublicKeys this_ptr_conv;
42693         this_ptr_conv.inner = untag_ptr(this_ptr);
42694         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42696         this_ptr_conv.is_owned = false;
42697         LDKPublicKey val_ref;
42698         CHECK((*env)->GetArrayLength(env, val) == 33);
42699         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42700         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
42701 }
42702
42703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42704         LDKChannelPublicKeys this_ptr_conv;
42705         this_ptr_conv.inner = untag_ptr(this_ptr);
42706         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42708         this_ptr_conv.is_owned = false;
42709         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42710         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
42711         return ret_arr;
42712 }
42713
42714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42715         LDKChannelPublicKeys this_ptr_conv;
42716         this_ptr_conv.inner = untag_ptr(this_ptr);
42717         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42719         this_ptr_conv.is_owned = false;
42720         LDKPublicKey val_ref;
42721         CHECK((*env)->GetArrayLength(env, val) == 33);
42722         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42723         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
42724 }
42725
42726 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) {
42727         LDKPublicKey funding_pubkey_arg_ref;
42728         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
42729         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
42730         LDKPublicKey revocation_basepoint_arg_ref;
42731         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
42732         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
42733         LDKPublicKey payment_point_arg_ref;
42734         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
42735         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
42736         LDKPublicKey delayed_payment_basepoint_arg_ref;
42737         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
42738         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
42739         LDKPublicKey htlc_basepoint_arg_ref;
42740         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
42741         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
42742         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);
42743         int64_t ret_ref = 0;
42744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42745         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42746         return ret_ref;
42747 }
42748
42749 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
42750         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
42751         int64_t ret_ref = 0;
42752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42753         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42754         return ret_ref;
42755 }
42756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42757         LDKChannelPublicKeys arg_conv;
42758         arg_conv.inner = untag_ptr(arg);
42759         arg_conv.is_owned = ptr_is_owned(arg);
42760         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42761         arg_conv.is_owned = false;
42762         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
42763         return ret_conv;
42764 }
42765
42766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42767         LDKChannelPublicKeys orig_conv;
42768         orig_conv.inner = untag_ptr(orig);
42769         orig_conv.is_owned = ptr_is_owned(orig);
42770         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42771         orig_conv.is_owned = false;
42772         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
42773         int64_t ret_ref = 0;
42774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42775         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42776         return ret_ref;
42777 }
42778
42779 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42780         LDKChannelPublicKeys a_conv;
42781         a_conv.inner = untag_ptr(a);
42782         a_conv.is_owned = ptr_is_owned(a);
42783         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42784         a_conv.is_owned = false;
42785         LDKChannelPublicKeys b_conv;
42786         b_conv.inner = untag_ptr(b);
42787         b_conv.is_owned = ptr_is_owned(b);
42788         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42789         b_conv.is_owned = false;
42790         jboolean ret_conv = ChannelPublicKeys_eq(&a_conv, &b_conv);
42791         return ret_conv;
42792 }
42793
42794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
42795         LDKChannelPublicKeys obj_conv;
42796         obj_conv.inner = untag_ptr(obj);
42797         obj_conv.is_owned = ptr_is_owned(obj);
42798         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42799         obj_conv.is_owned = false;
42800         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
42801         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42802         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42803         CVec_u8Z_free(ret_var);
42804         return ret_arr;
42805 }
42806
42807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42808         LDKu8slice ser_ref;
42809         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42810         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42811         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
42812         *ret_conv = ChannelPublicKeys_read(ser_ref);
42813         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42814         return tag_ptr(ret_conv, true);
42815 }
42816
42817 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) {
42818         LDKPublicKey per_commitment_point_ref;
42819         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42820         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42821         LDKPublicKey broadcaster_delayed_payment_base_ref;
42822         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
42823         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
42824         LDKPublicKey broadcaster_htlc_base_ref;
42825         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
42826         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
42827         LDKPublicKey countersignatory_revocation_base_ref;
42828         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
42829         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
42830         LDKPublicKey countersignatory_htlc_base_ref;
42831         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
42832         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
42833         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);
42834         int64_t ret_ref = 0;
42835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42836         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42837         return ret_ref;
42838 }
42839
42840 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) {
42841         LDKPublicKey per_commitment_point_ref;
42842         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42843         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42844         LDKChannelPublicKeys broadcaster_keys_conv;
42845         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
42846         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
42847         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
42848         broadcaster_keys_conv.is_owned = false;
42849         LDKChannelPublicKeys countersignatory_keys_conv;
42850         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
42851         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
42852         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
42853         countersignatory_keys_conv.is_owned = false;
42854         LDKTxCreationKeys ret_var = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
42855         int64_t ret_ref = 0;
42856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42857         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42858         return ret_ref;
42859 }
42860
42861 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) {
42862         LDKPublicKey revocation_key_ref;
42863         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
42864         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
42865         LDKPublicKey broadcaster_delayed_payment_key_ref;
42866         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
42867         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
42868         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
42869         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42870         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42871         CVec_u8Z_free(ret_var);
42872         return ret_arr;
42873 }
42874
42875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42876         LDKHTLCOutputInCommitment this_obj_conv;
42877         this_obj_conv.inner = untag_ptr(this_obj);
42878         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42880         HTLCOutputInCommitment_free(this_obj_conv);
42881 }
42882
42883 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
42884         LDKHTLCOutputInCommitment this_ptr_conv;
42885         this_ptr_conv.inner = untag_ptr(this_ptr);
42886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42888         this_ptr_conv.is_owned = false;
42889         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
42890         return ret_conv;
42891 }
42892
42893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
42894         LDKHTLCOutputInCommitment this_ptr_conv;
42895         this_ptr_conv.inner = untag_ptr(this_ptr);
42896         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42898         this_ptr_conv.is_owned = false;
42899         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
42900 }
42901
42902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42903         LDKHTLCOutputInCommitment this_ptr_conv;
42904         this_ptr_conv.inner = untag_ptr(this_ptr);
42905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42907         this_ptr_conv.is_owned = false;
42908         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
42909         return ret_conv;
42910 }
42911
42912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42913         LDKHTLCOutputInCommitment this_ptr_conv;
42914         this_ptr_conv.inner = untag_ptr(this_ptr);
42915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42917         this_ptr_conv.is_owned = false;
42918         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
42919 }
42920
42921 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
42922         LDKHTLCOutputInCommitment this_ptr_conv;
42923         this_ptr_conv.inner = untag_ptr(this_ptr);
42924         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42926         this_ptr_conv.is_owned = false;
42927         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
42928         return ret_conv;
42929 }
42930
42931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42932         LDKHTLCOutputInCommitment this_ptr_conv;
42933         this_ptr_conv.inner = untag_ptr(this_ptr);
42934         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42936         this_ptr_conv.is_owned = false;
42937         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
42938 }
42939
42940 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
42941         LDKHTLCOutputInCommitment this_ptr_conv;
42942         this_ptr_conv.inner = untag_ptr(this_ptr);
42943         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42945         this_ptr_conv.is_owned = false;
42946         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42947         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
42948         return ret_arr;
42949 }
42950
42951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKThirtyTwoBytes val_ref;
42958         CHECK((*env)->GetArrayLength(env, val) == 32);
42959         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
42960         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
42961 }
42962
42963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
42964         LDKHTLCOutputInCommitment this_ptr_conv;
42965         this_ptr_conv.inner = untag_ptr(this_ptr);
42966         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42968         this_ptr_conv.is_owned = false;
42969         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
42970         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
42971         int64_t ret_ref = tag_ptr(ret_copy, true);
42972         return ret_ref;
42973 }
42974
42975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42976         LDKHTLCOutputInCommitment this_ptr_conv;
42977         this_ptr_conv.inner = untag_ptr(this_ptr);
42978         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42980         this_ptr_conv.is_owned = false;
42981         void* val_ptr = untag_ptr(val);
42982         CHECK_ACCESS(val_ptr);
42983         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
42984         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
42985         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
42986 }
42987
42988 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) {
42989         LDKThirtyTwoBytes payment_hash_arg_ref;
42990         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
42991         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
42992         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
42993         CHECK_ACCESS(transaction_output_index_arg_ptr);
42994         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
42995         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
42996         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
42997         int64_t ret_ref = 0;
42998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42999         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43000         return ret_ref;
43001 }
43002
43003 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
43004         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
43005         int64_t ret_ref = 0;
43006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43007         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43008         return ret_ref;
43009 }
43010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43011         LDKHTLCOutputInCommitment arg_conv;
43012         arg_conv.inner = untag_ptr(arg);
43013         arg_conv.is_owned = ptr_is_owned(arg);
43014         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43015         arg_conv.is_owned = false;
43016         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
43017         return ret_conv;
43018 }
43019
43020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43021         LDKHTLCOutputInCommitment orig_conv;
43022         orig_conv.inner = untag_ptr(orig);
43023         orig_conv.is_owned = ptr_is_owned(orig);
43024         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43025         orig_conv.is_owned = false;
43026         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
43027         int64_t ret_ref = 0;
43028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43029         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43030         return ret_ref;
43031 }
43032
43033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43034         LDKHTLCOutputInCommitment a_conv;
43035         a_conv.inner = untag_ptr(a);
43036         a_conv.is_owned = ptr_is_owned(a);
43037         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43038         a_conv.is_owned = false;
43039         LDKHTLCOutputInCommitment b_conv;
43040         b_conv.inner = untag_ptr(b);
43041         b_conv.is_owned = ptr_is_owned(b);
43042         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43043         b_conv.is_owned = false;
43044         jboolean ret_conv = HTLCOutputInCommitment_eq(&a_conv, &b_conv);
43045         return ret_conv;
43046 }
43047
43048 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
43049         LDKHTLCOutputInCommitment obj_conv;
43050         obj_conv.inner = untag_ptr(obj);
43051         obj_conv.is_owned = ptr_is_owned(obj);
43052         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43053         obj_conv.is_owned = false;
43054         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
43055         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43056         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43057         CVec_u8Z_free(ret_var);
43058         return ret_arr;
43059 }
43060
43061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43062         LDKu8slice ser_ref;
43063         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43064         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43065         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
43066         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
43067         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43068         return tag_ptr(ret_conv, true);
43069 }
43070
43071 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) {
43072         LDKHTLCOutputInCommitment htlc_conv;
43073         htlc_conv.inner = untag_ptr(htlc);
43074         htlc_conv.is_owned = ptr_is_owned(htlc);
43075         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
43076         htlc_conv.is_owned = false;
43077         LDKTxCreationKeys keys_conv;
43078         keys_conv.inner = untag_ptr(keys);
43079         keys_conv.is_owned = ptr_is_owned(keys);
43080         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
43081         keys_conv.is_owned = false;
43082         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
43083         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43084         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43085         CVec_u8Z_free(ret_var);
43086         return ret_arr;
43087 }
43088
43089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
43090         LDKPublicKey broadcaster_ref;
43091         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
43092         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
43093         LDKPublicKey countersignatory_ref;
43094         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
43095         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
43096         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
43097         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43098         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43099         CVec_u8Z_free(ret_var);
43100         return ret_arr;
43101 }
43102
43103 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) {
43104         uint8_t commitment_txid_arr[32];
43105         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
43106         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
43107         uint8_t (*commitment_txid_ref)[32] = &commitment_txid_arr;
43108         LDKHTLCOutputInCommitment htlc_conv;
43109         htlc_conv.inner = untag_ptr(htlc);
43110         htlc_conv.is_owned = ptr_is_owned(htlc);
43111         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
43112         htlc_conv.is_owned = false;
43113         LDKPublicKey broadcaster_delayed_payment_key_ref;
43114         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
43115         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
43116         LDKPublicKey revocation_key_ref;
43117         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
43118         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
43119         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);
43120         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43121         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43122         Transaction_free(ret_var);
43123         return ret_arr;
43124 }
43125
43126 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) {
43127         LDKSignature local_sig_ref;
43128         CHECK((*env)->GetArrayLength(env, local_sig) == 64);
43129         (*env)->GetByteArrayRegion(env, local_sig, 0, 64, local_sig_ref.compact_form);
43130         LDKSignature remote_sig_ref;
43131         CHECK((*env)->GetArrayLength(env, remote_sig) == 64);
43132         (*env)->GetByteArrayRegion(env, remote_sig, 0, 64, remote_sig_ref.compact_form);
43133         LDKThirtyTwoBytes preimage_ref;
43134         CHECK((*env)->GetArrayLength(env, preimage) == 32);
43135         (*env)->GetByteArrayRegion(env, preimage, 0, 32, preimage_ref.data);
43136         LDKu8slice redeem_script_ref;
43137         redeem_script_ref.datalen = (*env)->GetArrayLength(env, redeem_script);
43138         redeem_script_ref.data = (*env)->GetByteArrayElements (env, redeem_script, NULL);
43139         LDKWitness ret_var = build_htlc_input_witness(local_sig_ref, remote_sig_ref, preimage_ref, redeem_script_ref, opt_anchors);
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         Witness_free(ret_var);
43143         (*env)->ReleaseByteArrayElements(env, redeem_script, (int8_t*)redeem_script_ref.data, 0);
43144         return ret_arr;
43145 }
43146
43147 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1to_1countersignatory_1with_1anchors_1redeemscript(JNIEnv *env, jclass clz, int8_tArray payment_point) {
43148         LDKPublicKey payment_point_ref;
43149         CHECK((*env)->GetArrayLength(env, payment_point) == 33);
43150         (*env)->GetByteArrayRegion(env, payment_point, 0, 33, payment_point_ref.compressed_form);
43151         LDKCVec_u8Z ret_var = get_to_countersignatory_with_anchors_redeemscript(payment_point_ref);
43152         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43153         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43154         CVec_u8Z_free(ret_var);
43155         return ret_arr;
43156 }
43157
43158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
43159         LDKPublicKey funding_pubkey_ref;
43160         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
43161         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
43162         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
43163         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43164         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43165         CVec_u8Z_free(ret_var);
43166         return ret_arr;
43167 }
43168
43169 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) {
43170         LDKPublicKey funding_key_ref;
43171         CHECK((*env)->GetArrayLength(env, funding_key) == 33);
43172         (*env)->GetByteArrayRegion(env, funding_key, 0, 33, funding_key_ref.compressed_form);
43173         LDKSignature funding_sig_ref;
43174         CHECK((*env)->GetArrayLength(env, funding_sig) == 64);
43175         (*env)->GetByteArrayRegion(env, funding_sig, 0, 64, funding_sig_ref.compact_form);
43176         LDKWitness ret_var = build_anchor_input_witness(funding_key_ref, funding_sig_ref);
43177         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43178         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43179         Witness_free(ret_var);
43180         return ret_arr;
43181 }
43182
43183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43184         LDKChannelTransactionParameters this_obj_conv;
43185         this_obj_conv.inner = untag_ptr(this_obj);
43186         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43188         ChannelTransactionParameters_free(this_obj_conv);
43189 }
43190
43191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
43192         LDKChannelTransactionParameters this_ptr_conv;
43193         this_ptr_conv.inner = untag_ptr(this_ptr);
43194         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43196         this_ptr_conv.is_owned = false;
43197         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
43198         int64_t ret_ref = 0;
43199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43200         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43201         return ret_ref;
43202 }
43203
43204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43205         LDKChannelTransactionParameters this_ptr_conv;
43206         this_ptr_conv.inner = untag_ptr(this_ptr);
43207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43209         this_ptr_conv.is_owned = false;
43210         LDKChannelPublicKeys val_conv;
43211         val_conv.inner = untag_ptr(val);
43212         val_conv.is_owned = ptr_is_owned(val);
43213         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43214         val_conv = ChannelPublicKeys_clone(&val_conv);
43215         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
43216 }
43217
43218 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
43219         LDKChannelTransactionParameters this_ptr_conv;
43220         this_ptr_conv.inner = untag_ptr(this_ptr);
43221         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43223         this_ptr_conv.is_owned = false;
43224         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
43225         return ret_conv;
43226 }
43227
43228 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) {
43229         LDKChannelTransactionParameters this_ptr_conv;
43230         this_ptr_conv.inner = untag_ptr(this_ptr);
43231         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43233         this_ptr_conv.is_owned = false;
43234         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
43235 }
43236
43237 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
43238         LDKChannelTransactionParameters this_ptr_conv;
43239         this_ptr_conv.inner = untag_ptr(this_ptr);
43240         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43242         this_ptr_conv.is_owned = false;
43243         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
43244         return ret_conv;
43245 }
43246
43247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
43248         LDKChannelTransactionParameters this_ptr_conv;
43249         this_ptr_conv.inner = untag_ptr(this_ptr);
43250         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43252         this_ptr_conv.is_owned = false;
43253         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
43254 }
43255
43256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
43257         LDKChannelTransactionParameters this_ptr_conv;
43258         this_ptr_conv.inner = untag_ptr(this_ptr);
43259         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43261         this_ptr_conv.is_owned = false;
43262         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
43263         int64_t ret_ref = 0;
43264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43265         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43266         return ret_ref;
43267 }
43268
43269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43270         LDKChannelTransactionParameters this_ptr_conv;
43271         this_ptr_conv.inner = untag_ptr(this_ptr);
43272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43274         this_ptr_conv.is_owned = false;
43275         LDKCounterpartyChannelTransactionParameters val_conv;
43276         val_conv.inner = untag_ptr(val);
43277         val_conv.is_owned = ptr_is_owned(val);
43278         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43279         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
43280         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
43281 }
43282
43283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
43284         LDKChannelTransactionParameters this_ptr_conv;
43285         this_ptr_conv.inner = untag_ptr(this_ptr);
43286         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43288         this_ptr_conv.is_owned = false;
43289         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
43290         int64_t ret_ref = 0;
43291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43292         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43293         return ret_ref;
43294 }
43295
43296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43297         LDKChannelTransactionParameters this_ptr_conv;
43298         this_ptr_conv.inner = untag_ptr(this_ptr);
43299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43301         this_ptr_conv.is_owned = false;
43302         LDKOutPoint val_conv;
43303         val_conv.inner = untag_ptr(val);
43304         val_conv.is_owned = ptr_is_owned(val);
43305         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43306         val_conv = OutPoint_clone(&val_conv);
43307         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
43308 }
43309
43310 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
43311         LDKChannelTransactionParameters this_ptr_conv;
43312         this_ptr_conv.inner = untag_ptr(this_ptr);
43313         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43315         this_ptr_conv.is_owned = false;
43316         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
43317         return ret_conv;
43318 }
43319
43320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
43321         LDKChannelTransactionParameters this_ptr_conv;
43322         this_ptr_conv.inner = untag_ptr(this_ptr);
43323         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43325         this_ptr_conv.is_owned = false;
43326         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
43327         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
43328 }
43329
43330 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1non_1zero_1fee_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_non_zero_fee_anchors(&this_ptr_conv));
43337         return ret_conv;
43338 }
43339
43340 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) {
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_non_zero_fee_anchors(&this_ptr_conv, val_conv);
43348 }
43349
43350 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) {
43351         LDKChannelPublicKeys holder_pubkeys_arg_conv;
43352         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
43353         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
43354         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
43355         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
43356         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
43357         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
43358         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
43359         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
43360         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
43361         LDKOutPoint funding_outpoint_arg_conv;
43362         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
43363         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
43364         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
43365         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
43366         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
43367         LDKCOption_NoneZ opt_non_zero_fee_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_non_zero_fee_anchors_arg);
43368         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);
43369         int64_t ret_ref = 0;
43370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43371         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43372         return ret_ref;
43373 }
43374
43375 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
43376         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
43377         int64_t ret_ref = 0;
43378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43379         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43380         return ret_ref;
43381 }
43382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43383         LDKChannelTransactionParameters arg_conv;
43384         arg_conv.inner = untag_ptr(arg);
43385         arg_conv.is_owned = ptr_is_owned(arg);
43386         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43387         arg_conv.is_owned = false;
43388         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
43389         return ret_conv;
43390 }
43391
43392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43393         LDKChannelTransactionParameters orig_conv;
43394         orig_conv.inner = untag_ptr(orig);
43395         orig_conv.is_owned = ptr_is_owned(orig);
43396         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43397         orig_conv.is_owned = false;
43398         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
43399         int64_t ret_ref = 0;
43400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43401         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43402         return ret_ref;
43403 }
43404
43405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43406         LDKChannelTransactionParameters a_conv;
43407         a_conv.inner = untag_ptr(a);
43408         a_conv.is_owned = ptr_is_owned(a);
43409         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43410         a_conv.is_owned = false;
43411         LDKChannelTransactionParameters b_conv;
43412         b_conv.inner = untag_ptr(b);
43413         b_conv.is_owned = ptr_is_owned(b);
43414         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43415         b_conv.is_owned = false;
43416         jboolean ret_conv = ChannelTransactionParameters_eq(&a_conv, &b_conv);
43417         return ret_conv;
43418 }
43419
43420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43421         LDKCounterpartyChannelTransactionParameters this_obj_conv;
43422         this_obj_conv.inner = untag_ptr(this_obj);
43423         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43425         CounterpartyChannelTransactionParameters_free(this_obj_conv);
43426 }
43427
43428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
43429         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43430         this_ptr_conv.inner = untag_ptr(this_ptr);
43431         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43433         this_ptr_conv.is_owned = false;
43434         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
43435         int64_t ret_ref = 0;
43436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43437         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43438         return ret_ref;
43439 }
43440
43441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43442         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43443         this_ptr_conv.inner = untag_ptr(this_ptr);
43444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43446         this_ptr_conv.is_owned = false;
43447         LDKChannelPublicKeys val_conv;
43448         val_conv.inner = untag_ptr(val);
43449         val_conv.is_owned = ptr_is_owned(val);
43450         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43451         val_conv = ChannelPublicKeys_clone(&val_conv);
43452         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
43453 }
43454
43455 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
43456         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43457         this_ptr_conv.inner = untag_ptr(this_ptr);
43458         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43460         this_ptr_conv.is_owned = false;
43461         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
43462         return ret_conv;
43463 }
43464
43465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
43466         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
43467         this_ptr_conv.inner = untag_ptr(this_ptr);
43468         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43470         this_ptr_conv.is_owned = false;
43471         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
43472 }
43473
43474 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) {
43475         LDKChannelPublicKeys pubkeys_arg_conv;
43476         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
43477         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
43478         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
43479         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
43480         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
43481         int64_t ret_ref = 0;
43482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43483         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43484         return ret_ref;
43485 }
43486
43487 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
43488         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
43489         int64_t ret_ref = 0;
43490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43491         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43492         return ret_ref;
43493 }
43494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43495         LDKCounterpartyChannelTransactionParameters arg_conv;
43496         arg_conv.inner = untag_ptr(arg);
43497         arg_conv.is_owned = ptr_is_owned(arg);
43498         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43499         arg_conv.is_owned = false;
43500         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
43501         return ret_conv;
43502 }
43503
43504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43505         LDKCounterpartyChannelTransactionParameters orig_conv;
43506         orig_conv.inner = untag_ptr(orig);
43507         orig_conv.is_owned = ptr_is_owned(orig);
43508         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43509         orig_conv.is_owned = false;
43510         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
43511         int64_t ret_ref = 0;
43512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43513         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43514         return ret_ref;
43515 }
43516
43517 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43518         LDKCounterpartyChannelTransactionParameters a_conv;
43519         a_conv.inner = untag_ptr(a);
43520         a_conv.is_owned = ptr_is_owned(a);
43521         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43522         a_conv.is_owned = false;
43523         LDKCounterpartyChannelTransactionParameters b_conv;
43524         b_conv.inner = untag_ptr(b);
43525         b_conv.is_owned = ptr_is_owned(b);
43526         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43527         b_conv.is_owned = false;
43528         jboolean ret_conv = CounterpartyChannelTransactionParameters_eq(&a_conv, &b_conv);
43529         return ret_conv;
43530 }
43531
43532 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
43533         LDKChannelTransactionParameters this_arg_conv;
43534         this_arg_conv.inner = untag_ptr(this_arg);
43535         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43537         this_arg_conv.is_owned = false;
43538         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
43539         return ret_conv;
43540 }
43541
43542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
43543         LDKChannelTransactionParameters this_arg_conv;
43544         this_arg_conv.inner = untag_ptr(this_arg);
43545         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43547         this_arg_conv.is_owned = false;
43548         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
43549         int64_t ret_ref = 0;
43550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43552         return ret_ref;
43553 }
43554
43555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
43556         LDKChannelTransactionParameters this_arg_conv;
43557         this_arg_conv.inner = untag_ptr(this_arg);
43558         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43560         this_arg_conv.is_owned = false;
43561         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
43562         int64_t ret_ref = 0;
43563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43564         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43565         return ret_ref;
43566 }
43567
43568 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43569         LDKCounterpartyChannelTransactionParameters obj_conv;
43570         obj_conv.inner = untag_ptr(obj);
43571         obj_conv.is_owned = ptr_is_owned(obj);
43572         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43573         obj_conv.is_owned = false;
43574         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
43575         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43576         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43577         CVec_u8Z_free(ret_var);
43578         return ret_arr;
43579 }
43580
43581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43582         LDKu8slice ser_ref;
43583         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43584         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43585         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
43586         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
43587         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43588         return tag_ptr(ret_conv, true);
43589 }
43590
43591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43592         LDKChannelTransactionParameters obj_conv;
43593         obj_conv.inner = untag_ptr(obj);
43594         obj_conv.is_owned = ptr_is_owned(obj);
43595         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43596         obj_conv.is_owned = false;
43597         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
43598         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43599         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43600         CVec_u8Z_free(ret_var);
43601         return ret_arr;
43602 }
43603
43604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43605         LDKu8slice ser_ref;
43606         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43607         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43608         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
43609         *ret_conv = ChannelTransactionParameters_read(ser_ref);
43610         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43611         return tag_ptr(ret_conv, true);
43612 }
43613
43614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43615         LDKDirectedChannelTransactionParameters this_obj_conv;
43616         this_obj_conv.inner = untag_ptr(this_obj);
43617         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43619         DirectedChannelTransactionParameters_free(this_obj_conv);
43620 }
43621
43622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
43623         LDKDirectedChannelTransactionParameters this_arg_conv;
43624         this_arg_conv.inner = untag_ptr(this_arg);
43625         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43627         this_arg_conv.is_owned = false;
43628         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
43629         int64_t ret_ref = 0;
43630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43631         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43632         return ret_ref;
43633 }
43634
43635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
43636         LDKDirectedChannelTransactionParameters this_arg_conv;
43637         this_arg_conv.inner = untag_ptr(this_arg);
43638         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43640         this_arg_conv.is_owned = false;
43641         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
43642         int64_t ret_ref = 0;
43643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43644         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43645         return ret_ref;
43646 }
43647
43648 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
43649         LDKDirectedChannelTransactionParameters this_arg_conv;
43650         this_arg_conv.inner = untag_ptr(this_arg);
43651         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43653         this_arg_conv.is_owned = false;
43654         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
43655         return ret_conv;
43656 }
43657
43658 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
43659         LDKDirectedChannelTransactionParameters this_arg_conv;
43660         this_arg_conv.inner = untag_ptr(this_arg);
43661         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43663         this_arg_conv.is_owned = false;
43664         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
43665         return ret_conv;
43666 }
43667
43668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(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         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
43675         int64_t ret_ref = 0;
43676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43677         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43678         return ret_ref;
43679 }
43680
43681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
43682         LDKDirectedChannelTransactionParameters this_arg_conv;
43683         this_arg_conv.inner = untag_ptr(this_arg);
43684         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43686         this_arg_conv.is_owned = false;
43687         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
43688         return ret_conv;
43689 }
43690
43691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43692         LDKHolderCommitmentTransaction this_obj_conv;
43693         this_obj_conv.inner = untag_ptr(this_obj);
43694         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43696         HolderCommitmentTransaction_free(this_obj_conv);
43697 }
43698
43699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
43700         LDKHolderCommitmentTransaction this_ptr_conv;
43701         this_ptr_conv.inner = untag_ptr(this_ptr);
43702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43704         this_ptr_conv.is_owned = false;
43705         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
43706         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
43707         return ret_arr;
43708 }
43709
43710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43711         LDKHolderCommitmentTransaction this_ptr_conv;
43712         this_ptr_conv.inner = untag_ptr(this_ptr);
43713         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43715         this_ptr_conv.is_owned = false;
43716         LDKSignature val_ref;
43717         CHECK((*env)->GetArrayLength(env, val) == 64);
43718         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
43719         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
43720 }
43721
43722 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr) {
43723         LDKHolderCommitmentTransaction this_ptr_conv;
43724         this_ptr_conv.inner = untag_ptr(this_ptr);
43725         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43727         this_ptr_conv.is_owned = false;
43728         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
43729         jobjectArray ret_arr = NULL;
43730         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
43731         ;
43732         for (size_t i = 0; i < ret_var.datalen; i++) {
43733                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
43734                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
43735                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
43736         }
43737         
43738         FREE(ret_var.data);
43739         return ret_arr;
43740 }
43741
43742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
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 val_constr;
43749         val_constr.datalen = (*env)->GetArrayLength(env, val);
43750         if (val_constr.datalen > 0)
43751                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
43752         else
43753                 val_constr.data = NULL;
43754         for (size_t i = 0; i < val_constr.datalen; i++) {
43755                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
43756                 LDKSignature val_conv_8_ref;
43757                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
43758                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
43759                 val_constr.data[i] = val_conv_8_ref;
43760         }
43761         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
43762 }
43763
43764 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
43765         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
43766         int64_t ret_ref = 0;
43767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43768         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43769         return ret_ref;
43770 }
43771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43772         LDKHolderCommitmentTransaction arg_conv;
43773         arg_conv.inner = untag_ptr(arg);
43774         arg_conv.is_owned = ptr_is_owned(arg);
43775         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43776         arg_conv.is_owned = false;
43777         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
43778         return ret_conv;
43779 }
43780
43781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43782         LDKHolderCommitmentTransaction orig_conv;
43783         orig_conv.inner = untag_ptr(orig);
43784         orig_conv.is_owned = ptr_is_owned(orig);
43785         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43786         orig_conv.is_owned = false;
43787         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
43788         int64_t ret_ref = 0;
43789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43790         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43791         return ret_ref;
43792 }
43793
43794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43795         LDKHolderCommitmentTransaction obj_conv;
43796         obj_conv.inner = untag_ptr(obj);
43797         obj_conv.is_owned = ptr_is_owned(obj);
43798         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43799         obj_conv.is_owned = false;
43800         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
43801         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43802         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43803         CVec_u8Z_free(ret_var);
43804         return ret_arr;
43805 }
43806
43807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43808         LDKu8slice ser_ref;
43809         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43810         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43811         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
43812         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
43813         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43814         return tag_ptr(ret_conv, true);
43815 }
43816
43817 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) {
43818         LDKCommitmentTransaction commitment_tx_conv;
43819         commitment_tx_conv.inner = untag_ptr(commitment_tx);
43820         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
43821         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
43822         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
43823         LDKSignature counterparty_sig_ref;
43824         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
43825         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
43826         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
43827         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
43828         if (counterparty_htlc_sigs_constr.datalen > 0)
43829                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
43830         else
43831                 counterparty_htlc_sigs_constr.data = NULL;
43832         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
43833                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
43834                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
43835                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
43836                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
43837                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
43838         }
43839         LDKPublicKey holder_funding_key_ref;
43840         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
43841         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
43842         LDKPublicKey counterparty_funding_key_ref;
43843         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
43844         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
43845         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
43846         int64_t ret_ref = 0;
43847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43848         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43849         return ret_ref;
43850 }
43851
43852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43853         LDKBuiltCommitmentTransaction this_obj_conv;
43854         this_obj_conv.inner = untag_ptr(this_obj);
43855         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43857         BuiltCommitmentTransaction_free(this_obj_conv);
43858 }
43859
43860 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
43861         LDKBuiltCommitmentTransaction this_ptr_conv;
43862         this_ptr_conv.inner = untag_ptr(this_ptr);
43863         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43865         this_ptr_conv.is_owned = false;
43866         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
43867         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43868         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43869         Transaction_free(ret_var);
43870         return ret_arr;
43871 }
43872
43873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43874         LDKBuiltCommitmentTransaction this_ptr_conv;
43875         this_ptr_conv.inner = untag_ptr(this_ptr);
43876         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43878         this_ptr_conv.is_owned = false;
43879         LDKTransaction val_ref;
43880         val_ref.datalen = (*env)->GetArrayLength(env, val);
43881         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
43882         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
43883         val_ref.data_is_owned = true;
43884         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
43885 }
43886
43887 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
43888         LDKBuiltCommitmentTransaction this_ptr_conv;
43889         this_ptr_conv.inner = untag_ptr(this_ptr);
43890         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43892         this_ptr_conv.is_owned = false;
43893         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43894         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
43895         return ret_arr;
43896 }
43897
43898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43899         LDKBuiltCommitmentTransaction this_ptr_conv;
43900         this_ptr_conv.inner = untag_ptr(this_ptr);
43901         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43903         this_ptr_conv.is_owned = false;
43904         LDKThirtyTwoBytes val_ref;
43905         CHECK((*env)->GetArrayLength(env, val) == 32);
43906         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
43907         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
43908 }
43909
43910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
43911         LDKTransaction transaction_arg_ref;
43912         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
43913         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
43914         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
43915         transaction_arg_ref.data_is_owned = true;
43916         LDKThirtyTwoBytes txid_arg_ref;
43917         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
43918         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
43919         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
43920         int64_t ret_ref = 0;
43921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43922         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43923         return ret_ref;
43924 }
43925
43926 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
43927         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
43928         int64_t ret_ref = 0;
43929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43930         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43931         return ret_ref;
43932 }
43933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43934         LDKBuiltCommitmentTransaction arg_conv;
43935         arg_conv.inner = untag_ptr(arg);
43936         arg_conv.is_owned = ptr_is_owned(arg);
43937         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43938         arg_conv.is_owned = false;
43939         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
43940         return ret_conv;
43941 }
43942
43943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43944         LDKBuiltCommitmentTransaction orig_conv;
43945         orig_conv.inner = untag_ptr(orig);
43946         orig_conv.is_owned = ptr_is_owned(orig);
43947         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43948         orig_conv.is_owned = false;
43949         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
43950         int64_t ret_ref = 0;
43951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43952         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43953         return ret_ref;
43954 }
43955
43956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43957         LDKBuiltCommitmentTransaction obj_conv;
43958         obj_conv.inner = untag_ptr(obj);
43959         obj_conv.is_owned = ptr_is_owned(obj);
43960         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43961         obj_conv.is_owned = false;
43962         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
43963         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43964         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43965         CVec_u8Z_free(ret_var);
43966         return ret_arr;
43967 }
43968
43969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43970         LDKu8slice ser_ref;
43971         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43972         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43973         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
43974         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
43975         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43976         return tag_ptr(ret_conv, true);
43977 }
43978
43979 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) {
43980         LDKBuiltCommitmentTransaction this_arg_conv;
43981         this_arg_conv.inner = untag_ptr(this_arg);
43982         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43984         this_arg_conv.is_owned = false;
43985         LDKu8slice funding_redeemscript_ref;
43986         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
43987         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
43988         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43989         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
43990         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
43991         return ret_arr;
43992 }
43993
43994 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) {
43995         LDKBuiltCommitmentTransaction this_arg_conv;
43996         this_arg_conv.inner = untag_ptr(this_arg);
43997         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43999         this_arg_conv.is_owned = false;
44000         uint8_t funding_key_arr[32];
44001         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
44002         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
44003         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
44004         LDKu8slice funding_redeemscript_ref;
44005         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44006         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44007         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
44008         (*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);
44009         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44010         return ret_arr;
44011 }
44012
44013 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) {
44014         LDKBuiltCommitmentTransaction this_arg_conv;
44015         this_arg_conv.inner = untag_ptr(this_arg);
44016         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44018         this_arg_conv.is_owned = false;
44019         uint8_t funding_key_arr[32];
44020         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
44021         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
44022         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
44023         LDKu8slice funding_redeemscript_ref;
44024         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44025         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44026         void* entropy_source_ptr = untag_ptr(entropy_source);
44027         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
44028         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
44029         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
44030         (*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);
44031         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44032         return ret_arr;
44033 }
44034
44035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44036         LDKClosingTransaction this_obj_conv;
44037         this_obj_conv.inner = untag_ptr(this_obj);
44038         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44040         ClosingTransaction_free(this_obj_conv);
44041 }
44042
44043 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
44044         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
44045         int64_t ret_ref = 0;
44046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44047         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44048         return ret_ref;
44049 }
44050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44051         LDKClosingTransaction arg_conv;
44052         arg_conv.inner = untag_ptr(arg);
44053         arg_conv.is_owned = ptr_is_owned(arg);
44054         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44055         arg_conv.is_owned = false;
44056         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
44057         return ret_conv;
44058 }
44059
44060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44061         LDKClosingTransaction orig_conv;
44062         orig_conv.inner = untag_ptr(orig);
44063         orig_conv.is_owned = ptr_is_owned(orig);
44064         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44065         orig_conv.is_owned = false;
44066         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
44067         int64_t ret_ref = 0;
44068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44069         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44070         return ret_ref;
44071 }
44072
44073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
44074         LDKClosingTransaction o_conv;
44075         o_conv.inner = untag_ptr(o);
44076         o_conv.is_owned = ptr_is_owned(o);
44077         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44078         o_conv.is_owned = false;
44079         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
44080         return ret_conv;
44081 }
44082
44083 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44084         LDKClosingTransaction a_conv;
44085         a_conv.inner = untag_ptr(a);
44086         a_conv.is_owned = ptr_is_owned(a);
44087         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44088         a_conv.is_owned = false;
44089         LDKClosingTransaction b_conv;
44090         b_conv.inner = untag_ptr(b);
44091         b_conv.is_owned = ptr_is_owned(b);
44092         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44093         b_conv.is_owned = false;
44094         jboolean ret_conv = ClosingTransaction_eq(&a_conv, &b_conv);
44095         return ret_conv;
44096 }
44097
44098 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) {
44099         LDKCVec_u8Z to_holder_script_ref;
44100         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
44101         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
44102         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
44103         LDKCVec_u8Z to_counterparty_script_ref;
44104         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
44105         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
44106         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
44107         LDKOutPoint funding_outpoint_conv;
44108         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
44109         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
44110         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
44111         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
44112         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
44113         int64_t ret_ref = 0;
44114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44115         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44116         return ret_ref;
44117 }
44118
44119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
44120         LDKClosingTransaction this_arg_conv;
44121         this_arg_conv.inner = untag_ptr(this_arg);
44122         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44124         this_arg_conv.is_owned = false;
44125         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
44126         int64_t ret_ref = 0;
44127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44128         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44129         return ret_ref;
44130 }
44131
44132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
44133         LDKClosingTransaction this_arg_conv;
44134         this_arg_conv.inner = untag_ptr(this_arg);
44135         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44137         this_arg_conv.is_owned = false;
44138         LDKOutPoint funding_outpoint_conv;
44139         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
44140         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
44141         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
44142         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
44143         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
44144         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
44145         return tag_ptr(ret_conv, true);
44146 }
44147
44148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44149         LDKClosingTransaction this_arg_conv;
44150         this_arg_conv.inner = untag_ptr(this_arg);
44151         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44153         this_arg_conv.is_owned = false;
44154         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
44155         return ret_conv;
44156 }
44157
44158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44159         LDKClosingTransaction this_arg_conv;
44160         this_arg_conv.inner = untag_ptr(this_arg);
44161         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44163         this_arg_conv.is_owned = false;
44164         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
44165         return ret_conv;
44166 }
44167
44168 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(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         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
44175         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44176         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44177         return ret_arr;
44178 }
44179
44180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44181         LDKClosingTransaction this_arg_conv;
44182         this_arg_conv.inner = untag_ptr(this_arg);
44183         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44185         this_arg_conv.is_owned = false;
44186         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
44187         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44188         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44189         return ret_arr;
44190 }
44191
44192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44193         LDKTrustedClosingTransaction this_obj_conv;
44194         this_obj_conv.inner = untag_ptr(this_obj);
44195         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44197         TrustedClosingTransaction_free(this_obj_conv);
44198 }
44199
44200 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
44201         LDKTrustedClosingTransaction 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         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&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         Transaction_free(ret_var);
44210         return ret_arr;
44211 }
44212
44213 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) {
44214         LDKTrustedClosingTransaction this_arg_conv;
44215         this_arg_conv.inner = untag_ptr(this_arg);
44216         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44218         this_arg_conv.is_owned = false;
44219         LDKu8slice funding_redeemscript_ref;
44220         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44221         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44222         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44223         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
44224         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44225         return ret_arr;
44226 }
44227
44228 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) {
44229         LDKTrustedClosingTransaction this_arg_conv;
44230         this_arg_conv.inner = untag_ptr(this_arg);
44231         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44233         this_arg_conv.is_owned = false;
44234         uint8_t funding_key_arr[32];
44235         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
44236         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
44237         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
44238         LDKu8slice funding_redeemscript_ref;
44239         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
44240         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
44241         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
44242         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
44243         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
44244         return ret_arr;
44245 }
44246
44247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44248         LDKCommitmentTransaction this_obj_conv;
44249         this_obj_conv.inner = untag_ptr(this_obj);
44250         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44252         CommitmentTransaction_free(this_obj_conv);
44253 }
44254
44255 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
44256         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
44257         int64_t ret_ref = 0;
44258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44260         return ret_ref;
44261 }
44262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44263         LDKCommitmentTransaction arg_conv;
44264         arg_conv.inner = untag_ptr(arg);
44265         arg_conv.is_owned = ptr_is_owned(arg);
44266         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44267         arg_conv.is_owned = false;
44268         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
44269         return ret_conv;
44270 }
44271
44272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44273         LDKCommitmentTransaction orig_conv;
44274         orig_conv.inner = untag_ptr(orig);
44275         orig_conv.is_owned = ptr_is_owned(orig);
44276         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44277         orig_conv.is_owned = false;
44278         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
44279         int64_t ret_ref = 0;
44280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44281         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44282         return ret_ref;
44283 }
44284
44285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
44286         LDKCommitmentTransaction obj_conv;
44287         obj_conv.inner = untag_ptr(obj);
44288         obj_conv.is_owned = ptr_is_owned(obj);
44289         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44290         obj_conv.is_owned = false;
44291         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
44292         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44293         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44294         CVec_u8Z_free(ret_var);
44295         return ret_arr;
44296 }
44297
44298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44299         LDKu8slice ser_ref;
44300         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44301         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44302         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
44303         *ret_conv = CommitmentTransaction_read(ser_ref);
44304         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44305         return tag_ptr(ret_conv, true);
44306 }
44307
44308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
44309         LDKCommitmentTransaction this_arg_conv;
44310         this_arg_conv.inner = untag_ptr(this_arg);
44311         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44313         this_arg_conv.is_owned = false;
44314         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
44315         return ret_conv;
44316 }
44317
44318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
44319         LDKCommitmentTransaction this_arg_conv;
44320         this_arg_conv.inner = untag_ptr(this_arg);
44321         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44323         this_arg_conv.is_owned = false;
44324         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
44325         return ret_conv;
44326 }
44327
44328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(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_to_countersignatory_value_sat(&this_arg_conv);
44335         return ret_conv;
44336 }
44337
44338 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(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         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
44345         return ret_conv;
44346 }
44347
44348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(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         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
44355         int64_t ret_ref = 0;
44356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44358         return ret_ref;
44359 }
44360
44361 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) {
44362         LDKCommitmentTransaction this_arg_conv;
44363         this_arg_conv.inner = untag_ptr(this_arg);
44364         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44366         this_arg_conv.is_owned = false;
44367         LDKDirectedChannelTransactionParameters channel_parameters_conv;
44368         channel_parameters_conv.inner = untag_ptr(channel_parameters);
44369         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
44370         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
44371         channel_parameters_conv.is_owned = false;
44372         LDKChannelPublicKeys broadcaster_keys_conv;
44373         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
44374         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
44375         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
44376         broadcaster_keys_conv.is_owned = false;
44377         LDKChannelPublicKeys countersignatory_keys_conv;
44378         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
44379         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
44380         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
44381         countersignatory_keys_conv.is_owned = false;
44382         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
44383         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
44384         return tag_ptr(ret_conv, true);
44385 }
44386
44387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44388         LDKTrustedCommitmentTransaction this_obj_conv;
44389         this_obj_conv.inner = untag_ptr(this_obj);
44390         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44392         TrustedCommitmentTransaction_free(this_obj_conv);
44393 }
44394
44395 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
44396         LDKTrustedCommitmentTransaction this_arg_conv;
44397         this_arg_conv.inner = untag_ptr(this_arg);
44398         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44400         this_arg_conv.is_owned = false;
44401         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44402         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
44403         return ret_arr;
44404 }
44405
44406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
44407         LDKTrustedCommitmentTransaction this_arg_conv;
44408         this_arg_conv.inner = untag_ptr(this_arg);
44409         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44411         this_arg_conv.is_owned = false;
44412         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
44413         int64_t ret_ref = 0;
44414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44415         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44416         return ret_ref;
44417 }
44418
44419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
44420         LDKTrustedCommitmentTransaction this_arg_conv;
44421         this_arg_conv.inner = untag_ptr(this_arg);
44422         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44424         this_arg_conv.is_owned = false;
44425         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
44426         int64_t ret_ref = 0;
44427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44428         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44429         return ret_ref;
44430 }
44431
44432 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
44433         LDKTrustedCommitmentTransaction this_arg_conv;
44434         this_arg_conv.inner = untag_ptr(this_arg);
44435         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44437         this_arg_conv.is_owned = false;
44438         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
44439         return ret_conv;
44440 }
44441
44442 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) {
44443         LDKTrustedCommitmentTransaction this_arg_conv;
44444         this_arg_conv.inner = untag_ptr(this_arg);
44445         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44447         this_arg_conv.is_owned = false;
44448         uint8_t htlc_base_key_arr[32];
44449         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
44450         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
44451         uint8_t (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
44452         LDKDirectedChannelTransactionParameters channel_parameters_conv;
44453         channel_parameters_conv.inner = untag_ptr(channel_parameters);
44454         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
44455         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
44456         channel_parameters_conv.is_owned = false;
44457         void* entropy_source_ptr = untag_ptr(entropy_source);
44458         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
44459         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
44460         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
44461         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv, entropy_source_conv);
44462         return tag_ptr(ret_conv, true);
44463 }
44464
44465 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) {
44466         LDKPublicKey broadcaster_payment_basepoint_ref;
44467         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
44468         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
44469         LDKPublicKey countersignatory_payment_basepoint_ref;
44470         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
44471         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
44472         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
44473         return ret_conv;
44474 }
44475
44476 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44477         LDKInitFeatures a_conv;
44478         a_conv.inner = untag_ptr(a);
44479         a_conv.is_owned = ptr_is_owned(a);
44480         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44481         a_conv.is_owned = false;
44482         LDKInitFeatures b_conv;
44483         b_conv.inner = untag_ptr(b);
44484         b_conv.is_owned = ptr_is_owned(b);
44485         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44486         b_conv.is_owned = false;
44487         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
44488         return ret_conv;
44489 }
44490
44491 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44492         LDKNodeFeatures a_conv;
44493         a_conv.inner = untag_ptr(a);
44494         a_conv.is_owned = ptr_is_owned(a);
44495         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44496         a_conv.is_owned = false;
44497         LDKNodeFeatures b_conv;
44498         b_conv.inner = untag_ptr(b);
44499         b_conv.is_owned = ptr_is_owned(b);
44500         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44501         b_conv.is_owned = false;
44502         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
44503         return ret_conv;
44504 }
44505
44506 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44507         LDKChannelFeatures a_conv;
44508         a_conv.inner = untag_ptr(a);
44509         a_conv.is_owned = ptr_is_owned(a);
44510         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44511         a_conv.is_owned = false;
44512         LDKChannelFeatures b_conv;
44513         b_conv.inner = untag_ptr(b);
44514         b_conv.is_owned = ptr_is_owned(b);
44515         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44516         b_conv.is_owned = false;
44517         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
44518         return ret_conv;
44519 }
44520
44521 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44522         LDKInvoiceFeatures a_conv;
44523         a_conv.inner = untag_ptr(a);
44524         a_conv.is_owned = ptr_is_owned(a);
44525         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44526         a_conv.is_owned = false;
44527         LDKInvoiceFeatures b_conv;
44528         b_conv.inner = untag_ptr(b);
44529         b_conv.is_owned = ptr_is_owned(b);
44530         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44531         b_conv.is_owned = false;
44532         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
44533         return ret_conv;
44534 }
44535
44536 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44537         LDKOfferFeatures a_conv;
44538         a_conv.inner = untag_ptr(a);
44539         a_conv.is_owned = ptr_is_owned(a);
44540         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44541         a_conv.is_owned = false;
44542         LDKOfferFeatures b_conv;
44543         b_conv.inner = untag_ptr(b);
44544         b_conv.is_owned = ptr_is_owned(b);
44545         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44546         b_conv.is_owned = false;
44547         jboolean ret_conv = OfferFeatures_eq(&a_conv, &b_conv);
44548         return ret_conv;
44549 }
44550
44551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44552         LDKInvoiceRequestFeatures a_conv;
44553         a_conv.inner = untag_ptr(a);
44554         a_conv.is_owned = ptr_is_owned(a);
44555         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44556         a_conv.is_owned = false;
44557         LDKInvoiceRequestFeatures b_conv;
44558         b_conv.inner = untag_ptr(b);
44559         b_conv.is_owned = ptr_is_owned(b);
44560         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44561         b_conv.is_owned = false;
44562         jboolean ret_conv = InvoiceRequestFeatures_eq(&a_conv, &b_conv);
44563         return ret_conv;
44564 }
44565
44566 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44567         LDKBolt12InvoiceFeatures a_conv;
44568         a_conv.inner = untag_ptr(a);
44569         a_conv.is_owned = ptr_is_owned(a);
44570         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44571         a_conv.is_owned = false;
44572         LDKBolt12InvoiceFeatures b_conv;
44573         b_conv.inner = untag_ptr(b);
44574         b_conv.is_owned = ptr_is_owned(b);
44575         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44576         b_conv.is_owned = false;
44577         jboolean ret_conv = Bolt12InvoiceFeatures_eq(&a_conv, &b_conv);
44578         return ret_conv;
44579 }
44580
44581 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44582         LDKBlindedHopFeatures a_conv;
44583         a_conv.inner = untag_ptr(a);
44584         a_conv.is_owned = ptr_is_owned(a);
44585         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44586         a_conv.is_owned = false;
44587         LDKBlindedHopFeatures b_conv;
44588         b_conv.inner = untag_ptr(b);
44589         b_conv.is_owned = ptr_is_owned(b);
44590         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44591         b_conv.is_owned = false;
44592         jboolean ret_conv = BlindedHopFeatures_eq(&a_conv, &b_conv);
44593         return ret_conv;
44594 }
44595
44596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44597         LDKChannelTypeFeatures a_conv;
44598         a_conv.inner = untag_ptr(a);
44599         a_conv.is_owned = ptr_is_owned(a);
44600         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44601         a_conv.is_owned = false;
44602         LDKChannelTypeFeatures b_conv;
44603         b_conv.inner = untag_ptr(b);
44604         b_conv.is_owned = ptr_is_owned(b);
44605         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44606         b_conv.is_owned = false;
44607         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
44608         return ret_conv;
44609 }
44610
44611 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
44612         LDKInitFeatures ret_var = InitFeatures_clone(arg);
44613         int64_t ret_ref = 0;
44614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44615         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44616         return ret_ref;
44617 }
44618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44619         LDKInitFeatures arg_conv;
44620         arg_conv.inner = untag_ptr(arg);
44621         arg_conv.is_owned = ptr_is_owned(arg);
44622         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44623         arg_conv.is_owned = false;
44624         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
44625         return ret_conv;
44626 }
44627
44628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44629         LDKInitFeatures orig_conv;
44630         orig_conv.inner = untag_ptr(orig);
44631         orig_conv.is_owned = ptr_is_owned(orig);
44632         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44633         orig_conv.is_owned = false;
44634         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
44635         int64_t ret_ref = 0;
44636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44637         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44638         return ret_ref;
44639 }
44640
44641 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
44642         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
44643         int64_t ret_ref = 0;
44644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44645         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44646         return ret_ref;
44647 }
44648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44649         LDKNodeFeatures arg_conv;
44650         arg_conv.inner = untag_ptr(arg);
44651         arg_conv.is_owned = ptr_is_owned(arg);
44652         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44653         arg_conv.is_owned = false;
44654         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
44655         return ret_conv;
44656 }
44657
44658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44659         LDKNodeFeatures orig_conv;
44660         orig_conv.inner = untag_ptr(orig);
44661         orig_conv.is_owned = ptr_is_owned(orig);
44662         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44663         orig_conv.is_owned = false;
44664         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
44665         int64_t ret_ref = 0;
44666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44667         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44668         return ret_ref;
44669 }
44670
44671 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
44672         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
44673         int64_t ret_ref = 0;
44674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44675         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44676         return ret_ref;
44677 }
44678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44679         LDKChannelFeatures arg_conv;
44680         arg_conv.inner = untag_ptr(arg);
44681         arg_conv.is_owned = ptr_is_owned(arg);
44682         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44683         arg_conv.is_owned = false;
44684         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
44685         return ret_conv;
44686 }
44687
44688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44689         LDKChannelFeatures orig_conv;
44690         orig_conv.inner = untag_ptr(orig);
44691         orig_conv.is_owned = ptr_is_owned(orig);
44692         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44693         orig_conv.is_owned = false;
44694         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
44695         int64_t ret_ref = 0;
44696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44697         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44698         return ret_ref;
44699 }
44700
44701 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
44702         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
44703         int64_t ret_ref = 0;
44704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44705         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44706         return ret_ref;
44707 }
44708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44709         LDKInvoiceFeatures arg_conv;
44710         arg_conv.inner = untag_ptr(arg);
44711         arg_conv.is_owned = ptr_is_owned(arg);
44712         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44713         arg_conv.is_owned = false;
44714         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
44715         return ret_conv;
44716 }
44717
44718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44719         LDKInvoiceFeatures orig_conv;
44720         orig_conv.inner = untag_ptr(orig);
44721         orig_conv.is_owned = ptr_is_owned(orig);
44722         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44723         orig_conv.is_owned = false;
44724         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
44725         int64_t ret_ref = 0;
44726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44727         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44728         return ret_ref;
44729 }
44730
44731 static inline uint64_t OfferFeatures_clone_ptr(LDKOfferFeatures *NONNULL_PTR arg) {
44732         LDKOfferFeatures ret_var = OfferFeatures_clone(arg);
44733         int64_t ret_ref = 0;
44734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44735         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44736         return ret_ref;
44737 }
44738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44739         LDKOfferFeatures arg_conv;
44740         arg_conv.inner = untag_ptr(arg);
44741         arg_conv.is_owned = ptr_is_owned(arg);
44742         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44743         arg_conv.is_owned = false;
44744         int64_t ret_conv = OfferFeatures_clone_ptr(&arg_conv);
44745         return ret_conv;
44746 }
44747
44748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44749         LDKOfferFeatures orig_conv;
44750         orig_conv.inner = untag_ptr(orig);
44751         orig_conv.is_owned = ptr_is_owned(orig);
44752         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44753         orig_conv.is_owned = false;
44754         LDKOfferFeatures ret_var = OfferFeatures_clone(&orig_conv);
44755         int64_t ret_ref = 0;
44756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44757         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44758         return ret_ref;
44759 }
44760
44761 static inline uint64_t InvoiceRequestFeatures_clone_ptr(LDKInvoiceRequestFeatures *NONNULL_PTR arg) {
44762         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(arg);
44763         int64_t ret_ref = 0;
44764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44765         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44766         return ret_ref;
44767 }
44768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44769         LDKInvoiceRequestFeatures arg_conv;
44770         arg_conv.inner = untag_ptr(arg);
44771         arg_conv.is_owned = ptr_is_owned(arg);
44772         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44773         arg_conv.is_owned = false;
44774         int64_t ret_conv = InvoiceRequestFeatures_clone_ptr(&arg_conv);
44775         return ret_conv;
44776 }
44777
44778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44779         LDKInvoiceRequestFeatures orig_conv;
44780         orig_conv.inner = untag_ptr(orig);
44781         orig_conv.is_owned = ptr_is_owned(orig);
44782         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44783         orig_conv.is_owned = false;
44784         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(&orig_conv);
44785         int64_t ret_ref = 0;
44786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44787         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44788         return ret_ref;
44789 }
44790
44791 static inline uint64_t Bolt12InvoiceFeatures_clone_ptr(LDKBolt12InvoiceFeatures *NONNULL_PTR arg) {
44792         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(arg);
44793         int64_t ret_ref = 0;
44794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44795         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44796         return ret_ref;
44797 }
44798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44799         LDKBolt12InvoiceFeatures arg_conv;
44800         arg_conv.inner = untag_ptr(arg);
44801         arg_conv.is_owned = ptr_is_owned(arg);
44802         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44803         arg_conv.is_owned = false;
44804         int64_t ret_conv = Bolt12InvoiceFeatures_clone_ptr(&arg_conv);
44805         return ret_conv;
44806 }
44807
44808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44809         LDKBolt12InvoiceFeatures orig_conv;
44810         orig_conv.inner = untag_ptr(orig);
44811         orig_conv.is_owned = ptr_is_owned(orig);
44812         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44813         orig_conv.is_owned = false;
44814         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(&orig_conv);
44815         int64_t ret_ref = 0;
44816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44817         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44818         return ret_ref;
44819 }
44820
44821 static inline uint64_t BlindedHopFeatures_clone_ptr(LDKBlindedHopFeatures *NONNULL_PTR arg) {
44822         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(arg);
44823         int64_t ret_ref = 0;
44824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44825         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44826         return ret_ref;
44827 }
44828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44829         LDKBlindedHopFeatures arg_conv;
44830         arg_conv.inner = untag_ptr(arg);
44831         arg_conv.is_owned = ptr_is_owned(arg);
44832         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44833         arg_conv.is_owned = false;
44834         int64_t ret_conv = BlindedHopFeatures_clone_ptr(&arg_conv);
44835         return ret_conv;
44836 }
44837
44838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44839         LDKBlindedHopFeatures orig_conv;
44840         orig_conv.inner = untag_ptr(orig);
44841         orig_conv.is_owned = ptr_is_owned(orig);
44842         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44843         orig_conv.is_owned = false;
44844         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(&orig_conv);
44845         int64_t ret_ref = 0;
44846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44848         return ret_ref;
44849 }
44850
44851 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
44852         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
44853         int64_t ret_ref = 0;
44854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44855         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44856         return ret_ref;
44857 }
44858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44859         LDKChannelTypeFeatures arg_conv;
44860         arg_conv.inner = untag_ptr(arg);
44861         arg_conv.is_owned = ptr_is_owned(arg);
44862         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44863         arg_conv.is_owned = false;
44864         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
44865         return ret_conv;
44866 }
44867
44868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44869         LDKChannelTypeFeatures orig_conv;
44870         orig_conv.inner = untag_ptr(orig);
44871         orig_conv.is_owned = ptr_is_owned(orig);
44872         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44873         orig_conv.is_owned = false;
44874         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
44875         int64_t ret_ref = 0;
44876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44877         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44878         return ret_ref;
44879 }
44880
44881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44882         LDKInitFeatures this_obj_conv;
44883         this_obj_conv.inner = untag_ptr(this_obj);
44884         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44886         InitFeatures_free(this_obj_conv);
44887 }
44888
44889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44890         LDKNodeFeatures this_obj_conv;
44891         this_obj_conv.inner = untag_ptr(this_obj);
44892         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44894         NodeFeatures_free(this_obj_conv);
44895 }
44896
44897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44898         LDKChannelFeatures this_obj_conv;
44899         this_obj_conv.inner = untag_ptr(this_obj);
44900         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44902         ChannelFeatures_free(this_obj_conv);
44903 }
44904
44905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44906         LDKInvoiceFeatures this_obj_conv;
44907         this_obj_conv.inner = untag_ptr(this_obj);
44908         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44910         InvoiceFeatures_free(this_obj_conv);
44911 }
44912
44913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44914         LDKOfferFeatures this_obj_conv;
44915         this_obj_conv.inner = untag_ptr(this_obj);
44916         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44918         OfferFeatures_free(this_obj_conv);
44919 }
44920
44921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44922         LDKInvoiceRequestFeatures this_obj_conv;
44923         this_obj_conv.inner = untag_ptr(this_obj);
44924         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44926         InvoiceRequestFeatures_free(this_obj_conv);
44927 }
44928
44929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44930         LDKBolt12InvoiceFeatures this_obj_conv;
44931         this_obj_conv.inner = untag_ptr(this_obj);
44932         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44934         Bolt12InvoiceFeatures_free(this_obj_conv);
44935 }
44936
44937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44938         LDKBlindedHopFeatures this_obj_conv;
44939         this_obj_conv.inner = untag_ptr(this_obj);
44940         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44942         BlindedHopFeatures_free(this_obj_conv);
44943 }
44944
44945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44946         LDKChannelTypeFeatures this_obj_conv;
44947         this_obj_conv.inner = untag_ptr(this_obj);
44948         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44950         ChannelTypeFeatures_free(this_obj_conv);
44951 }
44952
44953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
44954         LDKInitFeatures ret_var = InitFeatures_empty();
44955         int64_t ret_ref = 0;
44956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44957         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44958         return ret_ref;
44959 }
44960
44961 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44962         LDKInitFeatures this_arg_conv;
44963         this_arg_conv.inner = untag_ptr(this_arg);
44964         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44966         this_arg_conv.is_owned = false;
44967         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
44968         return ret_conv;
44969 }
44970
44971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
44972         LDKNodeFeatures ret_var = NodeFeatures_empty();
44973         int64_t ret_ref = 0;
44974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44975         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44976         return ret_ref;
44977 }
44978
44979 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44980         LDKNodeFeatures this_arg_conv;
44981         this_arg_conv.inner = untag_ptr(this_arg);
44982         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44984         this_arg_conv.is_owned = false;
44985         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
44986         return ret_conv;
44987 }
44988
44989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
44990         LDKChannelFeatures ret_var = ChannelFeatures_empty();
44991         int64_t ret_ref = 0;
44992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44993         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44994         return ret_ref;
44995 }
44996
44997 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44998         LDKChannelFeatures this_arg_conv;
44999         this_arg_conv.inner = untag_ptr(this_arg);
45000         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45002         this_arg_conv.is_owned = false;
45003         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
45004         return ret_conv;
45005 }
45006
45007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
45008         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
45009         int64_t ret_ref = 0;
45010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45011         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45012         return ret_ref;
45013 }
45014
45015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45016         LDKInvoiceFeatures this_arg_conv;
45017         this_arg_conv.inner = untag_ptr(this_arg);
45018         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45020         this_arg_conv.is_owned = false;
45021         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
45022         return ret_conv;
45023 }
45024
45025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1empty(JNIEnv *env, jclass clz) {
45026         LDKOfferFeatures ret_var = OfferFeatures_empty();
45027         int64_t ret_ref = 0;
45028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45029         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45030         return ret_ref;
45031 }
45032
45033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45034         LDKOfferFeatures this_arg_conv;
45035         this_arg_conv.inner = untag_ptr(this_arg);
45036         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45038         this_arg_conv.is_owned = false;
45039         jboolean ret_conv = OfferFeatures_requires_unknown_bits(&this_arg_conv);
45040         return ret_conv;
45041 }
45042
45043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1empty(JNIEnv *env, jclass clz) {
45044         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_empty();
45045         int64_t ret_ref = 0;
45046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45047         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45048         return ret_ref;
45049 }
45050
45051 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45052         LDKInvoiceRequestFeatures this_arg_conv;
45053         this_arg_conv.inner = untag_ptr(this_arg);
45054         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45056         this_arg_conv.is_owned = false;
45057         jboolean ret_conv = InvoiceRequestFeatures_requires_unknown_bits(&this_arg_conv);
45058         return ret_conv;
45059 }
45060
45061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
45062         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_empty();
45063         int64_t ret_ref = 0;
45064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45065         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45066         return ret_ref;
45067 }
45068
45069 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45070         LDKBolt12InvoiceFeatures this_arg_conv;
45071         this_arg_conv.inner = untag_ptr(this_arg);
45072         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45074         this_arg_conv.is_owned = false;
45075         jboolean ret_conv = Bolt12InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
45076         return ret_conv;
45077 }
45078
45079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1empty(JNIEnv *env, jclass clz) {
45080         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_empty();
45081         int64_t ret_ref = 0;
45082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45083         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45084         return ret_ref;
45085 }
45086
45087 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45088         LDKBlindedHopFeatures this_arg_conv;
45089         this_arg_conv.inner = untag_ptr(this_arg);
45090         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45092         this_arg_conv.is_owned = false;
45093         jboolean ret_conv = BlindedHopFeatures_requires_unknown_bits(&this_arg_conv);
45094         return ret_conv;
45095 }
45096
45097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
45098         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
45099         int64_t ret_ref = 0;
45100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45101         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45102         return ret_ref;
45103 }
45104
45105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
45106         LDKChannelTypeFeatures this_arg_conv;
45107         this_arg_conv.inner = untag_ptr(this_arg);
45108         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45110         this_arg_conv.is_owned = false;
45111         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
45112         return ret_conv;
45113 }
45114
45115 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45116         LDKInitFeatures obj_conv;
45117         obj_conv.inner = untag_ptr(obj);
45118         obj_conv.is_owned = ptr_is_owned(obj);
45119         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45120         obj_conv.is_owned = false;
45121         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
45122         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45123         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45124         CVec_u8Z_free(ret_var);
45125         return ret_arr;
45126 }
45127
45128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45129         LDKu8slice ser_ref;
45130         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45131         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45132         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
45133         *ret_conv = InitFeatures_read(ser_ref);
45134         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45135         return tag_ptr(ret_conv, true);
45136 }
45137
45138 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45139         LDKChannelFeatures obj_conv;
45140         obj_conv.inner = untag_ptr(obj);
45141         obj_conv.is_owned = ptr_is_owned(obj);
45142         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45143         obj_conv.is_owned = false;
45144         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
45145         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45146         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45147         CVec_u8Z_free(ret_var);
45148         return ret_arr;
45149 }
45150
45151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45152         LDKu8slice ser_ref;
45153         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45154         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45155         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
45156         *ret_conv = ChannelFeatures_read(ser_ref);
45157         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45158         return tag_ptr(ret_conv, true);
45159 }
45160
45161 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45162         LDKNodeFeatures obj_conv;
45163         obj_conv.inner = untag_ptr(obj);
45164         obj_conv.is_owned = ptr_is_owned(obj);
45165         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45166         obj_conv.is_owned = false;
45167         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
45168         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45169         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45170         CVec_u8Z_free(ret_var);
45171         return ret_arr;
45172 }
45173
45174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45175         LDKu8slice ser_ref;
45176         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45177         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45178         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
45179         *ret_conv = NodeFeatures_read(ser_ref);
45180         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45181         return tag_ptr(ret_conv, true);
45182 }
45183
45184 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45185         LDKInvoiceFeatures obj_conv;
45186         obj_conv.inner = untag_ptr(obj);
45187         obj_conv.is_owned = ptr_is_owned(obj);
45188         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45189         obj_conv.is_owned = false;
45190         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
45191         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45192         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45193         CVec_u8Z_free(ret_var);
45194         return ret_arr;
45195 }
45196
45197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45198         LDKu8slice ser_ref;
45199         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45200         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45201         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
45202         *ret_conv = InvoiceFeatures_read(ser_ref);
45203         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45204         return tag_ptr(ret_conv, true);
45205 }
45206
45207 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45208         LDKBlindedHopFeatures obj_conv;
45209         obj_conv.inner = untag_ptr(obj);
45210         obj_conv.is_owned = ptr_is_owned(obj);
45211         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45212         obj_conv.is_owned = false;
45213         LDKCVec_u8Z ret_var = BlindedHopFeatures_write(&obj_conv);
45214         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45215         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45216         CVec_u8Z_free(ret_var);
45217         return ret_arr;
45218 }
45219
45220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHopFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45221         LDKu8slice ser_ref;
45222         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45223         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45224         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
45225         *ret_conv = BlindedHopFeatures_read(ser_ref);
45226         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45227         return tag_ptr(ret_conv, true);
45228 }
45229
45230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
45231         LDKChannelTypeFeatures obj_conv;
45232         obj_conv.inner = untag_ptr(obj);
45233         obj_conv.is_owned = ptr_is_owned(obj);
45234         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45235         obj_conv.is_owned = false;
45236         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
45237         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45238         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45239         CVec_u8Z_free(ret_var);
45240         return ret_arr;
45241 }
45242
45243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45244         LDKu8slice ser_ref;
45245         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45246         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45247         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
45248         *ret_conv = ChannelTypeFeatures_read(ser_ref);
45249         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45250         return tag_ptr(ret_conv, true);
45251 }
45252
45253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45254         LDKInitFeatures this_arg_conv;
45255         this_arg_conv.inner = untag_ptr(this_arg);
45256         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45258         this_arg_conv.is_owned = false;
45259         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
45260 }
45261
45262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45263         LDKInitFeatures this_arg_conv;
45264         this_arg_conv.inner = untag_ptr(this_arg);
45265         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45267         this_arg_conv.is_owned = false;
45268         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
45269 }
45270
45271 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45272         LDKInitFeatures this_arg_conv;
45273         this_arg_conv.inner = untag_ptr(this_arg);
45274         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45276         this_arg_conv.is_owned = false;
45277         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
45278         return ret_conv;
45279 }
45280
45281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45282         LDKNodeFeatures this_arg_conv;
45283         this_arg_conv.inner = untag_ptr(this_arg);
45284         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45286         this_arg_conv.is_owned = false;
45287         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
45288 }
45289
45290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45291         LDKNodeFeatures this_arg_conv;
45292         this_arg_conv.inner = untag_ptr(this_arg);
45293         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45295         this_arg_conv.is_owned = false;
45296         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
45297 }
45298
45299 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45300         LDKNodeFeatures this_arg_conv;
45301         this_arg_conv.inner = untag_ptr(this_arg);
45302         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45304         this_arg_conv.is_owned = false;
45305         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
45306         return ret_conv;
45307 }
45308
45309 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
45310         LDKInitFeatures this_arg_conv;
45311         this_arg_conv.inner = untag_ptr(this_arg);
45312         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45314         this_arg_conv.is_owned = false;
45315         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
45316         return ret_conv;
45317 }
45318
45319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_data_loss_protect(&this_arg_conv);
45326         return ret_conv;
45327 }
45328
45329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(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         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
45336 }
45337
45338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45339         LDKInitFeatures this_arg_conv;
45340         this_arg_conv.inner = untag_ptr(this_arg);
45341         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45343         this_arg_conv.is_owned = false;
45344         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
45345 }
45346
45347 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
45348         LDKInitFeatures this_arg_conv;
45349         this_arg_conv.inner = untag_ptr(this_arg);
45350         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45352         this_arg_conv.is_owned = false;
45353         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
45354         return ret_conv;
45355 }
45356
45357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45358         LDKInitFeatures this_arg_conv;
45359         this_arg_conv.inner = untag_ptr(this_arg);
45360         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45362         this_arg_conv.is_owned = false;
45363         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
45364 }
45365
45366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45367         LDKInitFeatures this_arg_conv;
45368         this_arg_conv.inner = untag_ptr(this_arg);
45369         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45371         this_arg_conv.is_owned = false;
45372         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
45373 }
45374
45375 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45376         LDKInitFeatures this_arg_conv;
45377         this_arg_conv.inner = untag_ptr(this_arg);
45378         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45380         this_arg_conv.is_owned = false;
45381         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
45382         return ret_conv;
45383 }
45384
45385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45386         LDKNodeFeatures this_arg_conv;
45387         this_arg_conv.inner = untag_ptr(this_arg);
45388         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45390         this_arg_conv.is_owned = false;
45391         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
45392 }
45393
45394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45395         LDKNodeFeatures this_arg_conv;
45396         this_arg_conv.inner = untag_ptr(this_arg);
45397         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45399         this_arg_conv.is_owned = false;
45400         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
45401 }
45402
45403 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45404         LDKNodeFeatures this_arg_conv;
45405         this_arg_conv.inner = untag_ptr(this_arg);
45406         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45408         this_arg_conv.is_owned = false;
45409         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
45410         return ret_conv;
45411 }
45412
45413 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
45414         LDKInitFeatures this_arg_conv;
45415         this_arg_conv.inner = untag_ptr(this_arg);
45416         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45418         this_arg_conv.is_owned = false;
45419         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
45420         return ret_conv;
45421 }
45422
45423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_upfront_shutdown_script(&this_arg_conv);
45430         return ret_conv;
45431 }
45432
45433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(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         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
45440 }
45441
45442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45443         LDKInitFeatures this_arg_conv;
45444         this_arg_conv.inner = untag_ptr(this_arg);
45445         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45447         this_arg_conv.is_owned = false;
45448         InitFeatures_set_gossip_queries_required(&this_arg_conv);
45449 }
45450
45451 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45452         LDKInitFeatures this_arg_conv;
45453         this_arg_conv.inner = untag_ptr(this_arg);
45454         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45456         this_arg_conv.is_owned = false;
45457         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
45458         return ret_conv;
45459 }
45460
45461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45462         LDKNodeFeatures this_arg_conv;
45463         this_arg_conv.inner = untag_ptr(this_arg);
45464         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45466         this_arg_conv.is_owned = false;
45467         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
45468 }
45469
45470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45471         LDKNodeFeatures this_arg_conv;
45472         this_arg_conv.inner = untag_ptr(this_arg);
45473         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45475         this_arg_conv.is_owned = false;
45476         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
45477 }
45478
45479 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45480         LDKNodeFeatures this_arg_conv;
45481         this_arg_conv.inner = untag_ptr(this_arg);
45482         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45484         this_arg_conv.is_owned = false;
45485         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
45486         return ret_conv;
45487 }
45488
45489 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
45490         LDKInitFeatures this_arg_conv;
45491         this_arg_conv.inner = untag_ptr(this_arg);
45492         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45494         this_arg_conv.is_owned = false;
45495         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
45496         return ret_conv;
45497 }
45498
45499 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_gossip_queries(&this_arg_conv);
45506         return ret_conv;
45507 }
45508
45509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(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         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
45516 }
45517
45518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45519         LDKInitFeatures this_arg_conv;
45520         this_arg_conv.inner = untag_ptr(this_arg);
45521         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45523         this_arg_conv.is_owned = false;
45524         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
45525 }
45526
45527 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45528         LDKInitFeatures this_arg_conv;
45529         this_arg_conv.inner = untag_ptr(this_arg);
45530         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45532         this_arg_conv.is_owned = false;
45533         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
45534         return ret_conv;
45535 }
45536
45537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45538         LDKNodeFeatures this_arg_conv;
45539         this_arg_conv.inner = untag_ptr(this_arg);
45540         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45542         this_arg_conv.is_owned = false;
45543         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
45544 }
45545
45546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45547         LDKNodeFeatures this_arg_conv;
45548         this_arg_conv.inner = untag_ptr(this_arg);
45549         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45551         this_arg_conv.is_owned = false;
45552         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
45553 }
45554
45555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45556         LDKNodeFeatures this_arg_conv;
45557         this_arg_conv.inner = untag_ptr(this_arg);
45558         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45560         this_arg_conv.is_owned = false;
45561         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
45562         return ret_conv;
45563 }
45564
45565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45566         LDKInvoiceFeatures this_arg_conv;
45567         this_arg_conv.inner = untag_ptr(this_arg);
45568         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45570         this_arg_conv.is_owned = false;
45571         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
45572 }
45573
45574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45575         LDKInvoiceFeatures this_arg_conv;
45576         this_arg_conv.inner = untag_ptr(this_arg);
45577         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45579         this_arg_conv.is_owned = false;
45580         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
45581 }
45582
45583 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45584         LDKInvoiceFeatures this_arg_conv;
45585         this_arg_conv.inner = untag_ptr(this_arg);
45586         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45588         this_arg_conv.is_owned = false;
45589         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
45590         return ret_conv;
45591 }
45592
45593 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45594         LDKInitFeatures this_arg_conv;
45595         this_arg_conv.inner = untag_ptr(this_arg);
45596         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45598         this_arg_conv.is_owned = false;
45599         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
45600         return ret_conv;
45601 }
45602
45603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45604         LDKNodeFeatures 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 = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
45610         return ret_conv;
45611 }
45612
45613 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
45614         LDKInvoiceFeatures 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 = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
45620         return ret_conv;
45621 }
45622
45623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45624         LDKInitFeatures 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         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
45630 }
45631
45632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45633         LDKInitFeatures this_arg_conv;
45634         this_arg_conv.inner = untag_ptr(this_arg);
45635         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45637         this_arg_conv.is_owned = false;
45638         InitFeatures_set_static_remote_key_required(&this_arg_conv);
45639 }
45640
45641 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45642         LDKInitFeatures this_arg_conv;
45643         this_arg_conv.inner = untag_ptr(this_arg);
45644         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45646         this_arg_conv.is_owned = false;
45647         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
45648         return ret_conv;
45649 }
45650
45651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45652         LDKNodeFeatures this_arg_conv;
45653         this_arg_conv.inner = untag_ptr(this_arg);
45654         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45656         this_arg_conv.is_owned = false;
45657         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
45658 }
45659
45660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45661         LDKNodeFeatures this_arg_conv;
45662         this_arg_conv.inner = untag_ptr(this_arg);
45663         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45665         this_arg_conv.is_owned = false;
45666         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
45667 }
45668
45669 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45670         LDKNodeFeatures this_arg_conv;
45671         this_arg_conv.inner = untag_ptr(this_arg);
45672         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45674         this_arg_conv.is_owned = false;
45675         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
45676         return ret_conv;
45677 }
45678
45679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45680         LDKChannelTypeFeatures this_arg_conv;
45681         this_arg_conv.inner = untag_ptr(this_arg);
45682         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45684         this_arg_conv.is_owned = false;
45685         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
45686 }
45687
45688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45689         LDKChannelTypeFeatures this_arg_conv;
45690         this_arg_conv.inner = untag_ptr(this_arg);
45691         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45693         this_arg_conv.is_owned = false;
45694         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
45695 }
45696
45697 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45698         LDKChannelTypeFeatures this_arg_conv;
45699         this_arg_conv.inner = untag_ptr(this_arg);
45700         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45702         this_arg_conv.is_owned = false;
45703         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
45704         return ret_conv;
45705 }
45706
45707 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45708         LDKInitFeatures this_arg_conv;
45709         this_arg_conv.inner = untag_ptr(this_arg);
45710         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45712         this_arg_conv.is_owned = false;
45713         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
45714         return ret_conv;
45715 }
45716
45717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45718         LDKNodeFeatures 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 = NodeFeatures_requires_static_remote_key(&this_arg_conv);
45724         return ret_conv;
45725 }
45726
45727 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45728         LDKChannelTypeFeatures 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 = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
45734         return ret_conv;
45735 }
45736
45737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45738         LDKInitFeatures 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         InitFeatures_set_payment_secret_optional(&this_arg_conv);
45744 }
45745
45746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45747         LDKInitFeatures this_arg_conv;
45748         this_arg_conv.inner = untag_ptr(this_arg);
45749         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45751         this_arg_conv.is_owned = false;
45752         InitFeatures_set_payment_secret_required(&this_arg_conv);
45753 }
45754
45755 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45756         LDKInitFeatures this_arg_conv;
45757         this_arg_conv.inner = untag_ptr(this_arg);
45758         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45760         this_arg_conv.is_owned = false;
45761         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
45762         return ret_conv;
45763 }
45764
45765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45766         LDKNodeFeatures this_arg_conv;
45767         this_arg_conv.inner = untag_ptr(this_arg);
45768         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45770         this_arg_conv.is_owned = false;
45771         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
45772 }
45773
45774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45775         LDKNodeFeatures this_arg_conv;
45776         this_arg_conv.inner = untag_ptr(this_arg);
45777         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45779         this_arg_conv.is_owned = false;
45780         NodeFeatures_set_payment_secret_required(&this_arg_conv);
45781 }
45782
45783 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45784         LDKNodeFeatures this_arg_conv;
45785         this_arg_conv.inner = untag_ptr(this_arg);
45786         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45788         this_arg_conv.is_owned = false;
45789         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
45790         return ret_conv;
45791 }
45792
45793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45794         LDKInvoiceFeatures this_arg_conv;
45795         this_arg_conv.inner = untag_ptr(this_arg);
45796         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45798         this_arg_conv.is_owned = false;
45799         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
45800 }
45801
45802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45803         LDKInvoiceFeatures this_arg_conv;
45804         this_arg_conv.inner = untag_ptr(this_arg);
45805         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45807         this_arg_conv.is_owned = false;
45808         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
45809 }
45810
45811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45812         LDKInvoiceFeatures this_arg_conv;
45813         this_arg_conv.inner = untag_ptr(this_arg);
45814         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45816         this_arg_conv.is_owned = false;
45817         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
45818         return ret_conv;
45819 }
45820
45821 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45822         LDKInitFeatures this_arg_conv;
45823         this_arg_conv.inner = untag_ptr(this_arg);
45824         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45826         this_arg_conv.is_owned = false;
45827         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
45828         return ret_conv;
45829 }
45830
45831 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45832         LDKNodeFeatures 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 = NodeFeatures_requires_payment_secret(&this_arg_conv);
45838         return ret_conv;
45839 }
45840
45841 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45842         LDKInvoiceFeatures 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 = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
45848         return ret_conv;
45849 }
45850
45851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45852         LDKInitFeatures 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         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
45858 }
45859
45860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45861         LDKInitFeatures this_arg_conv;
45862         this_arg_conv.inner = untag_ptr(this_arg);
45863         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45865         this_arg_conv.is_owned = false;
45866         InitFeatures_set_basic_mpp_required(&this_arg_conv);
45867 }
45868
45869 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45870         LDKInitFeatures this_arg_conv;
45871         this_arg_conv.inner = untag_ptr(this_arg);
45872         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45874         this_arg_conv.is_owned = false;
45875         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
45876         return ret_conv;
45877 }
45878
45879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45880         LDKNodeFeatures this_arg_conv;
45881         this_arg_conv.inner = untag_ptr(this_arg);
45882         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45884         this_arg_conv.is_owned = false;
45885         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
45886 }
45887
45888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45889         LDKNodeFeatures this_arg_conv;
45890         this_arg_conv.inner = untag_ptr(this_arg);
45891         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45893         this_arg_conv.is_owned = false;
45894         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
45895 }
45896
45897 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45898         LDKNodeFeatures this_arg_conv;
45899         this_arg_conv.inner = untag_ptr(this_arg);
45900         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45902         this_arg_conv.is_owned = false;
45903         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
45904         return ret_conv;
45905 }
45906
45907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45908         LDKInvoiceFeatures this_arg_conv;
45909         this_arg_conv.inner = untag_ptr(this_arg);
45910         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45912         this_arg_conv.is_owned = false;
45913         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
45914 }
45915
45916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45917         LDKInvoiceFeatures this_arg_conv;
45918         this_arg_conv.inner = untag_ptr(this_arg);
45919         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45921         this_arg_conv.is_owned = false;
45922         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
45923 }
45924
45925 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45926         LDKInvoiceFeatures this_arg_conv;
45927         this_arg_conv.inner = untag_ptr(this_arg);
45928         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45930         this_arg_conv.is_owned = false;
45931         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
45932         return ret_conv;
45933 }
45934
45935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45936         LDKBolt12InvoiceFeatures this_arg_conv;
45937         this_arg_conv.inner = untag_ptr(this_arg);
45938         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45940         this_arg_conv.is_owned = false;
45941         Bolt12InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
45942 }
45943
45944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45945         LDKBolt12InvoiceFeatures this_arg_conv;
45946         this_arg_conv.inner = untag_ptr(this_arg);
45947         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45949         this_arg_conv.is_owned = false;
45950         Bolt12InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
45951 }
45952
45953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45954         LDKBolt12InvoiceFeatures this_arg_conv;
45955         this_arg_conv.inner = untag_ptr(this_arg);
45956         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45958         this_arg_conv.is_owned = false;
45959         jboolean ret_conv = Bolt12InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
45960         return ret_conv;
45961 }
45962
45963 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45964         LDKInitFeatures this_arg_conv;
45965         this_arg_conv.inner = untag_ptr(this_arg);
45966         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45968         this_arg_conv.is_owned = false;
45969         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
45970         return ret_conv;
45971 }
45972
45973 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45974         LDKNodeFeatures 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 = NodeFeatures_requires_basic_mpp(&this_arg_conv);
45980         return ret_conv;
45981 }
45982
45983 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45984         LDKInvoiceFeatures 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 = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
45990         return ret_conv;
45991 }
45992
45993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Bolt12InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
45994         LDKBolt12InvoiceFeatures 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 = Bolt12InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
46000         return ret_conv;
46001 }
46002
46003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46004         LDKInitFeatures 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         InitFeatures_set_wumbo_optional(&this_arg_conv);
46010 }
46011
46012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46013         LDKInitFeatures this_arg_conv;
46014         this_arg_conv.inner = untag_ptr(this_arg);
46015         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46017         this_arg_conv.is_owned = false;
46018         InitFeatures_set_wumbo_required(&this_arg_conv);
46019 }
46020
46021 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46022         LDKInitFeatures this_arg_conv;
46023         this_arg_conv.inner = untag_ptr(this_arg);
46024         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46026         this_arg_conv.is_owned = false;
46027         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
46028         return ret_conv;
46029 }
46030
46031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46032         LDKNodeFeatures this_arg_conv;
46033         this_arg_conv.inner = untag_ptr(this_arg);
46034         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46036         this_arg_conv.is_owned = false;
46037         NodeFeatures_set_wumbo_optional(&this_arg_conv);
46038 }
46039
46040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46041         LDKNodeFeatures this_arg_conv;
46042         this_arg_conv.inner = untag_ptr(this_arg);
46043         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46045         this_arg_conv.is_owned = false;
46046         NodeFeatures_set_wumbo_required(&this_arg_conv);
46047 }
46048
46049 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46050         LDKNodeFeatures this_arg_conv;
46051         this_arg_conv.inner = untag_ptr(this_arg);
46052         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46054         this_arg_conv.is_owned = false;
46055         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
46056         return ret_conv;
46057 }
46058
46059 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
46060         LDKInitFeatures this_arg_conv;
46061         this_arg_conv.inner = untag_ptr(this_arg);
46062         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46064         this_arg_conv.is_owned = false;
46065         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
46066         return ret_conv;
46067 }
46068
46069 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_wumbo(&this_arg_conv);
46076         return ret_conv;
46077 }
46078
46079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(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         InitFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
46086 }
46087
46088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46089         LDKInitFeatures this_arg_conv;
46090         this_arg_conv.inner = untag_ptr(this_arg);
46091         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46093         this_arg_conv.is_owned = false;
46094         InitFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46095 }
46096
46097 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46098         LDKInitFeatures this_arg_conv;
46099         this_arg_conv.inner = untag_ptr(this_arg);
46100         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46102         this_arg_conv.is_owned = false;
46103         jboolean ret_conv = InitFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46104         return ret_conv;
46105 }
46106
46107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46108         LDKNodeFeatures this_arg_conv;
46109         this_arg_conv.inner = untag_ptr(this_arg);
46110         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46112         this_arg_conv.is_owned = false;
46113         NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
46114 }
46115
46116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46117         LDKNodeFeatures this_arg_conv;
46118         this_arg_conv.inner = untag_ptr(this_arg);
46119         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46121         this_arg_conv.is_owned = false;
46122         NodeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46123 }
46124
46125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46126         LDKNodeFeatures this_arg_conv;
46127         this_arg_conv.inner = untag_ptr(this_arg);
46128         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46130         this_arg_conv.is_owned = false;
46131         jboolean ret_conv = NodeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46132         return ret_conv;
46133 }
46134
46135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46136         LDKChannelTypeFeatures this_arg_conv;
46137         this_arg_conv.inner = untag_ptr(this_arg);
46138         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46140         this_arg_conv.is_owned = false;
46141         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
46142 }
46143
46144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1anchors_1zero_1fee_1htlc_1tx_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46145         LDKChannelTypeFeatures this_arg_conv;
46146         this_arg_conv.inner = untag_ptr(this_arg);
46147         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46149         this_arg_conv.is_owned = false;
46150         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
46151 }
46152
46153 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46154         LDKChannelTypeFeatures this_arg_conv;
46155         this_arg_conv.inner = untag_ptr(this_arg);
46156         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46158         this_arg_conv.is_owned = false;
46159         jboolean ret_conv = ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
46160         return ret_conv;
46161 }
46162
46163 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46164         LDKInitFeatures this_arg_conv;
46165         this_arg_conv.inner = untag_ptr(this_arg);
46166         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46168         this_arg_conv.is_owned = false;
46169         jboolean ret_conv = InitFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46170         return ret_conv;
46171 }
46172
46173 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46174         LDKNodeFeatures 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 = NodeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46180         return ret_conv;
46181 }
46182
46183 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1anchors_1zero_1fee_1htlc_1tx(JNIEnv *env, jclass clz, int64_t this_arg) {
46184         LDKChannelTypeFeatures 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 = ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
46190         return ret_conv;
46191 }
46192
46193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46194         LDKInitFeatures 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         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
46200 }
46201
46202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46203         LDKInitFeatures this_arg_conv;
46204         this_arg_conv.inner = untag_ptr(this_arg);
46205         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46207         this_arg_conv.is_owned = false;
46208         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
46209 }
46210
46211 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46212         LDKInitFeatures this_arg_conv;
46213         this_arg_conv.inner = untag_ptr(this_arg);
46214         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46216         this_arg_conv.is_owned = false;
46217         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
46218         return ret_conv;
46219 }
46220
46221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46222         LDKNodeFeatures this_arg_conv;
46223         this_arg_conv.inner = untag_ptr(this_arg);
46224         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46226         this_arg_conv.is_owned = false;
46227         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
46228 }
46229
46230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46231         LDKNodeFeatures this_arg_conv;
46232         this_arg_conv.inner = untag_ptr(this_arg);
46233         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46235         this_arg_conv.is_owned = false;
46236         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
46237 }
46238
46239 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46240         LDKNodeFeatures this_arg_conv;
46241         this_arg_conv.inner = untag_ptr(this_arg);
46242         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46244         this_arg_conv.is_owned = false;
46245         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
46246         return ret_conv;
46247 }
46248
46249 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
46250         LDKInitFeatures this_arg_conv;
46251         this_arg_conv.inner = untag_ptr(this_arg);
46252         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46254         this_arg_conv.is_owned = false;
46255         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
46256         return ret_conv;
46257 }
46258
46259 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_shutdown_anysegwit(&this_arg_conv);
46266         return ret_conv;
46267 }
46268
46269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1optional(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         InitFeatures_set_onion_messages_optional(&this_arg_conv);
46276 }
46277
46278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46279         LDKInitFeatures this_arg_conv;
46280         this_arg_conv.inner = untag_ptr(this_arg);
46281         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46283         this_arg_conv.is_owned = false;
46284         InitFeatures_set_onion_messages_required(&this_arg_conv);
46285 }
46286
46287 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46288         LDKInitFeatures this_arg_conv;
46289         this_arg_conv.inner = untag_ptr(this_arg);
46290         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46292         this_arg_conv.is_owned = false;
46293         jboolean ret_conv = InitFeatures_supports_onion_messages(&this_arg_conv);
46294         return ret_conv;
46295 }
46296
46297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46298         LDKNodeFeatures this_arg_conv;
46299         this_arg_conv.inner = untag_ptr(this_arg);
46300         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46302         this_arg_conv.is_owned = false;
46303         NodeFeatures_set_onion_messages_optional(&this_arg_conv);
46304 }
46305
46306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46307         LDKNodeFeatures this_arg_conv;
46308         this_arg_conv.inner = untag_ptr(this_arg);
46309         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46311         this_arg_conv.is_owned = false;
46312         NodeFeatures_set_onion_messages_required(&this_arg_conv);
46313 }
46314
46315 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46316         LDKNodeFeatures this_arg_conv;
46317         this_arg_conv.inner = untag_ptr(this_arg);
46318         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46320         this_arg_conv.is_owned = false;
46321         jboolean ret_conv = NodeFeatures_supports_onion_messages(&this_arg_conv);
46322         return ret_conv;
46323 }
46324
46325 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
46326         LDKInitFeatures this_arg_conv;
46327         this_arg_conv.inner = untag_ptr(this_arg);
46328         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46330         this_arg_conv.is_owned = false;
46331         jboolean ret_conv = InitFeatures_requires_onion_messages(&this_arg_conv);
46332         return ret_conv;
46333 }
46334
46335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_onion_messages(&this_arg_conv);
46342         return ret_conv;
46343 }
46344
46345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(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         InitFeatures_set_channel_type_optional(&this_arg_conv);
46352 }
46353
46354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46355         LDKInitFeatures this_arg_conv;
46356         this_arg_conv.inner = untag_ptr(this_arg);
46357         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46359         this_arg_conv.is_owned = false;
46360         InitFeatures_set_channel_type_required(&this_arg_conv);
46361 }
46362
46363 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46364         LDKInitFeatures this_arg_conv;
46365         this_arg_conv.inner = untag_ptr(this_arg);
46366         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46368         this_arg_conv.is_owned = false;
46369         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
46370         return ret_conv;
46371 }
46372
46373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46374         LDKNodeFeatures this_arg_conv;
46375         this_arg_conv.inner = untag_ptr(this_arg);
46376         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46378         this_arg_conv.is_owned = false;
46379         NodeFeatures_set_channel_type_optional(&this_arg_conv);
46380 }
46381
46382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46383         LDKNodeFeatures this_arg_conv;
46384         this_arg_conv.inner = untag_ptr(this_arg);
46385         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46387         this_arg_conv.is_owned = false;
46388         NodeFeatures_set_channel_type_required(&this_arg_conv);
46389 }
46390
46391 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46392         LDKNodeFeatures this_arg_conv;
46393         this_arg_conv.inner = untag_ptr(this_arg);
46394         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46396         this_arg_conv.is_owned = false;
46397         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
46398         return ret_conv;
46399 }
46400
46401 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
46402         LDKInitFeatures this_arg_conv;
46403         this_arg_conv.inner = untag_ptr(this_arg);
46404         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46406         this_arg_conv.is_owned = false;
46407         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
46408         return ret_conv;
46409 }
46410
46411 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_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_requires_channel_type(&this_arg_conv);
46418         return ret_conv;
46419 }
46420
46421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(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         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
46428 }
46429
46430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46431         LDKInitFeatures this_arg_conv;
46432         this_arg_conv.inner = untag_ptr(this_arg);
46433         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46435         this_arg_conv.is_owned = false;
46436         InitFeatures_set_scid_privacy_required(&this_arg_conv);
46437 }
46438
46439 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46440         LDKInitFeatures this_arg_conv;
46441         this_arg_conv.inner = untag_ptr(this_arg);
46442         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46444         this_arg_conv.is_owned = false;
46445         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
46446         return ret_conv;
46447 }
46448
46449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46450         LDKNodeFeatures this_arg_conv;
46451         this_arg_conv.inner = untag_ptr(this_arg);
46452         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46454         this_arg_conv.is_owned = false;
46455         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
46456 }
46457
46458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46459         LDKNodeFeatures this_arg_conv;
46460         this_arg_conv.inner = untag_ptr(this_arg);
46461         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46463         this_arg_conv.is_owned = false;
46464         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
46465 }
46466
46467 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46468         LDKNodeFeatures this_arg_conv;
46469         this_arg_conv.inner = untag_ptr(this_arg);
46470         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46472         this_arg_conv.is_owned = false;
46473         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
46474         return ret_conv;
46475 }
46476
46477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46478         LDKChannelTypeFeatures this_arg_conv;
46479         this_arg_conv.inner = untag_ptr(this_arg);
46480         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46482         this_arg_conv.is_owned = false;
46483         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
46484 }
46485
46486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46487         LDKChannelTypeFeatures this_arg_conv;
46488         this_arg_conv.inner = untag_ptr(this_arg);
46489         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46491         this_arg_conv.is_owned = false;
46492         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
46493 }
46494
46495 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46496         LDKChannelTypeFeatures this_arg_conv;
46497         this_arg_conv.inner = untag_ptr(this_arg);
46498         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46500         this_arg_conv.is_owned = false;
46501         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
46502         return ret_conv;
46503 }
46504
46505 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46506         LDKInitFeatures this_arg_conv;
46507         this_arg_conv.inner = untag_ptr(this_arg);
46508         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46510         this_arg_conv.is_owned = false;
46511         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
46512         return ret_conv;
46513 }
46514
46515 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46516         LDKNodeFeatures 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 = NodeFeatures_requires_scid_privacy(&this_arg_conv);
46522         return ret_conv;
46523 }
46524
46525 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
46526         LDKChannelTypeFeatures 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 = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
46532         return ret_conv;
46533 }
46534
46535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1metadata_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46536         LDKInvoiceFeatures 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         InvoiceFeatures_set_payment_metadata_optional(&this_arg_conv);
46542 }
46543
46544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1metadata_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46545         LDKInvoiceFeatures this_arg_conv;
46546         this_arg_conv.inner = untag_ptr(this_arg);
46547         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46549         this_arg_conv.is_owned = false;
46550         InvoiceFeatures_set_payment_metadata_required(&this_arg_conv);
46551 }
46552
46553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
46554         LDKInvoiceFeatures this_arg_conv;
46555         this_arg_conv.inner = untag_ptr(this_arg);
46556         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46558         this_arg_conv.is_owned = false;
46559         jboolean ret_conv = InvoiceFeatures_supports_payment_metadata(&this_arg_conv);
46560         return ret_conv;
46561 }
46562
46563 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
46564         LDKInvoiceFeatures this_arg_conv;
46565         this_arg_conv.inner = untag_ptr(this_arg);
46566         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46568         this_arg_conv.is_owned = false;
46569         jboolean ret_conv = InvoiceFeatures_requires_payment_metadata(&this_arg_conv);
46570         return ret_conv;
46571 }
46572
46573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46574         LDKInitFeatures 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         InitFeatures_set_zero_conf_optional(&this_arg_conv);
46580 }
46581
46582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46583         LDKInitFeatures this_arg_conv;
46584         this_arg_conv.inner = untag_ptr(this_arg);
46585         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46587         this_arg_conv.is_owned = false;
46588         InitFeatures_set_zero_conf_required(&this_arg_conv);
46589 }
46590
46591 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46592         LDKInitFeatures this_arg_conv;
46593         this_arg_conv.inner = untag_ptr(this_arg);
46594         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46596         this_arg_conv.is_owned = false;
46597         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
46598         return ret_conv;
46599 }
46600
46601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46602         LDKNodeFeatures this_arg_conv;
46603         this_arg_conv.inner = untag_ptr(this_arg);
46604         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46606         this_arg_conv.is_owned = false;
46607         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
46608 }
46609
46610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46611         LDKNodeFeatures this_arg_conv;
46612         this_arg_conv.inner = untag_ptr(this_arg);
46613         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46615         this_arg_conv.is_owned = false;
46616         NodeFeatures_set_zero_conf_required(&this_arg_conv);
46617 }
46618
46619 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46620         LDKNodeFeatures this_arg_conv;
46621         this_arg_conv.inner = untag_ptr(this_arg);
46622         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46624         this_arg_conv.is_owned = false;
46625         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
46626         return ret_conv;
46627 }
46628
46629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
46630         LDKChannelTypeFeatures this_arg_conv;
46631         this_arg_conv.inner = untag_ptr(this_arg);
46632         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46634         this_arg_conv.is_owned = false;
46635         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
46636 }
46637
46638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46639         LDKChannelTypeFeatures this_arg_conv;
46640         this_arg_conv.inner = untag_ptr(this_arg);
46641         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46643         this_arg_conv.is_owned = false;
46644         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
46645 }
46646
46647 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46648         LDKChannelTypeFeatures this_arg_conv;
46649         this_arg_conv.inner = untag_ptr(this_arg);
46650         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46652         this_arg_conv.is_owned = false;
46653         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
46654         return ret_conv;
46655 }
46656
46657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46658         LDKInitFeatures this_arg_conv;
46659         this_arg_conv.inner = untag_ptr(this_arg);
46660         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46662         this_arg_conv.is_owned = false;
46663         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
46664         return ret_conv;
46665 }
46666
46667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46668         LDKNodeFeatures 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 = NodeFeatures_requires_zero_conf(&this_arg_conv);
46674         return ret_conv;
46675 }
46676
46677 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
46678         LDKChannelTypeFeatures 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 = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
46684         return ret_conv;
46685 }
46686
46687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(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         NodeFeatures_set_keysend_optional(&this_arg_conv);
46694 }
46695
46696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
46697         LDKNodeFeatures this_arg_conv;
46698         this_arg_conv.inner = untag_ptr(this_arg);
46699         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46701         this_arg_conv.is_owned = false;
46702         NodeFeatures_set_keysend_required(&this_arg_conv);
46703 }
46704
46705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
46706         LDKNodeFeatures this_arg_conv;
46707         this_arg_conv.inner = untag_ptr(this_arg);
46708         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46710         this_arg_conv.is_owned = false;
46711         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
46712         return ret_conv;
46713 }
46714
46715 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
46716         LDKNodeFeatures this_arg_conv;
46717         this_arg_conv.inner = untag_ptr(this_arg);
46718         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46720         this_arg_conv.is_owned = false;
46721         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
46722         return ret_conv;
46723 }
46724
46725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46726         LDKShutdownScript this_obj_conv;
46727         this_obj_conv.inner = untag_ptr(this_obj);
46728         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46730         ShutdownScript_free(this_obj_conv);
46731 }
46732
46733 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
46734         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
46735         int64_t ret_ref = 0;
46736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46738         return ret_ref;
46739 }
46740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46741         LDKShutdownScript arg_conv;
46742         arg_conv.inner = untag_ptr(arg);
46743         arg_conv.is_owned = ptr_is_owned(arg);
46744         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46745         arg_conv.is_owned = false;
46746         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
46747         return ret_conv;
46748 }
46749
46750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46751         LDKShutdownScript orig_conv;
46752         orig_conv.inner = untag_ptr(orig);
46753         orig_conv.is_owned = ptr_is_owned(orig);
46754         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46755         orig_conv.is_owned = false;
46756         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
46757         int64_t ret_ref = 0;
46758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46759         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46760         return ret_ref;
46761 }
46762
46763 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46764         LDKShutdownScript a_conv;
46765         a_conv.inner = untag_ptr(a);
46766         a_conv.is_owned = ptr_is_owned(a);
46767         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46768         a_conv.is_owned = false;
46769         LDKShutdownScript b_conv;
46770         b_conv.inner = untag_ptr(b);
46771         b_conv.is_owned = ptr_is_owned(b);
46772         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46773         b_conv.is_owned = false;
46774         jboolean ret_conv = ShutdownScript_eq(&a_conv, &b_conv);
46775         return ret_conv;
46776 }
46777
46778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46779         LDKInvalidShutdownScript this_obj_conv;
46780         this_obj_conv.inner = untag_ptr(this_obj);
46781         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46783         InvalidShutdownScript_free(this_obj_conv);
46784 }
46785
46786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
46787         LDKInvalidShutdownScript this_ptr_conv;
46788         this_ptr_conv.inner = untag_ptr(this_ptr);
46789         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46791         this_ptr_conv.is_owned = false;
46792         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
46793         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46794         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46795         return ret_arr;
46796 }
46797
46798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46799         LDKInvalidShutdownScript this_ptr_conv;
46800         this_ptr_conv.inner = untag_ptr(this_ptr);
46801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46803         this_ptr_conv.is_owned = false;
46804         LDKCVec_u8Z val_ref;
46805         val_ref.datalen = (*env)->GetArrayLength(env, val);
46806         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
46807         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
46808         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
46809 }
46810
46811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
46812         LDKCVec_u8Z script_arg_ref;
46813         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
46814         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
46815         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
46816         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
46817         int64_t ret_ref = 0;
46818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46819         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46820         return ret_ref;
46821 }
46822
46823 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
46824         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
46825         int64_t ret_ref = 0;
46826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46827         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46828         return ret_ref;
46829 }
46830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46831         LDKInvalidShutdownScript arg_conv;
46832         arg_conv.inner = untag_ptr(arg);
46833         arg_conv.is_owned = ptr_is_owned(arg);
46834         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46835         arg_conv.is_owned = false;
46836         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
46837         return ret_conv;
46838 }
46839
46840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46841         LDKInvalidShutdownScript orig_conv;
46842         orig_conv.inner = untag_ptr(orig);
46843         orig_conv.is_owned = ptr_is_owned(orig);
46844         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46845         orig_conv.is_owned = false;
46846         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
46847         int64_t ret_ref = 0;
46848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46849         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46850         return ret_ref;
46851 }
46852
46853 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
46854         LDKShutdownScript obj_conv;
46855         obj_conv.inner = untag_ptr(obj);
46856         obj_conv.is_owned = ptr_is_owned(obj);
46857         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46858         obj_conv.is_owned = false;
46859         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
46860         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46861         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46862         CVec_u8Z_free(ret_var);
46863         return ret_arr;
46864 }
46865
46866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46867         LDKu8slice ser_ref;
46868         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46869         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46870         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
46871         *ret_conv = ShutdownScript_read(ser_ref);
46872         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46873         return tag_ptr(ret_conv, true);
46874 }
46875
46876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
46877         uint8_t pubkey_hash_arr[20];
46878         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
46879         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
46880         uint8_t (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
46881         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
46882         int64_t ret_ref = 0;
46883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46884         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46885         return ret_ref;
46886 }
46887
46888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
46889         uint8_t script_hash_arr[32];
46890         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
46891         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
46892         uint8_t (*script_hash_ref)[32] = &script_hash_arr;
46893         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
46894         int64_t ret_ref = 0;
46895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46896         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46897         return ret_ref;
46898 }
46899
46900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
46901         
46902         LDKu8slice program_ref;
46903         program_ref.datalen = (*env)->GetArrayLength(env, program);
46904         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
46905         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
46906         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
46907         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
46908         return tag_ptr(ret_conv, true);
46909 }
46910
46911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
46912         LDKShutdownScript this_arg_conv;
46913         this_arg_conv.inner = untag_ptr(this_arg);
46914         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46916         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
46917         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
46918         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46919         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46920         CVec_u8Z_free(ret_var);
46921         return ret_arr;
46922 }
46923
46924 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
46925         LDKShutdownScript this_arg_conv;
46926         this_arg_conv.inner = untag_ptr(this_arg);
46927         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46929         this_arg_conv.is_owned = false;
46930         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46931         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
46932         return ret_arr;
46933 }
46934
46935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
46936         LDKShutdownScript this_arg_conv;
46937         this_arg_conv.inner = untag_ptr(this_arg);
46938         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46940         this_arg_conv.is_owned = false;
46941         LDKInitFeatures features_conv;
46942         features_conv.inner = untag_ptr(features);
46943         features_conv.is_owned = ptr_is_owned(features);
46944         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
46945         features_conv.is_owned = false;
46946         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
46947         return ret_conv;
46948 }
46949
46950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46951         if (!ptr_is_owned(this_ptr)) return;
46952         void* this_ptr_ptr = untag_ptr(this_ptr);
46953         CHECK_ACCESS(this_ptr_ptr);
46954         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
46955         FREE(untag_ptr(this_ptr));
46956         Retry_free(this_ptr_conv);
46957 }
46958
46959 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
46960         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46961         *ret_copy = Retry_clone(arg);
46962         int64_t ret_ref = tag_ptr(ret_copy, true);
46963         return ret_ref;
46964 }
46965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46966         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
46967         int64_t ret_conv = Retry_clone_ptr(arg_conv);
46968         return ret_conv;
46969 }
46970
46971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46972         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
46973         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46974         *ret_copy = Retry_clone(orig_conv);
46975         int64_t ret_ref = tag_ptr(ret_copy, true);
46976         return ret_ref;
46977 }
46978
46979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
46980         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46981         *ret_copy = Retry_attempts(a);
46982         int64_t ret_ref = tag_ptr(ret_copy, true);
46983         return ret_ref;
46984 }
46985
46986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
46987         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
46988         *ret_copy = Retry_timeout(a);
46989         int64_t ret_ref = tag_ptr(ret_copy, true);
46990         return ret_ref;
46991 }
46992
46993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46994         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
46995         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
46996         jboolean ret_conv = Retry_eq(a_conv, b_conv);
46997         return ret_conv;
46998 }
46999
47000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
47001         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
47002         int64_t ret_conv = Retry_hash(o_conv);
47003         return ret_conv;
47004 }
47005
47006 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47007         LDKRetryableSendFailure* orig_conv = (LDKRetryableSendFailure*)untag_ptr(orig);
47008         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_clone(orig_conv));
47009         return ret_conv;
47010 }
47011
47012 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1payment_1expired(JNIEnv *env, jclass clz) {
47013         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_payment_expired());
47014         return ret_conv;
47015 }
47016
47017 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1route_1not_1found(JNIEnv *env, jclass clz) {
47018         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_route_not_found());
47019         return ret_conv;
47020 }
47021
47022 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RetryableSendFailure_1duplicate_1payment(JNIEnv *env, jclass clz) {
47023         jclass ret_conv = LDKRetryableSendFailure_to_java(env, RetryableSendFailure_duplicate_payment());
47024         return ret_conv;
47025 }
47026
47027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47028         if (!ptr_is_owned(this_ptr)) return;
47029         void* this_ptr_ptr = untag_ptr(this_ptr);
47030         CHECK_ACCESS(this_ptr_ptr);
47031         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
47032         FREE(untag_ptr(this_ptr));
47033         PaymentSendFailure_free(this_ptr_conv);
47034 }
47035
47036 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
47037         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47038         *ret_copy = PaymentSendFailure_clone(arg);
47039         int64_t ret_ref = tag_ptr(ret_copy, true);
47040         return ret_ref;
47041 }
47042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47043         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
47044         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
47045         return ret_conv;
47046 }
47047
47048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47049         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
47050         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47051         *ret_copy = PaymentSendFailure_clone(orig_conv);
47052         int64_t ret_ref = tag_ptr(ret_copy, true);
47053         return ret_ref;
47054 }
47055
47056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
47057         void* a_ptr = untag_ptr(a);
47058         CHECK_ACCESS(a_ptr);
47059         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
47060         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
47061         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47062         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
47063         int64_t ret_ref = tag_ptr(ret_copy, true);
47064         return ret_ref;
47065 }
47066
47067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
47068         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
47069         a_constr.datalen = (*env)->GetArrayLength(env, a);
47070         if (a_constr.datalen > 0)
47071                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
47072         else
47073                 a_constr.data = NULL;
47074         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
47075         for (size_t w = 0; w < a_constr.datalen; w++) {
47076                 int64_t a_conv_22 = a_vals[w];
47077                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
47078                 CHECK_ACCESS(a_conv_22_ptr);
47079                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
47080                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
47081                 a_constr.data[w] = a_conv_22_conv;
47082         }
47083         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
47084         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47085         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
47086         int64_t ret_ref = tag_ptr(ret_copy, true);
47087         return ret_ref;
47088 }
47089
47090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1resend_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
47091         LDKCVec_APIErrorZ a_constr;
47092         a_constr.datalen = (*env)->GetArrayLength(env, a);
47093         if (a_constr.datalen > 0)
47094                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
47095         else
47096                 a_constr.data = NULL;
47097         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
47098         for (size_t k = 0; k < a_constr.datalen; k++) {
47099                 int64_t a_conv_10 = a_vals[k];
47100                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
47101                 CHECK_ACCESS(a_conv_10_ptr);
47102                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
47103                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
47104                 a_constr.data[k] = a_conv_10_conv;
47105         }
47106         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
47107         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47108         *ret_copy = PaymentSendFailure_all_failed_resend_safe(a_constr);
47109         int64_t ret_ref = tag_ptr(ret_copy, true);
47110         return ret_ref;
47111 }
47112
47113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1duplicate_1payment(JNIEnv *env, jclass clz) {
47114         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47115         *ret_copy = PaymentSendFailure_duplicate_payment();
47116         int64_t ret_ref = tag_ptr(ret_copy, true);
47117         return ret_ref;
47118 }
47119
47120 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) {
47121         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
47122         results_constr.datalen = (*env)->GetArrayLength(env, results);
47123         if (results_constr.datalen > 0)
47124                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
47125         else
47126                 results_constr.data = NULL;
47127         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
47128         for (size_t w = 0; w < results_constr.datalen; w++) {
47129                 int64_t results_conv_22 = results_vals[w];
47130                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
47131                 CHECK_ACCESS(results_conv_22_ptr);
47132                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
47133                 results_constr.data[w] = results_conv_22_conv;
47134         }
47135         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
47136         LDKRouteParameters failed_paths_retry_conv;
47137         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
47138         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
47139         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
47140         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
47141         LDKThirtyTwoBytes payment_id_ref;
47142         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
47143         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
47144         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
47145         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
47146         int64_t ret_ref = tag_ptr(ret_copy, true);
47147         return ret_ref;
47148 }
47149
47150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47151         LDKRecipientOnionFields this_obj_conv;
47152         this_obj_conv.inner = untag_ptr(this_obj);
47153         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47155         RecipientOnionFields_free(this_obj_conv);
47156 }
47157
47158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1get_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
47159         LDKRecipientOnionFields this_ptr_conv;
47160         this_ptr_conv.inner = untag_ptr(this_ptr);
47161         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47163         this_ptr_conv.is_owned = false;
47164         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47165         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RecipientOnionFields_get_payment_secret(&this_ptr_conv).data);
47166         return ret_arr;
47167 }
47168
47169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1set_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
47170         LDKRecipientOnionFields this_ptr_conv;
47171         this_ptr_conv.inner = untag_ptr(this_ptr);
47172         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47174         this_ptr_conv.is_owned = false;
47175         LDKThirtyTwoBytes val_ref;
47176         CHECK((*env)->GetArrayLength(env, val) == 32);
47177         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
47178         RecipientOnionFields_set_payment_secret(&this_ptr_conv, val_ref);
47179 }
47180
47181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1get_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_ptr) {
47182         LDKRecipientOnionFields this_ptr_conv;
47183         this_ptr_conv.inner = untag_ptr(this_ptr);
47184         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47186         this_ptr_conv.is_owned = false;
47187         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
47188         *ret_copy = RecipientOnionFields_get_payment_metadata(&this_ptr_conv);
47189         int64_t ret_ref = tag_ptr(ret_copy, true);
47190         return ret_ref;
47191 }
47192
47193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1set_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47194         LDKRecipientOnionFields this_ptr_conv;
47195         this_ptr_conv.inner = untag_ptr(this_ptr);
47196         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47198         this_ptr_conv.is_owned = false;
47199         void* val_ptr = untag_ptr(val);
47200         CHECK_ACCESS(val_ptr);
47201         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
47202         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
47203         RecipientOnionFields_set_payment_metadata(&this_ptr_conv, val_conv);
47204 }
47205
47206 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) {
47207         LDKThirtyTwoBytes payment_secret_arg_ref;
47208         CHECK((*env)->GetArrayLength(env, payment_secret_arg) == 32);
47209         (*env)->GetByteArrayRegion(env, payment_secret_arg, 0, 32, payment_secret_arg_ref.data);
47210         void* payment_metadata_arg_ptr = untag_ptr(payment_metadata_arg);
47211         CHECK_ACCESS(payment_metadata_arg_ptr);
47212         LDKCOption_CVec_u8ZZ payment_metadata_arg_conv = *(LDKCOption_CVec_u8ZZ*)(payment_metadata_arg_ptr);
47213         payment_metadata_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(payment_metadata_arg));
47214         LDKRecipientOnionFields ret_var = RecipientOnionFields_new(payment_secret_arg_ref, payment_metadata_arg_conv);
47215         int64_t ret_ref = 0;
47216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47217         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47218         return ret_ref;
47219 }
47220
47221 static inline uint64_t RecipientOnionFields_clone_ptr(LDKRecipientOnionFields *NONNULL_PTR arg) {
47222         LDKRecipientOnionFields ret_var = RecipientOnionFields_clone(arg);
47223         int64_t ret_ref = 0;
47224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47225         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47226         return ret_ref;
47227 }
47228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47229         LDKRecipientOnionFields arg_conv;
47230         arg_conv.inner = untag_ptr(arg);
47231         arg_conv.is_owned = ptr_is_owned(arg);
47232         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47233         arg_conv.is_owned = false;
47234         int64_t ret_conv = RecipientOnionFields_clone_ptr(&arg_conv);
47235         return ret_conv;
47236 }
47237
47238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47239         LDKRecipientOnionFields orig_conv;
47240         orig_conv.inner = untag_ptr(orig);
47241         orig_conv.is_owned = ptr_is_owned(orig);
47242         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47243         orig_conv.is_owned = false;
47244         LDKRecipientOnionFields ret_var = RecipientOnionFields_clone(&orig_conv);
47245         int64_t ret_ref = 0;
47246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47247         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47248         return ret_ref;
47249 }
47250
47251 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47252         LDKRecipientOnionFields a_conv;
47253         a_conv.inner = untag_ptr(a);
47254         a_conv.is_owned = ptr_is_owned(a);
47255         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47256         a_conv.is_owned = false;
47257         LDKRecipientOnionFields b_conv;
47258         b_conv.inner = untag_ptr(b);
47259         b_conv.is_owned = ptr_is_owned(b);
47260         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47261         b_conv.is_owned = false;
47262         jboolean ret_conv = RecipientOnionFields_eq(&a_conv, &b_conv);
47263         return ret_conv;
47264 }
47265
47266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1write(JNIEnv *env, jclass clz, int64_t obj) {
47267         LDKRecipientOnionFields obj_conv;
47268         obj_conv.inner = untag_ptr(obj);
47269         obj_conv.is_owned = ptr_is_owned(obj);
47270         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47271         obj_conv.is_owned = false;
47272         LDKCVec_u8Z ret_var = RecipientOnionFields_write(&obj_conv);
47273         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47274         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47275         CVec_u8Z_free(ret_var);
47276         return ret_arr;
47277 }
47278
47279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47280         LDKu8slice ser_ref;
47281         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47282         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47283         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
47284         *ret_conv = RecipientOnionFields_read(ser_ref);
47285         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47286         return tag_ptr(ret_conv, true);
47287 }
47288
47289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1secret_1only(JNIEnv *env, jclass clz, int8_tArray payment_secret) {
47290         LDKThirtyTwoBytes payment_secret_ref;
47291         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
47292         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
47293         LDKRecipientOnionFields ret_var = RecipientOnionFields_secret_only(payment_secret_ref);
47294         int64_t ret_ref = 0;
47295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47296         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47297         return ret_ref;
47298 }
47299
47300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RecipientOnionFields_1spontaneous_1empty(JNIEnv *env, jclass clz) {
47301         LDKRecipientOnionFields ret_var = RecipientOnionFields_spontaneous_empty();
47302         int64_t ret_ref = 0;
47303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47304         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47305         return ret_ref;
47306 }
47307
47308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47309         if (!ptr_is_owned(this_ptr)) return;
47310         void* this_ptr_ptr = untag_ptr(this_ptr);
47311         CHECK_ACCESS(this_ptr_ptr);
47312         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
47313         FREE(untag_ptr(this_ptr));
47314         CustomMessageReader_free(this_ptr_conv);
47315 }
47316
47317 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
47318         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
47319         *ret_ret = Type_clone(arg);
47320         return tag_ptr(ret_ret, true);
47321 }
47322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47323         void* arg_ptr = untag_ptr(arg);
47324         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
47325         LDKType* arg_conv = (LDKType*)arg_ptr;
47326         int64_t ret_conv = Type_clone_ptr(arg_conv);
47327         return ret_conv;
47328 }
47329
47330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47331         void* orig_ptr = untag_ptr(orig);
47332         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
47333         LDKType* orig_conv = (LDKType*)orig_ptr;
47334         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
47335         *ret_ret = Type_clone(orig_conv);
47336         return tag_ptr(ret_ret, true);
47337 }
47338
47339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47340         if (!ptr_is_owned(this_ptr)) return;
47341         void* this_ptr_ptr = untag_ptr(this_ptr);
47342         CHECK_ACCESS(this_ptr_ptr);
47343         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
47344         FREE(untag_ptr(this_ptr));
47345         Type_free(this_ptr_conv);
47346 }
47347
47348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47349         LDKUnsignedInvoice this_obj_conv;
47350         this_obj_conv.inner = untag_ptr(this_obj);
47351         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47353         UnsignedInvoice_free(this_obj_conv);
47354 }
47355
47356 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedInvoice_1signing_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
47357         LDKUnsignedInvoice this_arg_conv;
47358         this_arg_conv.inner = untag_ptr(this_arg);
47359         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47361         this_arg_conv.is_owned = false;
47362         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47363         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedInvoice_signing_pubkey(&this_arg_conv).compressed_form);
47364         return ret_arr;
47365 }
47366
47367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47368         LDKBlindedPayInfo this_obj_conv;
47369         this_obj_conv.inner = untag_ptr(this_obj);
47370         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47372         BlindedPayInfo_free(this_obj_conv);
47373 }
47374
47375 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47376         LDKBlindedPayInfo this_ptr_conv;
47377         this_ptr_conv.inner = untag_ptr(this_ptr);
47378         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47380         this_ptr_conv.is_owned = false;
47381         int32_t ret_conv = BlindedPayInfo_get_fee_base_msat(&this_ptr_conv);
47382         return ret_conv;
47383 }
47384
47385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
47386         LDKBlindedPayInfo this_ptr_conv;
47387         this_ptr_conv.inner = untag_ptr(this_ptr);
47388         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47390         this_ptr_conv.is_owned = false;
47391         BlindedPayInfo_set_fee_base_msat(&this_ptr_conv, val);
47392 }
47393
47394 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
47395         LDKBlindedPayInfo this_ptr_conv;
47396         this_ptr_conv.inner = untag_ptr(this_ptr);
47397         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47399         this_ptr_conv.is_owned = false;
47400         int32_t ret_conv = BlindedPayInfo_get_fee_proportional_millionths(&this_ptr_conv);
47401         return ret_conv;
47402 }
47403
47404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
47405         LDKBlindedPayInfo this_ptr_conv;
47406         this_ptr_conv.inner = untag_ptr(this_ptr);
47407         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47409         this_ptr_conv.is_owned = false;
47410         BlindedPayInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
47411 }
47412
47413 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
47414         LDKBlindedPayInfo this_ptr_conv;
47415         this_ptr_conv.inner = untag_ptr(this_ptr);
47416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47418         this_ptr_conv.is_owned = false;
47419         int16_t ret_conv = BlindedPayInfo_get_cltv_expiry_delta(&this_ptr_conv);
47420         return ret_conv;
47421 }
47422
47423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
47424         LDKBlindedPayInfo this_ptr_conv;
47425         this_ptr_conv.inner = untag_ptr(this_ptr);
47426         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47428         this_ptr_conv.is_owned = false;
47429         BlindedPayInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
47430 }
47431
47432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47433         LDKBlindedPayInfo this_ptr_conv;
47434         this_ptr_conv.inner = untag_ptr(this_ptr);
47435         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47437         this_ptr_conv.is_owned = false;
47438         int64_t ret_conv = BlindedPayInfo_get_htlc_minimum_msat(&this_ptr_conv);
47439         return ret_conv;
47440 }
47441
47442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47443         LDKBlindedPayInfo this_ptr_conv;
47444         this_ptr_conv.inner = untag_ptr(this_ptr);
47445         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47447         this_ptr_conv.is_owned = false;
47448         BlindedPayInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
47449 }
47450
47451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47452         LDKBlindedPayInfo this_ptr_conv;
47453         this_ptr_conv.inner = untag_ptr(this_ptr);
47454         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47456         this_ptr_conv.is_owned = false;
47457         int64_t ret_conv = BlindedPayInfo_get_htlc_maximum_msat(&this_ptr_conv);
47458         return ret_conv;
47459 }
47460
47461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47462         LDKBlindedPayInfo this_ptr_conv;
47463         this_ptr_conv.inner = untag_ptr(this_ptr);
47464         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47466         this_ptr_conv.is_owned = false;
47467         BlindedPayInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
47468 }
47469
47470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
47471         LDKBlindedPayInfo this_ptr_conv;
47472         this_ptr_conv.inner = untag_ptr(this_ptr);
47473         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47475         this_ptr_conv.is_owned = false;
47476         LDKBlindedHopFeatures ret_var = BlindedPayInfo_get_features(&this_ptr_conv);
47477         int64_t ret_ref = 0;
47478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47479         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47480         return ret_ref;
47481 }
47482
47483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47484         LDKBlindedPayInfo this_ptr_conv;
47485         this_ptr_conv.inner = untag_ptr(this_ptr);
47486         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47488         this_ptr_conv.is_owned = false;
47489         LDKBlindedHopFeatures val_conv;
47490         val_conv.inner = untag_ptr(val);
47491         val_conv.is_owned = ptr_is_owned(val);
47492         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47493         val_conv = BlindedHopFeatures_clone(&val_conv);
47494         BlindedPayInfo_set_features(&this_ptr_conv, val_conv);
47495 }
47496
47497 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) {
47498         LDKBlindedHopFeatures features_arg_conv;
47499         features_arg_conv.inner = untag_ptr(features_arg);
47500         features_arg_conv.is_owned = ptr_is_owned(features_arg);
47501         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
47502         features_arg_conv = BlindedHopFeatures_clone(&features_arg_conv);
47503         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);
47504         int64_t ret_ref = 0;
47505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47506         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47507         return ret_ref;
47508 }
47509
47510 static inline uint64_t BlindedPayInfo_clone_ptr(LDKBlindedPayInfo *NONNULL_PTR arg) {
47511         LDKBlindedPayInfo ret_var = BlindedPayInfo_clone(arg);
47512         int64_t ret_ref = 0;
47513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47514         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47515         return ret_ref;
47516 }
47517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47518         LDKBlindedPayInfo arg_conv;
47519         arg_conv.inner = untag_ptr(arg);
47520         arg_conv.is_owned = ptr_is_owned(arg);
47521         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47522         arg_conv.is_owned = false;
47523         int64_t ret_conv = BlindedPayInfo_clone_ptr(&arg_conv);
47524         return ret_conv;
47525 }
47526
47527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47528         LDKBlindedPayInfo orig_conv;
47529         orig_conv.inner = untag_ptr(orig);
47530         orig_conv.is_owned = ptr_is_owned(orig);
47531         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47532         orig_conv.is_owned = false;
47533         LDKBlindedPayInfo ret_var = BlindedPayInfo_clone(&orig_conv);
47534         int64_t ret_ref = 0;
47535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47536         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47537         return ret_ref;
47538 }
47539
47540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1hash(JNIEnv *env, jclass clz, int64_t o) {
47541         LDKBlindedPayInfo o_conv;
47542         o_conv.inner = untag_ptr(o);
47543         o_conv.is_owned = ptr_is_owned(o);
47544         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47545         o_conv.is_owned = false;
47546         int64_t ret_conv = BlindedPayInfo_hash(&o_conv);
47547         return ret_conv;
47548 }
47549
47550 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47551         LDKBlindedPayInfo a_conv;
47552         a_conv.inner = untag_ptr(a);
47553         a_conv.is_owned = ptr_is_owned(a);
47554         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47555         a_conv.is_owned = false;
47556         LDKBlindedPayInfo b_conv;
47557         b_conv.inner = untag_ptr(b);
47558         b_conv.is_owned = ptr_is_owned(b);
47559         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47560         b_conv.is_owned = false;
47561         jboolean ret_conv = BlindedPayInfo_eq(&a_conv, &b_conv);
47562         return ret_conv;
47563 }
47564
47565 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
47566         LDKBlindedPayInfo obj_conv;
47567         obj_conv.inner = untag_ptr(obj);
47568         obj_conv.is_owned = ptr_is_owned(obj);
47569         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47570         obj_conv.is_owned = false;
47571         LDKCVec_u8Z ret_var = BlindedPayInfo_write(&obj_conv);
47572         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47573         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47574         CVec_u8Z_free(ret_var);
47575         return ret_arr;
47576 }
47577
47578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPayInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47579         LDKu8slice ser_ref;
47580         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47581         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47582         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
47583         *ret_conv = BlindedPayInfo_read(ser_ref);
47584         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47585         return tag_ptr(ret_conv, true);
47586 }
47587
47588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedInvoiceRequest_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47589         LDKUnsignedInvoiceRequest this_obj_conv;
47590         this_obj_conv.inner = untag_ptr(this_obj);
47591         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47593         UnsignedInvoiceRequest_free(this_obj_conv);
47594 }
47595
47596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47597         LDKInvoiceRequest this_obj_conv;
47598         this_obj_conv.inner = untag_ptr(this_obj);
47599         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47601         InvoiceRequest_free(this_obj_conv);
47602 }
47603
47604 static inline uint64_t InvoiceRequest_clone_ptr(LDKInvoiceRequest *NONNULL_PTR arg) {
47605         LDKInvoiceRequest ret_var = InvoiceRequest_clone(arg);
47606         int64_t ret_ref = 0;
47607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47608         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47609         return ret_ref;
47610 }
47611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47612         LDKInvoiceRequest arg_conv;
47613         arg_conv.inner = untag_ptr(arg);
47614         arg_conv.is_owned = ptr_is_owned(arg);
47615         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47616         arg_conv.is_owned = false;
47617         int64_t ret_conv = InvoiceRequest_clone_ptr(&arg_conv);
47618         return ret_conv;
47619 }
47620
47621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47622         LDKInvoiceRequest orig_conv;
47623         orig_conv.inner = untag_ptr(orig);
47624         orig_conv.is_owned = ptr_is_owned(orig);
47625         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47626         orig_conv.is_owned = false;
47627         LDKInvoiceRequest ret_var = InvoiceRequest_clone(&orig_conv);
47628         int64_t ret_ref = 0;
47629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47631         return ret_ref;
47632 }
47633
47634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
47635         LDKInvoiceRequest this_arg_conv;
47636         this_arg_conv.inner = untag_ptr(this_arg);
47637         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47639         this_arg_conv.is_owned = false;
47640         LDKu8slice ret_var = InvoiceRequest_metadata(&this_arg_conv);
47641         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47642         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47643         return ret_arr;
47644 }
47645
47646 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1chain(JNIEnv *env, jclass clz, int64_t this_arg) {
47647         LDKInvoiceRequest this_arg_conv;
47648         this_arg_conv.inner = untag_ptr(this_arg);
47649         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47651         this_arg_conv.is_owned = false;
47652         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47653         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, InvoiceRequest_chain(&this_arg_conv).data);
47654         return ret_arr;
47655 }
47656
47657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1amount_1msats(JNIEnv *env, jclass clz, int64_t this_arg) {
47658         LDKInvoiceRequest this_arg_conv;
47659         this_arg_conv.inner = untag_ptr(this_arg);
47660         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47662         this_arg_conv.is_owned = false;
47663         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47664         *ret_copy = InvoiceRequest_amount_msats(&this_arg_conv);
47665         int64_t ret_ref = tag_ptr(ret_copy, true);
47666         return ret_ref;
47667 }
47668
47669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47670         LDKInvoiceRequest this_arg_conv;
47671         this_arg_conv.inner = untag_ptr(this_arg);
47672         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47674         this_arg_conv.is_owned = false;
47675         LDKInvoiceRequestFeatures ret_var = InvoiceRequest_features(&this_arg_conv);
47676         int64_t ret_ref = 0;
47677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47678         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47679         return ret_ref;
47680 }
47681
47682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
47683         LDKInvoiceRequest this_arg_conv;
47684         this_arg_conv.inner = untag_ptr(this_arg);
47685         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47687         this_arg_conv.is_owned = false;
47688         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47689         *ret_copy = InvoiceRequest_quantity(&this_arg_conv);
47690         int64_t ret_ref = tag_ptr(ret_copy, true);
47691         return ret_ref;
47692 }
47693
47694 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1payer_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
47695         LDKInvoiceRequest this_arg_conv;
47696         this_arg_conv.inner = untag_ptr(this_arg);
47697         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47699         this_arg_conv.is_owned = false;
47700         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47701         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, InvoiceRequest_payer_id(&this_arg_conv).compressed_form);
47702         return ret_arr;
47703 }
47704
47705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1payer_1note(JNIEnv *env, jclass clz, int64_t this_arg) {
47706         LDKInvoiceRequest this_arg_conv;
47707         this_arg_conv.inner = untag_ptr(this_arg);
47708         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47710         this_arg_conv.is_owned = false;
47711         LDKPrintableString ret_var = InvoiceRequest_payer_note(&this_arg_conv);
47712         int64_t ret_ref = 0;
47713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47714         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47715         return ret_ref;
47716 }
47717
47718 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequest_1write(JNIEnv *env, jclass clz, int64_t obj) {
47719         LDKInvoiceRequest obj_conv;
47720         obj_conv.inner = untag_ptr(obj);
47721         obj_conv.is_owned = ptr_is_owned(obj);
47722         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47723         obj_conv.is_owned = false;
47724         LDKCVec_u8Z ret_var = InvoiceRequest_write(&obj_conv);
47725         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47726         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47727         CVec_u8Z_free(ret_var);
47728         return ret_arr;
47729 }
47730
47731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Offer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47732         LDKOffer this_obj_conv;
47733         this_obj_conv.inner = untag_ptr(this_obj);
47734         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47736         Offer_free(this_obj_conv);
47737 }
47738
47739 static inline uint64_t Offer_clone_ptr(LDKOffer *NONNULL_PTR arg) {
47740         LDKOffer ret_var = Offer_clone(arg);
47741         int64_t ret_ref = 0;
47742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47744         return ret_ref;
47745 }
47746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47747         LDKOffer arg_conv;
47748         arg_conv.inner = untag_ptr(arg);
47749         arg_conv.is_owned = ptr_is_owned(arg);
47750         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47751         arg_conv.is_owned = false;
47752         int64_t ret_conv = Offer_clone_ptr(&arg_conv);
47753         return ret_conv;
47754 }
47755
47756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47757         LDKOffer orig_conv;
47758         orig_conv.inner = untag_ptr(orig);
47759         orig_conv.is_owned = ptr_is_owned(orig);
47760         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47761         orig_conv.is_owned = false;
47762         LDKOffer ret_var = Offer_clone(&orig_conv);
47763         int64_t ret_ref = 0;
47764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47765         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47766         return ret_ref;
47767 }
47768
47769 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Offer_1chains(JNIEnv *env, jclass clz, int64_t this_arg) {
47770         LDKOffer this_arg_conv;
47771         this_arg_conv.inner = untag_ptr(this_arg);
47772         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47774         this_arg_conv.is_owned = false;
47775         LDKCVec_ChainHashZ ret_var = Offer_chains(&this_arg_conv);
47776         jobjectArray ret_arr = NULL;
47777         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
47778         ;
47779         for (size_t i = 0; i < ret_var.datalen; i++) {
47780                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
47781                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
47782                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
47783         }
47784         
47785         FREE(ret_var.data);
47786         return ret_arr;
47787 }
47788
47789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1supports_1chain(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray chain) {
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         LDKThirtyTwoBytes chain_ref;
47796         CHECK((*env)->GetArrayLength(env, chain) == 32);
47797         (*env)->GetByteArrayRegion(env, chain, 0, 32, chain_ref.data);
47798         jboolean ret_conv = Offer_supports_chain(&this_arg_conv, chain_ref);
47799         return ret_conv;
47800 }
47801
47802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
47803         LDKOffer this_arg_conv;
47804         this_arg_conv.inner = untag_ptr(this_arg);
47805         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47807         this_arg_conv.is_owned = false;
47808         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
47809         *ret_copy = Offer_metadata(&this_arg_conv);
47810         int64_t ret_ref = tag_ptr(ret_copy, true);
47811         return ret_ref;
47812 }
47813
47814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
47815         LDKOffer this_arg_conv;
47816         this_arg_conv.inner = untag_ptr(this_arg);
47817         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47819         this_arg_conv.is_owned = false;
47820         LDKAmount ret_var = Offer_amount(&this_arg_conv);
47821         int64_t ret_ref = 0;
47822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47823         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47824         return ret_ref;
47825 }
47826
47827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
47828         LDKOffer this_arg_conv;
47829         this_arg_conv.inner = untag_ptr(this_arg);
47830         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47832         this_arg_conv.is_owned = false;
47833         LDKPrintableString ret_var = Offer_description(&this_arg_conv);
47834         int64_t ret_ref = 0;
47835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47836         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47837         return ret_ref;
47838 }
47839
47840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47841         LDKOffer this_arg_conv;
47842         this_arg_conv.inner = untag_ptr(this_arg);
47843         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47845         this_arg_conv.is_owned = false;
47846         LDKOfferFeatures ret_var = Offer_features(&this_arg_conv);
47847         int64_t ret_ref = 0;
47848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47849         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47850         return ret_ref;
47851 }
47852
47853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1absolute_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
47854         LDKOffer this_arg_conv;
47855         this_arg_conv.inner = untag_ptr(this_arg);
47856         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47858         this_arg_conv.is_owned = false;
47859         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
47860         *ret_copy = Offer_absolute_expiry(&this_arg_conv);
47861         int64_t ret_ref = tag_ptr(ret_copy, true);
47862         return ret_ref;
47863 }
47864
47865 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
47866         LDKOffer this_arg_conv;
47867         this_arg_conv.inner = untag_ptr(this_arg);
47868         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47870         this_arg_conv.is_owned = false;
47871         jboolean ret_conv = Offer_is_expired(&this_arg_conv);
47872         return ret_conv;
47873 }
47874
47875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1issuer(JNIEnv *env, jclass clz, int64_t this_arg) {
47876         LDKOffer this_arg_conv;
47877         this_arg_conv.inner = untag_ptr(this_arg);
47878         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47880         this_arg_conv.is_owned = false;
47881         LDKPrintableString ret_var = Offer_issuer(&this_arg_conv);
47882         int64_t ret_ref = 0;
47883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47884         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47885         return ret_ref;
47886 }
47887
47888 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Offer_1paths(JNIEnv *env, jclass clz, int64_t this_arg) {
47889         LDKOffer this_arg_conv;
47890         this_arg_conv.inner = untag_ptr(this_arg);
47891         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47893         this_arg_conv.is_owned = false;
47894         LDKCVec_BlindedPathZ ret_var = Offer_paths(&this_arg_conv);
47895         int64_tArray ret_arr = NULL;
47896         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47897         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47898         for (size_t n = 0; n < ret_var.datalen; n++) {
47899                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
47900                 int64_t ret_conv_13_ref = 0;
47901                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
47902                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
47903                 ret_arr_ptr[n] = ret_conv_13_ref;
47904         }
47905         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47906         FREE(ret_var.data);
47907         return ret_arr;
47908 }
47909
47910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Offer_1supported_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
47911         LDKOffer this_arg_conv;
47912         this_arg_conv.inner = untag_ptr(this_arg);
47913         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47915         this_arg_conv.is_owned = false;
47916         LDKQuantity ret_var = Offer_supported_quantity(&this_arg_conv);
47917         int64_t ret_ref = 0;
47918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47919         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47920         return ret_ref;
47921 }
47922
47923 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1is_1valid_1quantity(JNIEnv *env, jclass clz, int64_t this_arg, int64_t quantity) {
47924         LDKOffer this_arg_conv;
47925         this_arg_conv.inner = untag_ptr(this_arg);
47926         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47928         this_arg_conv.is_owned = false;
47929         jboolean ret_conv = Offer_is_valid_quantity(&this_arg_conv, quantity);
47930         return ret_conv;
47931 }
47932
47933 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Offer_1expects_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
47934         LDKOffer this_arg_conv;
47935         this_arg_conv.inner = untag_ptr(this_arg);
47936         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47938         this_arg_conv.is_owned = false;
47939         jboolean ret_conv = Offer_expects_quantity(&this_arg_conv);
47940         return ret_conv;
47941 }
47942
47943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Offer_1signing_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47950         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Offer_signing_pubkey(&this_arg_conv).compressed_form);
47951         return ret_arr;
47952 }
47953
47954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Offer_1write(JNIEnv *env, jclass clz, int64_t obj) {
47955         LDKOffer obj_conv;
47956         obj_conv.inner = untag_ptr(obj);
47957         obj_conv.is_owned = ptr_is_owned(obj);
47958         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47959         obj_conv.is_owned = false;
47960         LDKCVec_u8Z ret_var = Offer_write(&obj_conv);
47961         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47962         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47963         CVec_u8Z_free(ret_var);
47964         return ret_arr;
47965 }
47966
47967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Amount_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47968         LDKAmount this_obj_conv;
47969         this_obj_conv.inner = untag_ptr(this_obj);
47970         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47972         Amount_free(this_obj_conv);
47973 }
47974
47975 static inline uint64_t Amount_clone_ptr(LDKAmount *NONNULL_PTR arg) {
47976         LDKAmount ret_var = Amount_clone(arg);
47977         int64_t ret_ref = 0;
47978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47979         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47980         return ret_ref;
47981 }
47982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Amount_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47983         LDKAmount arg_conv;
47984         arg_conv.inner = untag_ptr(arg);
47985         arg_conv.is_owned = ptr_is_owned(arg);
47986         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47987         arg_conv.is_owned = false;
47988         int64_t ret_conv = Amount_clone_ptr(&arg_conv);
47989         return ret_conv;
47990 }
47991
47992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Amount_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47993         LDKAmount orig_conv;
47994         orig_conv.inner = untag_ptr(orig);
47995         orig_conv.is_owned = ptr_is_owned(orig);
47996         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47997         orig_conv.is_owned = false;
47998         LDKAmount ret_var = Amount_clone(&orig_conv);
47999         int64_t ret_ref = 0;
48000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48001         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48002         return ret_ref;
48003 }
48004
48005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Quantity_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48006         LDKQuantity this_obj_conv;
48007         this_obj_conv.inner = untag_ptr(this_obj);
48008         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48010         Quantity_free(this_obj_conv);
48011 }
48012
48013 static inline uint64_t Quantity_clone_ptr(LDKQuantity *NONNULL_PTR arg) {
48014         LDKQuantity ret_var = Quantity_clone(arg);
48015         int64_t ret_ref = 0;
48016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48017         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48018         return ret_ref;
48019 }
48020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Quantity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48021         LDKQuantity arg_conv;
48022         arg_conv.inner = untag_ptr(arg);
48023         arg_conv.is_owned = ptr_is_owned(arg);
48024         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48025         arg_conv.is_owned = false;
48026         int64_t ret_conv = Quantity_clone_ptr(&arg_conv);
48027         return ret_conv;
48028 }
48029
48030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Quantity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48031         LDKQuantity orig_conv;
48032         orig_conv.inner = untag_ptr(orig);
48033         orig_conv.is_owned = ptr_is_owned(orig);
48034         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48035         orig_conv.is_owned = false;
48036         LDKQuantity ret_var = Quantity_clone(&orig_conv);
48037         int64_t ret_ref = 0;
48038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48039         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48040         return ret_ref;
48041 }
48042
48043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Refund_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48044         LDKRefund this_obj_conv;
48045         this_obj_conv.inner = untag_ptr(this_obj);
48046         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48048         Refund_free(this_obj_conv);
48049 }
48050
48051 static inline uint64_t Refund_clone_ptr(LDKRefund *NONNULL_PTR arg) {
48052         LDKRefund ret_var = Refund_clone(arg);
48053         int64_t ret_ref = 0;
48054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48055         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48056         return ret_ref;
48057 }
48058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48059         LDKRefund arg_conv;
48060         arg_conv.inner = untag_ptr(arg);
48061         arg_conv.is_owned = ptr_is_owned(arg);
48062         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48063         arg_conv.is_owned = false;
48064         int64_t ret_conv = Refund_clone_ptr(&arg_conv);
48065         return ret_conv;
48066 }
48067
48068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48069         LDKRefund orig_conv;
48070         orig_conv.inner = untag_ptr(orig);
48071         orig_conv.is_owned = ptr_is_owned(orig);
48072         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48073         orig_conv.is_owned = false;
48074         LDKRefund ret_var = Refund_clone(&orig_conv);
48075         int64_t ret_ref = 0;
48076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48078         return ret_ref;
48079 }
48080
48081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
48082         LDKRefund this_arg_conv;
48083         this_arg_conv.inner = untag_ptr(this_arg);
48084         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48086         this_arg_conv.is_owned = false;
48087         LDKPrintableString ret_var = Refund_description(&this_arg_conv);
48088         int64_t ret_ref = 0;
48089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48090         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48091         return ret_ref;
48092 }
48093
48094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1absolute_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
48095         LDKRefund this_arg_conv;
48096         this_arg_conv.inner = untag_ptr(this_arg);
48097         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48099         this_arg_conv.is_owned = false;
48100         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
48101         *ret_copy = Refund_absolute_expiry(&this_arg_conv);
48102         int64_t ret_ref = tag_ptr(ret_copy, true);
48103         return ret_ref;
48104 }
48105
48106 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Refund_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
48107         LDKRefund this_arg_conv;
48108         this_arg_conv.inner = untag_ptr(this_arg);
48109         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48111         this_arg_conv.is_owned = false;
48112         jboolean ret_conv = Refund_is_expired(&this_arg_conv);
48113         return ret_conv;
48114 }
48115
48116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1issuer(JNIEnv *env, jclass clz, int64_t this_arg) {
48117         LDKRefund this_arg_conv;
48118         this_arg_conv.inner = untag_ptr(this_arg);
48119         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48121         this_arg_conv.is_owned = false;
48122         LDKPrintableString ret_var = Refund_issuer(&this_arg_conv);
48123         int64_t ret_ref = 0;
48124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48125         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48126         return ret_ref;
48127 }
48128
48129 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1paths(JNIEnv *env, jclass clz, int64_t this_arg) {
48130         LDKRefund this_arg_conv;
48131         this_arg_conv.inner = untag_ptr(this_arg);
48132         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48134         this_arg_conv.is_owned = false;
48135         LDKCVec_BlindedPathZ ret_var = Refund_paths(&this_arg_conv);
48136         int64_tArray ret_arr = NULL;
48137         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48138         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48139         for (size_t n = 0; n < ret_var.datalen; n++) {
48140                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
48141                 int64_t ret_conv_13_ref = 0;
48142                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
48143                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
48144                 ret_arr_ptr[n] = ret_conv_13_ref;
48145         }
48146         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48147         FREE(ret_var.data);
48148         return ret_arr;
48149 }
48150
48151 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
48152         LDKRefund this_arg_conv;
48153         this_arg_conv.inner = untag_ptr(this_arg);
48154         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48156         this_arg_conv.is_owned = false;
48157         LDKu8slice ret_var = Refund_metadata(&this_arg_conv);
48158         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48159         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48160         return ret_arr;
48161 }
48162
48163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1chain(JNIEnv *env, jclass clz, int64_t this_arg) {
48164         LDKRefund this_arg_conv;
48165         this_arg_conv.inner = untag_ptr(this_arg);
48166         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48168         this_arg_conv.is_owned = false;
48169         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48170         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Refund_chain(&this_arg_conv).data);
48171         return ret_arr;
48172 }
48173
48174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1amount_1msats(JNIEnv *env, jclass clz, int64_t this_arg) {
48175         LDKRefund this_arg_conv;
48176         this_arg_conv.inner = untag_ptr(this_arg);
48177         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48179         this_arg_conv.is_owned = false;
48180         int64_t ret_conv = Refund_amount_msats(&this_arg_conv);
48181         return ret_conv;
48182 }
48183
48184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
48185         LDKRefund this_arg_conv;
48186         this_arg_conv.inner = untag_ptr(this_arg);
48187         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48189         this_arg_conv.is_owned = false;
48190         LDKInvoiceRequestFeatures ret_var = Refund_features(&this_arg_conv);
48191         int64_t ret_ref = 0;
48192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48193         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48194         return ret_ref;
48195 }
48196
48197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1quantity(JNIEnv *env, jclass clz, int64_t this_arg) {
48198         LDKRefund this_arg_conv;
48199         this_arg_conv.inner = untag_ptr(this_arg);
48200         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48202         this_arg_conv.is_owned = false;
48203         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48204         *ret_copy = Refund_quantity(&this_arg_conv);
48205         int64_t ret_ref = tag_ptr(ret_copy, true);
48206         return ret_ref;
48207 }
48208
48209 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1payer_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
48210         LDKRefund this_arg_conv;
48211         this_arg_conv.inner = untag_ptr(this_arg);
48212         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48214         this_arg_conv.is_owned = false;
48215         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48216         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Refund_payer_id(&this_arg_conv).compressed_form);
48217         return ret_arr;
48218 }
48219
48220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Refund_1payer_1note(JNIEnv *env, jclass clz, int64_t this_arg) {
48221         LDKRefund this_arg_conv;
48222         this_arg_conv.inner = untag_ptr(this_arg);
48223         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48225         this_arg_conv.is_owned = false;
48226         LDKPrintableString ret_var = Refund_payer_note(&this_arg_conv);
48227         int64_t ret_ref = 0;
48228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48229         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48230         return ret_ref;
48231 }
48232
48233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Refund_1write(JNIEnv *env, jclass clz, int64_t obj) {
48234         LDKRefund obj_conv;
48235         obj_conv.inner = untag_ptr(obj);
48236         obj_conv.is_owned = ptr_is_owned(obj);
48237         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48238         obj_conv.is_owned = false;
48239         LDKCVec_u8Z ret_var = Refund_write(&obj_conv);
48240         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48241         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48242         CVec_u8Z_free(ret_var);
48243         return ret_arr;
48244 }
48245
48246 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48247         LDKUtxoLookupError* orig_conv = (LDKUtxoLookupError*)untag_ptr(orig);
48248         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_clone(orig_conv));
48249         return ret_conv;
48250 }
48251
48252 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1unknown_1chain(JNIEnv *env, jclass clz) {
48253         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_unknown_chain());
48254         return ret_conv;
48255 }
48256
48257 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_UtxoLookupError_1unknown_1tx(JNIEnv *env, jclass clz) {
48258         jclass ret_conv = LDKUtxoLookupError_to_java(env, UtxoLookupError_unknown_tx());
48259         return ret_conv;
48260 }
48261
48262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoResult_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48263         if (!ptr_is_owned(this_ptr)) return;
48264         void* this_ptr_ptr = untag_ptr(this_ptr);
48265         CHECK_ACCESS(this_ptr_ptr);
48266         LDKUtxoResult this_ptr_conv = *(LDKUtxoResult*)(this_ptr_ptr);
48267         FREE(untag_ptr(this_ptr));
48268         UtxoResult_free(this_ptr_conv);
48269 }
48270
48271 static inline uint64_t UtxoResult_clone_ptr(LDKUtxoResult *NONNULL_PTR arg) {
48272         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48273         *ret_copy = UtxoResult_clone(arg);
48274         int64_t ret_ref = tag_ptr(ret_copy, true);
48275         return ret_ref;
48276 }
48277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48278         LDKUtxoResult* arg_conv = (LDKUtxoResult*)untag_ptr(arg);
48279         int64_t ret_conv = UtxoResult_clone_ptr(arg_conv);
48280         return ret_conv;
48281 }
48282
48283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48284         LDKUtxoResult* orig_conv = (LDKUtxoResult*)untag_ptr(orig);
48285         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48286         *ret_copy = UtxoResult_clone(orig_conv);
48287         int64_t ret_ref = tag_ptr(ret_copy, true);
48288         return ret_ref;
48289 }
48290
48291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1sync(JNIEnv *env, jclass clz, int64_t a) {
48292         void* a_ptr = untag_ptr(a);
48293         CHECK_ACCESS(a_ptr);
48294         LDKCResult_TxOutUtxoLookupErrorZ a_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(a_ptr);
48295         a_conv = CResult_TxOutUtxoLookupErrorZ_clone((LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(a));
48296         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48297         *ret_copy = UtxoResult_sync(a_conv);
48298         int64_t ret_ref = tag_ptr(ret_copy, true);
48299         return ret_ref;
48300 }
48301
48302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoResult_1async(JNIEnv *env, jclass clz, int64_t a) {
48303         LDKUtxoFuture a_conv;
48304         a_conv.inner = untag_ptr(a);
48305         a_conv.is_owned = ptr_is_owned(a);
48306         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48307         a_conv = UtxoFuture_clone(&a_conv);
48308         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
48309         *ret_copy = UtxoResult_async(a_conv);
48310         int64_t ret_ref = tag_ptr(ret_copy, true);
48311         return ret_ref;
48312 }
48313
48314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoLookup_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48315         if (!ptr_is_owned(this_ptr)) return;
48316         void* this_ptr_ptr = untag_ptr(this_ptr);
48317         CHECK_ACCESS(this_ptr_ptr);
48318         LDKUtxoLookup this_ptr_conv = *(LDKUtxoLookup*)(this_ptr_ptr);
48319         FREE(untag_ptr(this_ptr));
48320         UtxoLookup_free(this_ptr_conv);
48321 }
48322
48323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48324         LDKUtxoFuture this_obj_conv;
48325         this_obj_conv.inner = untag_ptr(this_obj);
48326         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48328         UtxoFuture_free(this_obj_conv);
48329 }
48330
48331 static inline uint64_t UtxoFuture_clone_ptr(LDKUtxoFuture *NONNULL_PTR arg) {
48332         LDKUtxoFuture ret_var = UtxoFuture_clone(arg);
48333         int64_t ret_ref = 0;
48334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48335         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48336         return ret_ref;
48337 }
48338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48339         LDKUtxoFuture arg_conv;
48340         arg_conv.inner = untag_ptr(arg);
48341         arg_conv.is_owned = ptr_is_owned(arg);
48342         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48343         arg_conv.is_owned = false;
48344         int64_t ret_conv = UtxoFuture_clone_ptr(&arg_conv);
48345         return ret_conv;
48346 }
48347
48348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48349         LDKUtxoFuture orig_conv;
48350         orig_conv.inner = untag_ptr(orig);
48351         orig_conv.is_owned = ptr_is_owned(orig);
48352         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48353         orig_conv.is_owned = false;
48354         LDKUtxoFuture ret_var = UtxoFuture_clone(&orig_conv);
48355         int64_t ret_ref = 0;
48356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48358         return ret_ref;
48359 }
48360
48361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UtxoFuture_1new(JNIEnv *env, jclass clz) {
48362         LDKUtxoFuture ret_var = UtxoFuture_new();
48363         int64_t ret_ref = 0;
48364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48366         return ret_ref;
48367 }
48368
48369 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) {
48370         LDKUtxoFuture this_arg_conv;
48371         this_arg_conv.inner = untag_ptr(this_arg);
48372         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48374         this_arg_conv.is_owned = false;
48375         LDKNetworkGraph graph_conv;
48376         graph_conv.inner = untag_ptr(graph);
48377         graph_conv.is_owned = ptr_is_owned(graph);
48378         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
48379         graph_conv.is_owned = false;
48380         void* result_ptr = untag_ptr(result);
48381         CHECK_ACCESS(result_ptr);
48382         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
48383         UtxoFuture_resolve_without_forwarding(&this_arg_conv, &graph_conv, result_conv);
48384 }
48385
48386 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) {
48387         LDKUtxoFuture this_arg_conv;
48388         this_arg_conv.inner = untag_ptr(this_arg);
48389         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48391         this_arg_conv.is_owned = false;
48392         LDKNetworkGraph graph_conv;
48393         graph_conv.inner = untag_ptr(graph);
48394         graph_conv.is_owned = ptr_is_owned(graph);
48395         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
48396         graph_conv.is_owned = false;
48397         LDKP2PGossipSync gossip_conv;
48398         gossip_conv.inner = untag_ptr(gossip);
48399         gossip_conv.is_owned = ptr_is_owned(gossip);
48400         CHECK_INNER_FIELD_ACCESS_OR_NULL(gossip_conv);
48401         gossip_conv.is_owned = false;
48402         void* result_ptr = untag_ptr(result);
48403         CHECK_ACCESS(result_ptr);
48404         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
48405         UtxoFuture_resolve(&this_arg_conv, &graph_conv, &gossip_conv, result_conv);
48406 }
48407
48408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48409         LDKNodeId this_obj_conv;
48410         this_obj_conv.inner = untag_ptr(this_obj);
48411         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48413         NodeId_free(this_obj_conv);
48414 }
48415
48416 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
48417         LDKNodeId ret_var = NodeId_clone(arg);
48418         int64_t ret_ref = 0;
48419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48420         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48421         return ret_ref;
48422 }
48423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48424         LDKNodeId arg_conv;
48425         arg_conv.inner = untag_ptr(arg);
48426         arg_conv.is_owned = ptr_is_owned(arg);
48427         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48428         arg_conv.is_owned = false;
48429         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
48430         return ret_conv;
48431 }
48432
48433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48434         LDKNodeId orig_conv;
48435         orig_conv.inner = untag_ptr(orig);
48436         orig_conv.is_owned = ptr_is_owned(orig);
48437         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48438         orig_conv.is_owned = false;
48439         LDKNodeId ret_var = NodeId_clone(&orig_conv);
48440         int64_t ret_ref = 0;
48441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48442         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48443         return ret_ref;
48444 }
48445
48446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
48447         LDKPublicKey pubkey_ref;
48448         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
48449         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
48450         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
48451         int64_t ret_ref = 0;
48452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48453         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48454         return ret_ref;
48455 }
48456
48457 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
48458         LDKNodeId this_arg_conv;
48459         this_arg_conv.inner = untag_ptr(this_arg);
48460         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48462         this_arg_conv.is_owned = false;
48463         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
48464         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48465         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48466         return ret_arr;
48467 }
48468
48469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
48470         LDKNodeId this_arg_conv;
48471         this_arg_conv.inner = untag_ptr(this_arg);
48472         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48474         this_arg_conv.is_owned = false;
48475         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
48476         *ret_conv = NodeId_as_pubkey(&this_arg_conv);
48477         return tag_ptr(ret_conv, true);
48478 }
48479
48480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
48481         LDKNodeId o_conv;
48482         o_conv.inner = untag_ptr(o);
48483         o_conv.is_owned = ptr_is_owned(o);
48484         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48485         o_conv.is_owned = false;
48486         int64_t ret_conv = NodeId_hash(&o_conv);
48487         return ret_conv;
48488 }
48489
48490 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
48491         LDKNodeId obj_conv;
48492         obj_conv.inner = untag_ptr(obj);
48493         obj_conv.is_owned = ptr_is_owned(obj);
48494         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48495         obj_conv.is_owned = false;
48496         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
48497         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48498         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48499         CVec_u8Z_free(ret_var);
48500         return ret_arr;
48501 }
48502
48503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48504         LDKu8slice ser_ref;
48505         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48506         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48507         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
48508         *ret_conv = NodeId_read(ser_ref);
48509         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48510         return tag_ptr(ret_conv, true);
48511 }
48512
48513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48514         LDKNetworkGraph this_obj_conv;
48515         this_obj_conv.inner = untag_ptr(this_obj);
48516         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48518         NetworkGraph_free(this_obj_conv);
48519 }
48520
48521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48522         LDKReadOnlyNetworkGraph this_obj_conv;
48523         this_obj_conv.inner = untag_ptr(this_obj);
48524         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48526         ReadOnlyNetworkGraph_free(this_obj_conv);
48527 }
48528
48529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48530         if (!ptr_is_owned(this_ptr)) return;
48531         void* this_ptr_ptr = untag_ptr(this_ptr);
48532         CHECK_ACCESS(this_ptr_ptr);
48533         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
48534         FREE(untag_ptr(this_ptr));
48535         NetworkUpdate_free(this_ptr_conv);
48536 }
48537
48538 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
48539         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48540         *ret_copy = NetworkUpdate_clone(arg);
48541         int64_t ret_ref = tag_ptr(ret_copy, true);
48542         return ret_ref;
48543 }
48544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48545         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
48546         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
48547         return ret_conv;
48548 }
48549
48550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48551         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
48552         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48553         *ret_copy = NetworkUpdate_clone(orig_conv);
48554         int64_t ret_ref = tag_ptr(ret_copy, true);
48555         return ret_ref;
48556 }
48557
48558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
48559         LDKChannelUpdate msg_conv;
48560         msg_conv.inner = untag_ptr(msg);
48561         msg_conv.is_owned = ptr_is_owned(msg);
48562         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
48563         msg_conv = ChannelUpdate_clone(&msg_conv);
48564         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48565         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
48566         int64_t ret_ref = tag_ptr(ret_copy, true);
48567         return ret_ref;
48568 }
48569
48570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
48571         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48572         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
48573         int64_t ret_ref = tag_ptr(ret_copy, true);
48574         return ret_ref;
48575 }
48576
48577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
48578         LDKPublicKey node_id_ref;
48579         CHECK((*env)->GetArrayLength(env, node_id) == 33);
48580         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
48581         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
48582         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
48583         int64_t ret_ref = tag_ptr(ret_copy, true);
48584         return ret_ref;
48585 }
48586
48587 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48588         LDKNetworkUpdate* a_conv = (LDKNetworkUpdate*)untag_ptr(a);
48589         LDKNetworkUpdate* b_conv = (LDKNetworkUpdate*)untag_ptr(b);
48590         jboolean ret_conv = NetworkUpdate_eq(a_conv, b_conv);
48591         return ret_conv;
48592 }
48593
48594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
48595         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
48596         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
48597         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48598         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48599         CVec_u8Z_free(ret_var);
48600         return ret_arr;
48601 }
48602
48603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48604         LDKu8slice ser_ref;
48605         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48606         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48607         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
48608         *ret_conv = NetworkUpdate_read(ser_ref);
48609         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48610         return tag_ptr(ret_conv, true);
48611 }
48612
48613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48614         LDKP2PGossipSync this_obj_conv;
48615         this_obj_conv.inner = untag_ptr(this_obj);
48616         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48618         P2PGossipSync_free(this_obj_conv);
48619 }
48620
48621 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) {
48622         LDKNetworkGraph network_graph_conv;
48623         network_graph_conv.inner = untag_ptr(network_graph);
48624         network_graph_conv.is_owned = ptr_is_owned(network_graph);
48625         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
48626         network_graph_conv.is_owned = false;
48627         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
48628         CHECK_ACCESS(utxo_lookup_ptr);
48629         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
48630         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
48631         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
48632                 // Manually implement clone for Java trait instances
48633                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
48634                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48635                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
48636                 }
48637         }
48638         void* logger_ptr = untag_ptr(logger);
48639         CHECK_ACCESS(logger_ptr);
48640         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48641         if (logger_conv.free == LDKLogger_JCalls_free) {
48642                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48643                 LDKLogger_JCalls_cloned(&logger_conv);
48644         }
48645         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, utxo_lookup_conv, logger_conv);
48646         int64_t ret_ref = 0;
48647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48648         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48649         return ret_ref;
48650 }
48651
48652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1utxo_1lookup(JNIEnv *env, jclass clz, int64_t this_arg, int64_t utxo_lookup) {
48653         LDKP2PGossipSync this_arg_conv;
48654         this_arg_conv.inner = untag_ptr(this_arg);
48655         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48657         this_arg_conv.is_owned = false;
48658         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
48659         CHECK_ACCESS(utxo_lookup_ptr);
48660         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
48661         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
48662         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
48663                 // Manually implement clone for Java trait instances
48664                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
48665                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48666                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
48667                 }
48668         }
48669         P2PGossipSync_add_utxo_lookup(&this_arg_conv, utxo_lookup_conv);
48670 }
48671
48672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1handle_1network_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_update) {
48673         LDKNetworkGraph 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         LDKNetworkUpdate* network_update_conv = (LDKNetworkUpdate*)untag_ptr(network_update);
48679         NetworkGraph_handle_network_update(&this_arg_conv, network_update_conv);
48680 }
48681
48682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
48683         LDKP2PGossipSync this_arg_conv;
48684         this_arg_conv.inner = untag_ptr(this_arg);
48685         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48687         this_arg_conv.is_owned = false;
48688         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
48689         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
48690         return tag_ptr(ret_ret, true);
48691 }
48692
48693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
48694         LDKP2PGossipSync this_arg_conv;
48695         this_arg_conv.inner = untag_ptr(this_arg);
48696         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48698         this_arg_conv.is_owned = false;
48699         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
48700         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
48701         return tag_ptr(ret_ret, true);
48702 }
48703
48704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48705         LDKChannelUpdateInfo this_obj_conv;
48706         this_obj_conv.inner = untag_ptr(this_obj);
48707         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48709         ChannelUpdateInfo_free(this_obj_conv);
48710 }
48711
48712 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
48713         LDKChannelUpdateInfo this_ptr_conv;
48714         this_ptr_conv.inner = untag_ptr(this_ptr);
48715         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48717         this_ptr_conv.is_owned = false;
48718         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
48719         return ret_conv;
48720 }
48721
48722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
48723         LDKChannelUpdateInfo this_ptr_conv;
48724         this_ptr_conv.inner = untag_ptr(this_ptr);
48725         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48727         this_ptr_conv.is_owned = false;
48728         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
48729 }
48730
48731 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
48732         LDKChannelUpdateInfo this_ptr_conv;
48733         this_ptr_conv.inner = untag_ptr(this_ptr);
48734         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48736         this_ptr_conv.is_owned = false;
48737         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
48738         return ret_conv;
48739 }
48740
48741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
48742         LDKChannelUpdateInfo this_ptr_conv;
48743         this_ptr_conv.inner = untag_ptr(this_ptr);
48744         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48746         this_ptr_conv.is_owned = false;
48747         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
48748 }
48749
48750 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
48751         LDKChannelUpdateInfo this_ptr_conv;
48752         this_ptr_conv.inner = untag_ptr(this_ptr);
48753         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48755         this_ptr_conv.is_owned = false;
48756         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
48757         return ret_conv;
48758 }
48759
48760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
48761         LDKChannelUpdateInfo this_ptr_conv;
48762         this_ptr_conv.inner = untag_ptr(this_ptr);
48763         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48765         this_ptr_conv.is_owned = false;
48766         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
48767 }
48768
48769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48770         LDKChannelUpdateInfo this_ptr_conv;
48771         this_ptr_conv.inner = untag_ptr(this_ptr);
48772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48774         this_ptr_conv.is_owned = false;
48775         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
48776         return ret_conv;
48777 }
48778
48779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48780         LDKChannelUpdateInfo this_ptr_conv;
48781         this_ptr_conv.inner = untag_ptr(this_ptr);
48782         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48784         this_ptr_conv.is_owned = false;
48785         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
48786 }
48787
48788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48789         LDKChannelUpdateInfo this_ptr_conv;
48790         this_ptr_conv.inner = untag_ptr(this_ptr);
48791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48793         this_ptr_conv.is_owned = false;
48794         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
48795         return ret_conv;
48796 }
48797
48798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48799         LDKChannelUpdateInfo this_ptr_conv;
48800         this_ptr_conv.inner = untag_ptr(this_ptr);
48801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48803         this_ptr_conv.is_owned = false;
48804         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
48805 }
48806
48807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
48808         LDKChannelUpdateInfo this_ptr_conv;
48809         this_ptr_conv.inner = untag_ptr(this_ptr);
48810         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48812         this_ptr_conv.is_owned = false;
48813         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
48814         int64_t ret_ref = 0;
48815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48816         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48817         return ret_ref;
48818 }
48819
48820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48821         LDKChannelUpdateInfo this_ptr_conv;
48822         this_ptr_conv.inner = untag_ptr(this_ptr);
48823         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48825         this_ptr_conv.is_owned = false;
48826         LDKRoutingFees val_conv;
48827         val_conv.inner = untag_ptr(val);
48828         val_conv.is_owned = ptr_is_owned(val);
48829         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48830         val_conv = RoutingFees_clone(&val_conv);
48831         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
48832 }
48833
48834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
48835         LDKChannelUpdateInfo this_ptr_conv;
48836         this_ptr_conv.inner = untag_ptr(this_ptr);
48837         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48839         this_ptr_conv.is_owned = false;
48840         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
48841         int64_t ret_ref = 0;
48842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48843         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48844         return ret_ref;
48845 }
48846
48847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48848         LDKChannelUpdateInfo this_ptr_conv;
48849         this_ptr_conv.inner = untag_ptr(this_ptr);
48850         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48852         this_ptr_conv.is_owned = false;
48853         LDKChannelUpdate val_conv;
48854         val_conv.inner = untag_ptr(val);
48855         val_conv.is_owned = ptr_is_owned(val);
48856         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48857         val_conv = ChannelUpdate_clone(&val_conv);
48858         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
48859 }
48860
48861 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) {
48862         LDKRoutingFees fees_arg_conv;
48863         fees_arg_conv.inner = untag_ptr(fees_arg);
48864         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
48865         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
48866         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
48867         LDKChannelUpdate last_update_message_arg_conv;
48868         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
48869         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
48870         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
48871         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
48872         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);
48873         int64_t ret_ref = 0;
48874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48875         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48876         return ret_ref;
48877 }
48878
48879 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
48880         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
48881         int64_t ret_ref = 0;
48882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48883         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48884         return ret_ref;
48885 }
48886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48887         LDKChannelUpdateInfo arg_conv;
48888         arg_conv.inner = untag_ptr(arg);
48889         arg_conv.is_owned = ptr_is_owned(arg);
48890         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48891         arg_conv.is_owned = false;
48892         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
48893         return ret_conv;
48894 }
48895
48896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48897         LDKChannelUpdateInfo orig_conv;
48898         orig_conv.inner = untag_ptr(orig);
48899         orig_conv.is_owned = ptr_is_owned(orig);
48900         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48901         orig_conv.is_owned = false;
48902         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
48903         int64_t ret_ref = 0;
48904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48905         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48906         return ret_ref;
48907 }
48908
48909 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48910         LDKChannelUpdateInfo a_conv;
48911         a_conv.inner = untag_ptr(a);
48912         a_conv.is_owned = ptr_is_owned(a);
48913         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48914         a_conv.is_owned = false;
48915         LDKChannelUpdateInfo b_conv;
48916         b_conv.inner = untag_ptr(b);
48917         b_conv.is_owned = ptr_is_owned(b);
48918         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48919         b_conv.is_owned = false;
48920         jboolean ret_conv = ChannelUpdateInfo_eq(&a_conv, &b_conv);
48921         return ret_conv;
48922 }
48923
48924 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
48925         LDKChannelUpdateInfo obj_conv;
48926         obj_conv.inner = untag_ptr(obj);
48927         obj_conv.is_owned = ptr_is_owned(obj);
48928         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48929         obj_conv.is_owned = false;
48930         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
48931         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48932         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48933         CVec_u8Z_free(ret_var);
48934         return ret_arr;
48935 }
48936
48937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48938         LDKu8slice ser_ref;
48939         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48940         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48941         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
48942         *ret_conv = ChannelUpdateInfo_read(ser_ref);
48943         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48944         return tag_ptr(ret_conv, true);
48945 }
48946
48947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48948         LDKChannelInfo this_obj_conv;
48949         this_obj_conv.inner = untag_ptr(this_obj);
48950         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48952         ChannelInfo_free(this_obj_conv);
48953 }
48954
48955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
48956         LDKChannelInfo this_ptr_conv;
48957         this_ptr_conv.inner = untag_ptr(this_ptr);
48958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48960         this_ptr_conv.is_owned = false;
48961         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
48962         int64_t ret_ref = 0;
48963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48964         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48965         return ret_ref;
48966 }
48967
48968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48969         LDKChannelInfo this_ptr_conv;
48970         this_ptr_conv.inner = untag_ptr(this_ptr);
48971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48973         this_ptr_conv.is_owned = false;
48974         LDKChannelFeatures val_conv;
48975         val_conv.inner = untag_ptr(val);
48976         val_conv.is_owned = ptr_is_owned(val);
48977         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48978         val_conv = ChannelFeatures_clone(&val_conv);
48979         ChannelInfo_set_features(&this_ptr_conv, val_conv);
48980 }
48981
48982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
48983         LDKChannelInfo this_ptr_conv;
48984         this_ptr_conv.inner = untag_ptr(this_ptr);
48985         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48987         this_ptr_conv.is_owned = false;
48988         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
48989         int64_t ret_ref = 0;
48990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48991         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48992         return ret_ref;
48993 }
48994
48995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48996         LDKChannelInfo this_ptr_conv;
48997         this_ptr_conv.inner = untag_ptr(this_ptr);
48998         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49000         this_ptr_conv.is_owned = false;
49001         LDKNodeId val_conv;
49002         val_conv.inner = untag_ptr(val);
49003         val_conv.is_owned = ptr_is_owned(val);
49004         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49005         val_conv = NodeId_clone(&val_conv);
49006         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
49007 }
49008
49009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
49010         LDKChannelInfo this_ptr_conv;
49011         this_ptr_conv.inner = untag_ptr(this_ptr);
49012         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49014         this_ptr_conv.is_owned = false;
49015         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
49016         int64_t ret_ref = 0;
49017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49019         return ret_ref;
49020 }
49021
49022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49023         LDKChannelInfo this_ptr_conv;
49024         this_ptr_conv.inner = untag_ptr(this_ptr);
49025         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49027         this_ptr_conv.is_owned = false;
49028         LDKChannelUpdateInfo val_conv;
49029         val_conv.inner = untag_ptr(val);
49030         val_conv.is_owned = ptr_is_owned(val);
49031         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49032         val_conv = ChannelUpdateInfo_clone(&val_conv);
49033         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
49034 }
49035
49036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
49037         LDKChannelInfo this_ptr_conv;
49038         this_ptr_conv.inner = untag_ptr(this_ptr);
49039         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49041         this_ptr_conv.is_owned = false;
49042         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
49043         int64_t ret_ref = 0;
49044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49045         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49046         return ret_ref;
49047 }
49048
49049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49050         LDKChannelInfo this_ptr_conv;
49051         this_ptr_conv.inner = untag_ptr(this_ptr);
49052         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49054         this_ptr_conv.is_owned = false;
49055         LDKNodeId val_conv;
49056         val_conv.inner = untag_ptr(val);
49057         val_conv.is_owned = ptr_is_owned(val);
49058         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49059         val_conv = NodeId_clone(&val_conv);
49060         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
49061 }
49062
49063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
49064         LDKChannelInfo this_ptr_conv;
49065         this_ptr_conv.inner = untag_ptr(this_ptr);
49066         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49068         this_ptr_conv.is_owned = false;
49069         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
49070         int64_t ret_ref = 0;
49071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49072         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49073         return ret_ref;
49074 }
49075
49076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49077         LDKChannelInfo this_ptr_conv;
49078         this_ptr_conv.inner = untag_ptr(this_ptr);
49079         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49081         this_ptr_conv.is_owned = false;
49082         LDKChannelUpdateInfo val_conv;
49083         val_conv.inner = untag_ptr(val);
49084         val_conv.is_owned = ptr_is_owned(val);
49085         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49086         val_conv = ChannelUpdateInfo_clone(&val_conv);
49087         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
49088 }
49089
49090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
49091         LDKChannelInfo this_ptr_conv;
49092         this_ptr_conv.inner = untag_ptr(this_ptr);
49093         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49095         this_ptr_conv.is_owned = false;
49096         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
49097         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
49098         int64_t ret_ref = tag_ptr(ret_copy, true);
49099         return ret_ref;
49100 }
49101
49102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49103         LDKChannelInfo this_ptr_conv;
49104         this_ptr_conv.inner = untag_ptr(this_ptr);
49105         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49107         this_ptr_conv.is_owned = false;
49108         void* val_ptr = untag_ptr(val);
49109         CHECK_ACCESS(val_ptr);
49110         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
49111         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
49112         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
49113 }
49114
49115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
49116         LDKChannelInfo this_ptr_conv;
49117         this_ptr_conv.inner = untag_ptr(this_ptr);
49118         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49120         this_ptr_conv.is_owned = false;
49121         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
49122         int64_t ret_ref = 0;
49123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49124         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49125         return ret_ref;
49126 }
49127
49128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49129         LDKChannelInfo this_ptr_conv;
49130         this_ptr_conv.inner = untag_ptr(this_ptr);
49131         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49133         this_ptr_conv.is_owned = false;
49134         LDKChannelAnnouncement val_conv;
49135         val_conv.inner = untag_ptr(val);
49136         val_conv.is_owned = ptr_is_owned(val);
49137         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49138         val_conv = ChannelAnnouncement_clone(&val_conv);
49139         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
49140 }
49141
49142 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
49143         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
49144         int64_t ret_ref = 0;
49145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49147         return ret_ref;
49148 }
49149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49150         LDKChannelInfo arg_conv;
49151         arg_conv.inner = untag_ptr(arg);
49152         arg_conv.is_owned = ptr_is_owned(arg);
49153         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49154         arg_conv.is_owned = false;
49155         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
49156         return ret_conv;
49157 }
49158
49159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49160         LDKChannelInfo orig_conv;
49161         orig_conv.inner = untag_ptr(orig);
49162         orig_conv.is_owned = ptr_is_owned(orig);
49163         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49164         orig_conv.is_owned = false;
49165         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
49166         int64_t ret_ref = 0;
49167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49168         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49169         return ret_ref;
49170 }
49171
49172 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49173         LDKChannelInfo a_conv;
49174         a_conv.inner = untag_ptr(a);
49175         a_conv.is_owned = ptr_is_owned(a);
49176         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49177         a_conv.is_owned = false;
49178         LDKChannelInfo b_conv;
49179         b_conv.inner = untag_ptr(b);
49180         b_conv.is_owned = ptr_is_owned(b);
49181         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49182         b_conv.is_owned = false;
49183         jboolean ret_conv = ChannelInfo_eq(&a_conv, &b_conv);
49184         return ret_conv;
49185 }
49186
49187 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) {
49188         LDKChannelInfo this_arg_conv;
49189         this_arg_conv.inner = untag_ptr(this_arg);
49190         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49192         this_arg_conv.is_owned = false;
49193         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
49194         int64_t ret_ref = 0;
49195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49197         return ret_ref;
49198 }
49199
49200 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
49201         LDKChannelInfo obj_conv;
49202         obj_conv.inner = untag_ptr(obj);
49203         obj_conv.is_owned = ptr_is_owned(obj);
49204         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49205         obj_conv.is_owned = false;
49206         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
49207         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49208         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49209         CVec_u8Z_free(ret_var);
49210         return ret_arr;
49211 }
49212
49213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49214         LDKu8slice ser_ref;
49215         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49216         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49217         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
49218         *ret_conv = ChannelInfo_read(ser_ref);
49219         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49220         return tag_ptr(ret_conv, true);
49221 }
49222
49223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49224         LDKDirectedChannelInfo this_obj_conv;
49225         this_obj_conv.inner = untag_ptr(this_obj);
49226         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49228         DirectedChannelInfo_free(this_obj_conv);
49229 }
49230
49231 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
49232         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
49233         int64_t ret_ref = 0;
49234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49235         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49236         return ret_ref;
49237 }
49238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49239         LDKDirectedChannelInfo arg_conv;
49240         arg_conv.inner = untag_ptr(arg);
49241         arg_conv.is_owned = ptr_is_owned(arg);
49242         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49243         arg_conv.is_owned = false;
49244         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
49245         return ret_conv;
49246 }
49247
49248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49249         LDKDirectedChannelInfo orig_conv;
49250         orig_conv.inner = untag_ptr(orig);
49251         orig_conv.is_owned = ptr_is_owned(orig);
49252         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49253         orig_conv.is_owned = false;
49254         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
49255         int64_t ret_ref = 0;
49256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49257         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49258         return ret_ref;
49259 }
49260
49261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
49262         LDKDirectedChannelInfo this_arg_conv;
49263         this_arg_conv.inner = untag_ptr(this_arg);
49264         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49266         this_arg_conv.is_owned = false;
49267         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
49268         int64_t ret_ref = 0;
49269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49270         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49271         return ret_ref;
49272 }
49273
49274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
49275         LDKDirectedChannelInfo this_arg_conv;
49276         this_arg_conv.inner = untag_ptr(this_arg);
49277         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49279         this_arg_conv.is_owned = false;
49280         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
49281         return ret_conv;
49282 }
49283
49284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
49285         LDKDirectedChannelInfo this_arg_conv;
49286         this_arg_conv.inner = untag_ptr(this_arg);
49287         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49289         this_arg_conv.is_owned = false;
49290         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49291         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
49292         int64_t ret_ref = tag_ptr(ret_copy, true);
49293         return ret_ref;
49294 }
49295
49296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49297         if (!ptr_is_owned(this_ptr)) return;
49298         void* this_ptr_ptr = untag_ptr(this_ptr);
49299         CHECK_ACCESS(this_ptr_ptr);
49300         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
49301         FREE(untag_ptr(this_ptr));
49302         EffectiveCapacity_free(this_ptr_conv);
49303 }
49304
49305 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
49306         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49307         *ret_copy = EffectiveCapacity_clone(arg);
49308         int64_t ret_ref = tag_ptr(ret_copy, true);
49309         return ret_ref;
49310 }
49311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49312         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
49313         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
49314         return ret_conv;
49315 }
49316
49317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49318         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
49319         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49320         *ret_copy = EffectiveCapacity_clone(orig_conv);
49321         int64_t ret_ref = tag_ptr(ret_copy, true);
49322         return ret_ref;
49323 }
49324
49325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
49326         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49327         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
49328         int64_t ret_ref = tag_ptr(ret_copy, true);
49329         return ret_ref;
49330 }
49331
49332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
49333         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49334         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
49335         int64_t ret_ref = tag_ptr(ret_copy, true);
49336         return ret_ref;
49337 }
49338
49339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
49340         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49341         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat);
49342         int64_t ret_ref = tag_ptr(ret_copy, true);
49343         return ret_ref;
49344 }
49345
49346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
49347         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49348         *ret_copy = EffectiveCapacity_infinite();
49349         int64_t ret_ref = tag_ptr(ret_copy, true);
49350         return ret_ref;
49351 }
49352
49353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
49354         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49355         *ret_copy = EffectiveCapacity_unknown();
49356         int64_t ret_ref = tag_ptr(ret_copy, true);
49357         return ret_ref;
49358 }
49359
49360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
49361         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
49362         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
49363         return ret_conv;
49364 }
49365
49366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49367         LDKRoutingFees this_obj_conv;
49368         this_obj_conv.inner = untag_ptr(this_obj);
49369         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49371         RoutingFees_free(this_obj_conv);
49372 }
49373
49374 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49375         LDKRoutingFees this_ptr_conv;
49376         this_ptr_conv.inner = untag_ptr(this_ptr);
49377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49379         this_ptr_conv.is_owned = false;
49380         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
49381         return ret_conv;
49382 }
49383
49384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
49385         LDKRoutingFees this_ptr_conv;
49386         this_ptr_conv.inner = untag_ptr(this_ptr);
49387         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49389         this_ptr_conv.is_owned = false;
49390         RoutingFees_set_base_msat(&this_ptr_conv, val);
49391 }
49392
49393 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
49394         LDKRoutingFees this_ptr_conv;
49395         this_ptr_conv.inner = untag_ptr(this_ptr);
49396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49398         this_ptr_conv.is_owned = false;
49399         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
49400         return ret_conv;
49401 }
49402
49403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
49404         LDKRoutingFees this_ptr_conv;
49405         this_ptr_conv.inner = untag_ptr(this_ptr);
49406         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49408         this_ptr_conv.is_owned = false;
49409         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
49410 }
49411
49412 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) {
49413         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
49414         int64_t ret_ref = 0;
49415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49416         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49417         return ret_ref;
49418 }
49419
49420 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49421         LDKRoutingFees a_conv;
49422         a_conv.inner = untag_ptr(a);
49423         a_conv.is_owned = ptr_is_owned(a);
49424         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49425         a_conv.is_owned = false;
49426         LDKRoutingFees b_conv;
49427         b_conv.inner = untag_ptr(b);
49428         b_conv.is_owned = ptr_is_owned(b);
49429         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49430         b_conv.is_owned = false;
49431         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
49432         return ret_conv;
49433 }
49434
49435 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
49436         LDKRoutingFees ret_var = RoutingFees_clone(arg);
49437         int64_t ret_ref = 0;
49438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49439         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49440         return ret_ref;
49441 }
49442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49443         LDKRoutingFees arg_conv;
49444         arg_conv.inner = untag_ptr(arg);
49445         arg_conv.is_owned = ptr_is_owned(arg);
49446         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49447         arg_conv.is_owned = false;
49448         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
49449         return ret_conv;
49450 }
49451
49452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49453         LDKRoutingFees orig_conv;
49454         orig_conv.inner = untag_ptr(orig);
49455         orig_conv.is_owned = ptr_is_owned(orig);
49456         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49457         orig_conv.is_owned = false;
49458         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
49459         int64_t ret_ref = 0;
49460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49461         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49462         return ret_ref;
49463 }
49464
49465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
49466         LDKRoutingFees o_conv;
49467         o_conv.inner = untag_ptr(o);
49468         o_conv.is_owned = ptr_is_owned(o);
49469         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49470         o_conv.is_owned = false;
49471         int64_t ret_conv = RoutingFees_hash(&o_conv);
49472         return ret_conv;
49473 }
49474
49475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
49476         LDKRoutingFees obj_conv;
49477         obj_conv.inner = untag_ptr(obj);
49478         obj_conv.is_owned = ptr_is_owned(obj);
49479         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49480         obj_conv.is_owned = false;
49481         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
49482         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49483         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49484         CVec_u8Z_free(ret_var);
49485         return ret_arr;
49486 }
49487
49488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49489         LDKu8slice ser_ref;
49490         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49491         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49492         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
49493         *ret_conv = RoutingFees_read(ser_ref);
49494         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49495         return tag_ptr(ret_conv, true);
49496 }
49497
49498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49499         LDKNodeAnnouncementInfo this_obj_conv;
49500         this_obj_conv.inner = untag_ptr(this_obj);
49501         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49503         NodeAnnouncementInfo_free(this_obj_conv);
49504 }
49505
49506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
49507         LDKNodeAnnouncementInfo this_ptr_conv;
49508         this_ptr_conv.inner = untag_ptr(this_ptr);
49509         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49511         this_ptr_conv.is_owned = false;
49512         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
49513         int64_t ret_ref = 0;
49514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49515         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49516         return ret_ref;
49517 }
49518
49519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49520         LDKNodeAnnouncementInfo this_ptr_conv;
49521         this_ptr_conv.inner = untag_ptr(this_ptr);
49522         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49524         this_ptr_conv.is_owned = false;
49525         LDKNodeFeatures val_conv;
49526         val_conv.inner = untag_ptr(val);
49527         val_conv.is_owned = ptr_is_owned(val);
49528         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49529         val_conv = NodeFeatures_clone(&val_conv);
49530         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
49531 }
49532
49533 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
49534         LDKNodeAnnouncementInfo this_ptr_conv;
49535         this_ptr_conv.inner = untag_ptr(this_ptr);
49536         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49538         this_ptr_conv.is_owned = false;
49539         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
49540         return ret_conv;
49541 }
49542
49543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
49544         LDKNodeAnnouncementInfo this_ptr_conv;
49545         this_ptr_conv.inner = untag_ptr(this_ptr);
49546         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49548         this_ptr_conv.is_owned = false;
49549         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
49550 }
49551
49552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
49553         LDKNodeAnnouncementInfo this_ptr_conv;
49554         this_ptr_conv.inner = untag_ptr(this_ptr);
49555         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49557         this_ptr_conv.is_owned = false;
49558         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
49559         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
49560         return ret_arr;
49561 }
49562
49563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray 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         LDKThreeBytes val_ref;
49570         CHECK((*env)->GetArrayLength(env, val) == 3);
49571         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
49572         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
49573 }
49574
49575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
49576         LDKNodeAnnouncementInfo this_ptr_conv;
49577         this_ptr_conv.inner = untag_ptr(this_ptr);
49578         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49580         this_ptr_conv.is_owned = false;
49581         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
49582         int64_t ret_ref = 0;
49583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49584         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49585         return ret_ref;
49586 }
49587
49588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49589         LDKNodeAnnouncementInfo this_ptr_conv;
49590         this_ptr_conv.inner = untag_ptr(this_ptr);
49591         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49593         this_ptr_conv.is_owned = false;
49594         LDKNodeAlias val_conv;
49595         val_conv.inner = untag_ptr(val);
49596         val_conv.is_owned = ptr_is_owned(val);
49597         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49598         val_conv = NodeAlias_clone(&val_conv);
49599         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
49600 }
49601
49602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
49603         LDKNodeAnnouncementInfo this_ptr_conv;
49604         this_ptr_conv.inner = untag_ptr(this_ptr);
49605         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49607         this_ptr_conv.is_owned = false;
49608         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
49609         int64_t ret_ref = 0;
49610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49611         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49612         return ret_ref;
49613 }
49614
49615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49616         LDKNodeAnnouncementInfo this_ptr_conv;
49617         this_ptr_conv.inner = untag_ptr(this_ptr);
49618         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49620         this_ptr_conv.is_owned = false;
49621         LDKNodeAnnouncement val_conv;
49622         val_conv.inner = untag_ptr(val);
49623         val_conv.is_owned = ptr_is_owned(val);
49624         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49625         val_conv = NodeAnnouncement_clone(&val_conv);
49626         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
49627 }
49628
49629 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) {
49630         LDKNodeFeatures features_arg_conv;
49631         features_arg_conv.inner = untag_ptr(features_arg);
49632         features_arg_conv.is_owned = ptr_is_owned(features_arg);
49633         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
49634         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
49635         LDKThreeBytes rgb_arg_ref;
49636         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
49637         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
49638         LDKNodeAlias alias_arg_conv;
49639         alias_arg_conv.inner = untag_ptr(alias_arg);
49640         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
49641         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
49642         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
49643         LDKNodeAnnouncement announcement_message_arg_conv;
49644         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
49645         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
49646         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
49647         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
49648         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, announcement_message_arg_conv);
49649         int64_t ret_ref = 0;
49650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49651         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49652         return ret_ref;
49653 }
49654
49655 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
49656         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
49657         int64_t ret_ref = 0;
49658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49659         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49660         return ret_ref;
49661 }
49662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49663         LDKNodeAnnouncementInfo arg_conv;
49664         arg_conv.inner = untag_ptr(arg);
49665         arg_conv.is_owned = ptr_is_owned(arg);
49666         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49667         arg_conv.is_owned = false;
49668         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
49669         return ret_conv;
49670 }
49671
49672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49673         LDKNodeAnnouncementInfo orig_conv;
49674         orig_conv.inner = untag_ptr(orig);
49675         orig_conv.is_owned = ptr_is_owned(orig);
49676         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49677         orig_conv.is_owned = false;
49678         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
49679         int64_t ret_ref = 0;
49680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49681         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49682         return ret_ref;
49683 }
49684
49685 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49686         LDKNodeAnnouncementInfo a_conv;
49687         a_conv.inner = untag_ptr(a);
49688         a_conv.is_owned = ptr_is_owned(a);
49689         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49690         a_conv.is_owned = false;
49691         LDKNodeAnnouncementInfo b_conv;
49692         b_conv.inner = untag_ptr(b);
49693         b_conv.is_owned = ptr_is_owned(b);
49694         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49695         b_conv.is_owned = false;
49696         jboolean ret_conv = NodeAnnouncementInfo_eq(&a_conv, &b_conv);
49697         return ret_conv;
49698 }
49699
49700 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1addresses(JNIEnv *env, jclass clz, int64_t this_arg) {
49701         LDKNodeAnnouncementInfo this_arg_conv;
49702         this_arg_conv.inner = untag_ptr(this_arg);
49703         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49705         this_arg_conv.is_owned = false;
49706         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_addresses(&this_arg_conv);
49707         int64_tArray ret_arr = NULL;
49708         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49709         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49710         for (size_t m = 0; m < ret_var.datalen; m++) {
49711                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
49712                 *ret_conv_12_copy = ret_var.data[m];
49713                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
49714                 ret_arr_ptr[m] = ret_conv_12_ref;
49715         }
49716         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49717         FREE(ret_var.data);
49718         return ret_arr;
49719 }
49720
49721 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
49722         LDKNodeAnnouncementInfo obj_conv;
49723         obj_conv.inner = untag_ptr(obj);
49724         obj_conv.is_owned = ptr_is_owned(obj);
49725         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49726         obj_conv.is_owned = false;
49727         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
49728         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49729         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49730         CVec_u8Z_free(ret_var);
49731         return ret_arr;
49732 }
49733
49734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49735         LDKu8slice ser_ref;
49736         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49737         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49738         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
49739         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
49740         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49741         return tag_ptr(ret_conv, true);
49742 }
49743
49744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49745         LDKNodeAlias this_obj_conv;
49746         this_obj_conv.inner = untag_ptr(this_obj);
49747         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49749         NodeAlias_free(this_obj_conv);
49750 }
49751
49752 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
49753         LDKNodeAlias this_ptr_conv;
49754         this_ptr_conv.inner = untag_ptr(this_ptr);
49755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49757         this_ptr_conv.is_owned = false;
49758         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
49759         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
49760         return ret_arr;
49761 }
49762
49763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
49764         LDKNodeAlias this_ptr_conv;
49765         this_ptr_conv.inner = untag_ptr(this_ptr);
49766         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49768         this_ptr_conv.is_owned = false;
49769         LDKThirtyTwoBytes val_ref;
49770         CHECK((*env)->GetArrayLength(env, val) == 32);
49771         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
49772         NodeAlias_set_a(&this_ptr_conv, val_ref);
49773 }
49774
49775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
49776         LDKThirtyTwoBytes a_arg_ref;
49777         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
49778         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
49779         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
49780         int64_t ret_ref = 0;
49781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49782         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49783         return ret_ref;
49784 }
49785
49786 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
49787         LDKNodeAlias ret_var = NodeAlias_clone(arg);
49788         int64_t ret_ref = 0;
49789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49790         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49791         return ret_ref;
49792 }
49793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49794         LDKNodeAlias arg_conv;
49795         arg_conv.inner = untag_ptr(arg);
49796         arg_conv.is_owned = ptr_is_owned(arg);
49797         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49798         arg_conv.is_owned = false;
49799         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
49800         return ret_conv;
49801 }
49802
49803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49804         LDKNodeAlias orig_conv;
49805         orig_conv.inner = untag_ptr(orig);
49806         orig_conv.is_owned = ptr_is_owned(orig);
49807         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49808         orig_conv.is_owned = false;
49809         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
49810         int64_t ret_ref = 0;
49811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49812         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49813         return ret_ref;
49814 }
49815
49816 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAlias_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49817         LDKNodeAlias a_conv;
49818         a_conv.inner = untag_ptr(a);
49819         a_conv.is_owned = ptr_is_owned(a);
49820         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49821         a_conv.is_owned = false;
49822         LDKNodeAlias b_conv;
49823         b_conv.inner = untag_ptr(b);
49824         b_conv.is_owned = ptr_is_owned(b);
49825         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49826         b_conv.is_owned = false;
49827         jboolean ret_conv = NodeAlias_eq(&a_conv, &b_conv);
49828         return ret_conv;
49829 }
49830
49831 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
49832         LDKNodeAlias obj_conv;
49833         obj_conv.inner = untag_ptr(obj);
49834         obj_conv.is_owned = ptr_is_owned(obj);
49835         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49836         obj_conv.is_owned = false;
49837         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
49838         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49839         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49840         CVec_u8Z_free(ret_var);
49841         return ret_arr;
49842 }
49843
49844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49845         LDKu8slice ser_ref;
49846         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49847         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49848         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
49849         *ret_conv = NodeAlias_read(ser_ref);
49850         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49851         return tag_ptr(ret_conv, true);
49852 }
49853
49854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49855         LDKNodeInfo this_obj_conv;
49856         this_obj_conv.inner = untag_ptr(this_obj);
49857         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49859         NodeInfo_free(this_obj_conv);
49860 }
49861
49862 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
49863         LDKNodeInfo this_ptr_conv;
49864         this_ptr_conv.inner = untag_ptr(this_ptr);
49865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49867         this_ptr_conv.is_owned = false;
49868         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
49869         int64_tArray ret_arr = NULL;
49870         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49871         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49872         for (size_t g = 0; g < ret_var.datalen; g++) {
49873                 int64_t ret_conv_6_conv = ret_var.data[g];
49874                 ret_arr_ptr[g] = ret_conv_6_conv;
49875         }
49876         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49877         FREE(ret_var.data);
49878         return ret_arr;
49879 }
49880
49881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
49882         LDKNodeInfo this_ptr_conv;
49883         this_ptr_conv.inner = untag_ptr(this_ptr);
49884         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49886         this_ptr_conv.is_owned = false;
49887         LDKCVec_u64Z val_constr;
49888         val_constr.datalen = (*env)->GetArrayLength(env, val);
49889         if (val_constr.datalen > 0)
49890                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
49891         else
49892                 val_constr.data = NULL;
49893         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
49894         for (size_t g = 0; g < val_constr.datalen; g++) {
49895                 int64_t val_conv_6 = val_vals[g];
49896                 val_constr.data[g] = val_conv_6;
49897         }
49898         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
49899         NodeInfo_set_channels(&this_ptr_conv, val_constr);
49900 }
49901
49902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
49903         LDKNodeInfo this_ptr_conv;
49904         this_ptr_conv.inner = untag_ptr(this_ptr);
49905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49907         this_ptr_conv.is_owned = false;
49908         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
49909         int64_t ret_ref = 0;
49910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49911         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49912         return ret_ref;
49913 }
49914
49915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49916         LDKNodeInfo this_ptr_conv;
49917         this_ptr_conv.inner = untag_ptr(this_ptr);
49918         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49920         this_ptr_conv.is_owned = false;
49921         LDKNodeAnnouncementInfo val_conv;
49922         val_conv.inner = untag_ptr(val);
49923         val_conv.is_owned = ptr_is_owned(val);
49924         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49925         val_conv = NodeAnnouncementInfo_clone(&val_conv);
49926         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
49927 }
49928
49929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv *env, jclass clz, int64_tArray channels_arg, int64_t announcement_info_arg) {
49930         LDKCVec_u64Z channels_arg_constr;
49931         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
49932         if (channels_arg_constr.datalen > 0)
49933                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
49934         else
49935                 channels_arg_constr.data = NULL;
49936         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
49937         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
49938                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
49939                 channels_arg_constr.data[g] = channels_arg_conv_6;
49940         }
49941         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
49942         LDKNodeAnnouncementInfo announcement_info_arg_conv;
49943         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
49944         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
49945         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
49946         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
49947         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, announcement_info_arg_conv);
49948         int64_t ret_ref = 0;
49949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49950         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49951         return ret_ref;
49952 }
49953
49954 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
49955         LDKNodeInfo ret_var = NodeInfo_clone(arg);
49956         int64_t ret_ref = 0;
49957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49958         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49959         return ret_ref;
49960 }
49961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49962         LDKNodeInfo arg_conv;
49963         arg_conv.inner = untag_ptr(arg);
49964         arg_conv.is_owned = ptr_is_owned(arg);
49965         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49966         arg_conv.is_owned = false;
49967         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
49968         return ret_conv;
49969 }
49970
49971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49972         LDKNodeInfo orig_conv;
49973         orig_conv.inner = untag_ptr(orig);
49974         orig_conv.is_owned = ptr_is_owned(orig);
49975         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49976         orig_conv.is_owned = false;
49977         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
49978         int64_t ret_ref = 0;
49979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49980         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49981         return ret_ref;
49982 }
49983
49984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49985         LDKNodeInfo a_conv;
49986         a_conv.inner = untag_ptr(a);
49987         a_conv.is_owned = ptr_is_owned(a);
49988         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49989         a_conv.is_owned = false;
49990         LDKNodeInfo b_conv;
49991         b_conv.inner = untag_ptr(b);
49992         b_conv.is_owned = ptr_is_owned(b);
49993         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49994         b_conv.is_owned = false;
49995         jboolean ret_conv = NodeInfo_eq(&a_conv, &b_conv);
49996         return ret_conv;
49997 }
49998
49999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
50000         LDKNodeInfo obj_conv;
50001         obj_conv.inner = untag_ptr(obj);
50002         obj_conv.is_owned = ptr_is_owned(obj);
50003         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50004         obj_conv.is_owned = false;
50005         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
50006         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50007         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50008         CVec_u8Z_free(ret_var);
50009         return ret_arr;
50010 }
50011
50012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50013         LDKu8slice ser_ref;
50014         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50015         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50016         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
50017         *ret_conv = NodeInfo_read(ser_ref);
50018         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50019         return tag_ptr(ret_conv, true);
50020 }
50021
50022 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
50023         LDKNetworkGraph obj_conv;
50024         obj_conv.inner = untag_ptr(obj);
50025         obj_conv.is_owned = ptr_is_owned(obj);
50026         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50027         obj_conv.is_owned = false;
50028         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
50029         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50030         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50031         CVec_u8Z_free(ret_var);
50032         return ret_arr;
50033 }
50034
50035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
50036         LDKu8slice ser_ref;
50037         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50038         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50039         void* arg_ptr = untag_ptr(arg);
50040         CHECK_ACCESS(arg_ptr);
50041         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
50042         if (arg_conv.free == LDKLogger_JCalls_free) {
50043                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50044                 LDKLogger_JCalls_cloned(&arg_conv);
50045         }
50046         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
50047         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
50048         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50049         return tag_ptr(ret_conv, true);
50050 }
50051
50052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, jclass network, int64_t logger) {
50053         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
50054         void* logger_ptr = untag_ptr(logger);
50055         CHECK_ACCESS(logger_ptr);
50056         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50057         if (logger_conv.free == LDKLogger_JCalls_free) {
50058                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50059                 LDKLogger_JCalls_cloned(&logger_conv);
50060         }
50061         LDKNetworkGraph ret_var = NetworkGraph_new(network_conv, logger_conv);
50062         int64_t ret_ref = 0;
50063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50064         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50065         return ret_ref;
50066 }
50067
50068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
50069         LDKNetworkGraph this_arg_conv;
50070         this_arg_conv.inner = untag_ptr(this_arg);
50071         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50073         this_arg_conv.is_owned = false;
50074         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
50075         int64_t ret_ref = 0;
50076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50078         return ret_ref;
50079 }
50080
50081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
50082         LDKNetworkGraph this_arg_conv;
50083         this_arg_conv.inner = untag_ptr(this_arg);
50084         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50086         this_arg_conv.is_owned = false;
50087         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
50088         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
50089         int64_t ret_ref = tag_ptr(ret_copy, true);
50090         return ret_ref;
50091 }
50092
50093 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) {
50094         LDKNetworkGraph this_arg_conv;
50095         this_arg_conv.inner = untag_ptr(this_arg);
50096         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50098         this_arg_conv.is_owned = false;
50099         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
50100 }
50101
50102 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) {
50103         LDKNetworkGraph this_arg_conv;
50104         this_arg_conv.inner = untag_ptr(this_arg);
50105         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50107         this_arg_conv.is_owned = false;
50108         LDKNodeAnnouncement msg_conv;
50109         msg_conv.inner = untag_ptr(msg);
50110         msg_conv.is_owned = ptr_is_owned(msg);
50111         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50112         msg_conv.is_owned = false;
50113         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50114         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
50115         return tag_ptr(ret_conv, true);
50116 }
50117
50118 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) {
50119         LDKNetworkGraph this_arg_conv;
50120         this_arg_conv.inner = untag_ptr(this_arg);
50121         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50123         this_arg_conv.is_owned = false;
50124         LDKUnsignedNodeAnnouncement msg_conv;
50125         msg_conv.inner = untag_ptr(msg);
50126         msg_conv.is_owned = ptr_is_owned(msg);
50127         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50128         msg_conv.is_owned = false;
50129         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50130         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
50131         return tag_ptr(ret_conv, true);
50132 }
50133
50134 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) {
50135         LDKNetworkGraph this_arg_conv;
50136         this_arg_conv.inner = untag_ptr(this_arg);
50137         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50139         this_arg_conv.is_owned = false;
50140         LDKChannelAnnouncement msg_conv;
50141         msg_conv.inner = untag_ptr(msg);
50142         msg_conv.is_owned = ptr_is_owned(msg);
50143         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50144         msg_conv.is_owned = false;
50145         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
50146         CHECK_ACCESS(utxo_lookup_ptr);
50147         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
50148         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
50149         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
50150                 // Manually implement clone for Java trait instances
50151                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
50152                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50153                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
50154                 }
50155         }
50156         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50157         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
50158         return tag_ptr(ret_conv, true);
50159 }
50160
50161 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) {
50162         LDKNetworkGraph this_arg_conv;
50163         this_arg_conv.inner = untag_ptr(this_arg);
50164         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50166         this_arg_conv.is_owned = false;
50167         LDKUnsignedChannelAnnouncement msg_conv;
50168         msg_conv.inner = untag_ptr(msg);
50169         msg_conv.is_owned = ptr_is_owned(msg);
50170         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50171         msg_conv.is_owned = false;
50172         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
50173         CHECK_ACCESS(utxo_lookup_ptr);
50174         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
50175         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
50176         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
50177                 // Manually implement clone for Java trait instances
50178                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
50179                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50180                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
50181                 }
50182         }
50183         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50184         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
50185         return tag_ptr(ret_conv, true);
50186 }
50187
50188 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) {
50189         LDKNetworkGraph this_arg_conv;
50190         this_arg_conv.inner = untag_ptr(this_arg);
50191         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50193         this_arg_conv.is_owned = false;
50194         LDKChannelFeatures features_conv;
50195         features_conv.inner = untag_ptr(features);
50196         features_conv.is_owned = ptr_is_owned(features);
50197         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
50198         features_conv = ChannelFeatures_clone(&features_conv);
50199         LDKPublicKey node_id_1_ref;
50200         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
50201         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
50202         LDKPublicKey node_id_2_ref;
50203         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
50204         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
50205         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50206         *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);
50207         return tag_ptr(ret_conv, true);
50208 }
50209
50210 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) {
50211         LDKNetworkGraph this_arg_conv;
50212         this_arg_conv.inner = untag_ptr(this_arg);
50213         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50215         this_arg_conv.is_owned = false;
50216         NetworkGraph_channel_failed_permanent(&this_arg_conv, short_channel_id);
50217 }
50218
50219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed_1permanent(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray node_id) {
50220         LDKNetworkGraph this_arg_conv;
50221         this_arg_conv.inner = untag_ptr(this_arg);
50222         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50224         this_arg_conv.is_owned = false;
50225         LDKPublicKey node_id_ref;
50226         CHECK((*env)->GetArrayLength(env, node_id) == 33);
50227         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
50228         NetworkGraph_node_failed_permanent(&this_arg_conv, node_id_ref);
50229 }
50230
50231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels_1and_1tracking(JNIEnv *env, jclass clz, int64_t this_arg) {
50232         LDKNetworkGraph this_arg_conv;
50233         this_arg_conv.inner = untag_ptr(this_arg);
50234         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50236         this_arg_conv.is_owned = false;
50237         NetworkGraph_remove_stale_channels_and_tracking(&this_arg_conv);
50238 }
50239
50240 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) {
50241         LDKNetworkGraph this_arg_conv;
50242         this_arg_conv.inner = untag_ptr(this_arg);
50243         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50245         this_arg_conv.is_owned = false;
50246         NetworkGraph_remove_stale_channels_and_tracking_with_time(&this_arg_conv, current_time_unix);
50247 }
50248
50249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
50250         LDKNetworkGraph this_arg_conv;
50251         this_arg_conv.inner = untag_ptr(this_arg);
50252         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50254         this_arg_conv.is_owned = false;
50255         LDKChannelUpdate msg_conv;
50256         msg_conv.inner = untag_ptr(msg);
50257         msg_conv.is_owned = ptr_is_owned(msg);
50258         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50259         msg_conv.is_owned = false;
50260         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50261         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
50262         return tag_ptr(ret_conv, true);
50263 }
50264
50265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
50266         LDKNetworkGraph this_arg_conv;
50267         this_arg_conv.inner = untag_ptr(this_arg);
50268         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50270         this_arg_conv.is_owned = false;
50271         LDKUnsignedChannelUpdate msg_conv;
50272         msg_conv.inner = untag_ptr(msg);
50273         msg_conv.is_owned = ptr_is_owned(msg);
50274         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
50275         msg_conv.is_owned = false;
50276         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
50277         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
50278         return tag_ptr(ret_conv, true);
50279 }
50280
50281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
50282         LDKReadOnlyNetworkGraph this_arg_conv;
50283         this_arg_conv.inner = untag_ptr(this_arg);
50284         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50286         this_arg_conv.is_owned = false;
50287         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
50288         int64_t ret_ref = 0;
50289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50290         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50291         return ret_ref;
50292 }
50293
50294 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
50295         LDKReadOnlyNetworkGraph this_arg_conv;
50296         this_arg_conv.inner = untag_ptr(this_arg);
50297         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50299         this_arg_conv.is_owned = false;
50300         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
50301         int64_tArray ret_arr = NULL;
50302         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50303         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50304         for (size_t g = 0; g < ret_var.datalen; g++) {
50305                 int64_t ret_conv_6_conv = ret_var.data[g];
50306                 ret_arr_ptr[g] = ret_conv_6_conv;
50307         }
50308         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50309         FREE(ret_var.data);
50310         return ret_arr;
50311 }
50312
50313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
50314         LDKReadOnlyNetworkGraph this_arg_conv;
50315         this_arg_conv.inner = untag_ptr(this_arg);
50316         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50318         this_arg_conv.is_owned = false;
50319         LDKNodeId node_id_conv;
50320         node_id_conv.inner = untag_ptr(node_id);
50321         node_id_conv.is_owned = ptr_is_owned(node_id);
50322         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
50323         node_id_conv.is_owned = false;
50324         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
50325         int64_t ret_ref = 0;
50326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50327         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50328         return ret_ref;
50329 }
50330
50331 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1nodes(JNIEnv *env, jclass clz, int64_t this_arg) {
50332         LDKReadOnlyNetworkGraph this_arg_conv;
50333         this_arg_conv.inner = untag_ptr(this_arg);
50334         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50336         this_arg_conv.is_owned = false;
50337         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
50338         int64_tArray ret_arr = NULL;
50339         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50340         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50341         for (size_t i = 0; i < ret_var.datalen; i++) {
50342                 LDKNodeId ret_conv_8_var = ret_var.data[i];
50343                 int64_t ret_conv_8_ref = 0;
50344                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
50345                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
50346                 ret_arr_ptr[i] = ret_conv_8_ref;
50347         }
50348         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50349         FREE(ret_var.data);
50350         return ret_arr;
50351 }
50352
50353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
50354         LDKReadOnlyNetworkGraph this_arg_conv;
50355         this_arg_conv.inner = untag_ptr(this_arg);
50356         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50358         this_arg_conv.is_owned = false;
50359         LDKPublicKey pubkey_ref;
50360         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
50361         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
50362         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
50363         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
50364         int64_t ret_ref = tag_ptr(ret_copy, true);
50365         return ret_ref;
50366 }
50367
50368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50369         LDKDefaultRouter this_obj_conv;
50370         this_obj_conv.inner = untag_ptr(this_obj);
50371         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50373         DefaultRouter_free(this_obj_conv);
50374 }
50375
50376 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) {
50377         LDKNetworkGraph network_graph_conv;
50378         network_graph_conv.inner = untag_ptr(network_graph);
50379         network_graph_conv.is_owned = ptr_is_owned(network_graph);
50380         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
50381         network_graph_conv.is_owned = false;
50382         void* logger_ptr = untag_ptr(logger);
50383         CHECK_ACCESS(logger_ptr);
50384         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50385         if (logger_conv.free == LDKLogger_JCalls_free) {
50386                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50387                 LDKLogger_JCalls_cloned(&logger_conv);
50388         }
50389         LDKThirtyTwoBytes random_seed_bytes_ref;
50390         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
50391         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
50392         void* scorer_ptr = untag_ptr(scorer);
50393         CHECK_ACCESS(scorer_ptr);
50394         LDKLockableScore scorer_conv = *(LDKLockableScore*)(scorer_ptr);
50395         if (scorer_conv.free == LDKLockableScore_JCalls_free) {
50396                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50397                 LDKLockableScore_JCalls_cloned(&scorer_conv);
50398         }
50399         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref, scorer_conv);
50400         int64_t ret_ref = 0;
50401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50402         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50403         return ret_ref;
50404 }
50405
50406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
50407         LDKDefaultRouter this_arg_conv;
50408         this_arg_conv.inner = untag_ptr(this_arg);
50409         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50411         this_arg_conv.is_owned = false;
50412         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
50413         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
50414         return tag_ptr(ret_ret, true);
50415 }
50416
50417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50418         if (!ptr_is_owned(this_ptr)) return;
50419         void* this_ptr_ptr = untag_ptr(this_ptr);
50420         CHECK_ACCESS(this_ptr_ptr);
50421         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
50422         FREE(untag_ptr(this_ptr));
50423         Router_free(this_ptr_conv);
50424 }
50425
50426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50427         LDKScorerAccountingForInFlightHtlcs this_obj_conv;
50428         this_obj_conv.inner = untag_ptr(this_obj);
50429         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50431         ScorerAccountingForInFlightHtlcs_free(this_obj_conv);
50432 }
50433
50434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1new(JNIEnv *env, jclass clz, int64_t scorer, int64_t inflight_htlcs) {
50435         void* scorer_ptr = untag_ptr(scorer);
50436         CHECK_ACCESS(scorer_ptr);
50437         LDKScore scorer_conv = *(LDKScore*)(scorer_ptr);
50438         if (scorer_conv.free == LDKScore_JCalls_free) {
50439                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50440                 LDKScore_JCalls_cloned(&scorer_conv);
50441         }
50442         LDKInFlightHtlcs inflight_htlcs_conv;
50443         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
50444         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
50445         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
50446         inflight_htlcs_conv.is_owned = false;
50447         LDKScorerAccountingForInFlightHtlcs ret_var = ScorerAccountingForInFlightHtlcs_new(scorer_conv, &inflight_htlcs_conv);
50448         int64_t ret_ref = 0;
50449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50450         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50451         return ret_ref;
50452 }
50453
50454 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
50455         LDKScorerAccountingForInFlightHtlcs obj_conv;
50456         obj_conv.inner = untag_ptr(obj);
50457         obj_conv.is_owned = ptr_is_owned(obj);
50458         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50459         obj_conv.is_owned = false;
50460         LDKCVec_u8Z ret_var = ScorerAccountingForInFlightHtlcs_write(&obj_conv);
50461         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50462         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50463         CVec_u8Z_free(ret_var);
50464         return ret_arr;
50465 }
50466
50467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
50468         LDKScorerAccountingForInFlightHtlcs this_arg_conv;
50469         this_arg_conv.inner = untag_ptr(this_arg);
50470         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50472         this_arg_conv.is_owned = false;
50473         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
50474         *ret_ret = ScorerAccountingForInFlightHtlcs_as_Score(&this_arg_conv);
50475         return tag_ptr(ret_ret, true);
50476 }
50477
50478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50479         LDKInFlightHtlcs this_obj_conv;
50480         this_obj_conv.inner = untag_ptr(this_obj);
50481         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50483         InFlightHtlcs_free(this_obj_conv);
50484 }
50485
50486 static inline uint64_t InFlightHtlcs_clone_ptr(LDKInFlightHtlcs *NONNULL_PTR arg) {
50487         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(arg);
50488         int64_t ret_ref = 0;
50489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50490         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50491         return ret_ref;
50492 }
50493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50494         LDKInFlightHtlcs arg_conv;
50495         arg_conv.inner = untag_ptr(arg);
50496         arg_conv.is_owned = ptr_is_owned(arg);
50497         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50498         arg_conv.is_owned = false;
50499         int64_t ret_conv = InFlightHtlcs_clone_ptr(&arg_conv);
50500         return ret_conv;
50501 }
50502
50503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50504         LDKInFlightHtlcs orig_conv;
50505         orig_conv.inner = untag_ptr(orig);
50506         orig_conv.is_owned = ptr_is_owned(orig);
50507         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50508         orig_conv.is_owned = false;
50509         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(&orig_conv);
50510         int64_t ret_ref = 0;
50511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50512         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50513         return ret_ref;
50514 }
50515
50516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1new(JNIEnv *env, jclass clz) {
50517         LDKInFlightHtlcs ret_var = InFlightHtlcs_new();
50518         int64_t ret_ref = 0;
50519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50520         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50521         return ret_ref;
50522 }
50523
50524 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) {
50525         LDKInFlightHtlcs this_arg_conv;
50526         this_arg_conv.inner = untag_ptr(this_arg);
50527         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50529         this_arg_conv.is_owned = false;
50530         LDKPath path_conv;
50531         path_conv.inner = untag_ptr(path);
50532         path_conv.is_owned = ptr_is_owned(path);
50533         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
50534         path_conv.is_owned = false;
50535         LDKPublicKey payer_node_id_ref;
50536         CHECK((*env)->GetArrayLength(env, payer_node_id) == 33);
50537         (*env)->GetByteArrayRegion(env, payer_node_id, 0, 33, payer_node_id_ref.compressed_form);
50538         InFlightHtlcs_process_path(&this_arg_conv, &path_conv, payer_node_id_ref);
50539 }
50540
50541 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) {
50542         LDKInFlightHtlcs this_arg_conv;
50543         this_arg_conv.inner = untag_ptr(this_arg);
50544         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50546         this_arg_conv.is_owned = false;
50547         LDKNodeId source_conv;
50548         source_conv.inner = untag_ptr(source);
50549         source_conv.is_owned = ptr_is_owned(source);
50550         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
50551         source_conv.is_owned = false;
50552         LDKNodeId target_conv;
50553         target_conv.inner = untag_ptr(target);
50554         target_conv.is_owned = ptr_is_owned(target);
50555         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
50556         target_conv.is_owned = false;
50557         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
50558         *ret_copy = InFlightHtlcs_used_liquidity_msat(&this_arg_conv, &source_conv, &target_conv, channel_scid);
50559         int64_t ret_ref = tag_ptr(ret_copy, true);
50560         return ret_ref;
50561 }
50562
50563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
50564         LDKInFlightHtlcs obj_conv;
50565         obj_conv.inner = untag_ptr(obj);
50566         obj_conv.is_owned = ptr_is_owned(obj);
50567         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50568         obj_conv.is_owned = false;
50569         LDKCVec_u8Z ret_var = InFlightHtlcs_write(&obj_conv);
50570         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50571         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50572         CVec_u8Z_free(ret_var);
50573         return ret_arr;
50574 }
50575
50576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50577         LDKu8slice ser_ref;
50578         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50579         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50580         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
50581         *ret_conv = InFlightHtlcs_read(ser_ref);
50582         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50583         return tag_ptr(ret_conv, true);
50584 }
50585
50586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50587         LDKRouteHop this_obj_conv;
50588         this_obj_conv.inner = untag_ptr(this_obj);
50589         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50591         RouteHop_free(this_obj_conv);
50592 }
50593
50594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
50595         LDKRouteHop this_ptr_conv;
50596         this_ptr_conv.inner = untag_ptr(this_ptr);
50597         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50599         this_ptr_conv.is_owned = false;
50600         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50601         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
50602         return ret_arr;
50603 }
50604
50605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
50606         LDKRouteHop this_ptr_conv;
50607         this_ptr_conv.inner = untag_ptr(this_ptr);
50608         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50610         this_ptr_conv.is_owned = false;
50611         LDKPublicKey val_ref;
50612         CHECK((*env)->GetArrayLength(env, val) == 33);
50613         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
50614         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
50615 }
50616
50617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
50618         LDKRouteHop this_ptr_conv;
50619         this_ptr_conv.inner = untag_ptr(this_ptr);
50620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50622         this_ptr_conv.is_owned = false;
50623         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
50624         int64_t ret_ref = 0;
50625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50626         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50627         return ret_ref;
50628 }
50629
50630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50631         LDKRouteHop this_ptr_conv;
50632         this_ptr_conv.inner = untag_ptr(this_ptr);
50633         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50635         this_ptr_conv.is_owned = false;
50636         LDKNodeFeatures val_conv;
50637         val_conv.inner = untag_ptr(val);
50638         val_conv.is_owned = ptr_is_owned(val);
50639         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
50640         val_conv = NodeFeatures_clone(&val_conv);
50641         RouteHop_set_node_features(&this_ptr_conv, val_conv);
50642 }
50643
50644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
50645         LDKRouteHop this_ptr_conv;
50646         this_ptr_conv.inner = untag_ptr(this_ptr);
50647         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50649         this_ptr_conv.is_owned = false;
50650         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
50651         return ret_conv;
50652 }
50653
50654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50655         LDKRouteHop this_ptr_conv;
50656         this_ptr_conv.inner = untag_ptr(this_ptr);
50657         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50659         this_ptr_conv.is_owned = false;
50660         RouteHop_set_short_channel_id(&this_ptr_conv, val);
50661 }
50662
50663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
50664         LDKRouteHop this_ptr_conv;
50665         this_ptr_conv.inner = untag_ptr(this_ptr);
50666         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50668         this_ptr_conv.is_owned = false;
50669         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
50670         int64_t ret_ref = 0;
50671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50672         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50673         return ret_ref;
50674 }
50675
50676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50677         LDKRouteHop this_ptr_conv;
50678         this_ptr_conv.inner = untag_ptr(this_ptr);
50679         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50681         this_ptr_conv.is_owned = false;
50682         LDKChannelFeatures val_conv;
50683         val_conv.inner = untag_ptr(val);
50684         val_conv.is_owned = ptr_is_owned(val);
50685         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
50686         val_conv = ChannelFeatures_clone(&val_conv);
50687         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
50688 }
50689
50690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50691         LDKRouteHop this_ptr_conv;
50692         this_ptr_conv.inner = untag_ptr(this_ptr);
50693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50695         this_ptr_conv.is_owned = false;
50696         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
50697         return ret_conv;
50698 }
50699
50700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50701         LDKRouteHop this_ptr_conv;
50702         this_ptr_conv.inner = untag_ptr(this_ptr);
50703         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50705         this_ptr_conv.is_owned = false;
50706         RouteHop_set_fee_msat(&this_ptr_conv, val);
50707 }
50708
50709 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
50710         LDKRouteHop this_ptr_conv;
50711         this_ptr_conv.inner = untag_ptr(this_ptr);
50712         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50714         this_ptr_conv.is_owned = false;
50715         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
50716         return ret_conv;
50717 }
50718
50719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
50720         LDKRouteHop this_ptr_conv;
50721         this_ptr_conv.inner = untag_ptr(this_ptr);
50722         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50724         this_ptr_conv.is_owned = false;
50725         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
50726 }
50727
50728 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) {
50729         LDKPublicKey pubkey_arg_ref;
50730         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
50731         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
50732         LDKNodeFeatures node_features_arg_conv;
50733         node_features_arg_conv.inner = untag_ptr(node_features_arg);
50734         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
50735         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
50736         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
50737         LDKChannelFeatures channel_features_arg_conv;
50738         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
50739         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
50740         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
50741         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
50742         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);
50743         int64_t ret_ref = 0;
50744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50745         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50746         return ret_ref;
50747 }
50748
50749 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
50750         LDKRouteHop ret_var = RouteHop_clone(arg);
50751         int64_t ret_ref = 0;
50752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50753         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50754         return ret_ref;
50755 }
50756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50757         LDKRouteHop arg_conv;
50758         arg_conv.inner = untag_ptr(arg);
50759         arg_conv.is_owned = ptr_is_owned(arg);
50760         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50761         arg_conv.is_owned = false;
50762         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
50763         return ret_conv;
50764 }
50765
50766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50767         LDKRouteHop orig_conv;
50768         orig_conv.inner = untag_ptr(orig);
50769         orig_conv.is_owned = ptr_is_owned(orig);
50770         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50771         orig_conv.is_owned = false;
50772         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
50773         int64_t ret_ref = 0;
50774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50775         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50776         return ret_ref;
50777 }
50778
50779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
50780         LDKRouteHop o_conv;
50781         o_conv.inner = untag_ptr(o);
50782         o_conv.is_owned = ptr_is_owned(o);
50783         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50784         o_conv.is_owned = false;
50785         int64_t ret_conv = RouteHop_hash(&o_conv);
50786         return ret_conv;
50787 }
50788
50789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50790         LDKRouteHop a_conv;
50791         a_conv.inner = untag_ptr(a);
50792         a_conv.is_owned = ptr_is_owned(a);
50793         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50794         a_conv.is_owned = false;
50795         LDKRouteHop b_conv;
50796         b_conv.inner = untag_ptr(b);
50797         b_conv.is_owned = ptr_is_owned(b);
50798         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50799         b_conv.is_owned = false;
50800         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
50801         return ret_conv;
50802 }
50803
50804 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
50805         LDKRouteHop obj_conv;
50806         obj_conv.inner = untag_ptr(obj);
50807         obj_conv.is_owned = ptr_is_owned(obj);
50808         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50809         obj_conv.is_owned = false;
50810         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
50811         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50812         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50813         CVec_u8Z_free(ret_var);
50814         return ret_arr;
50815 }
50816
50817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50818         LDKu8slice ser_ref;
50819         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50820         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50821         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
50822         *ret_conv = RouteHop_read(ser_ref);
50823         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50824         return tag_ptr(ret_conv, true);
50825 }
50826
50827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50828         LDKBlindedTail this_obj_conv;
50829         this_obj_conv.inner = untag_ptr(this_obj);
50830         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50832         BlindedTail_free(this_obj_conv);
50833 }
50834
50835 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1hops(JNIEnv *env, jclass clz, int64_t this_ptr) {
50836         LDKBlindedTail this_ptr_conv;
50837         this_ptr_conv.inner = untag_ptr(this_ptr);
50838         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50840         this_ptr_conv.is_owned = false;
50841         LDKCVec_BlindedHopZ ret_var = BlindedTail_get_hops(&this_ptr_conv);
50842         int64_tArray ret_arr = NULL;
50843         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
50844         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
50845         for (size_t m = 0; m < ret_var.datalen; m++) {
50846                 LDKBlindedHop ret_conv_12_var = ret_var.data[m];
50847                 int64_t ret_conv_12_ref = 0;
50848                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_var);
50849                 ret_conv_12_ref = tag_ptr(ret_conv_12_var.inner, ret_conv_12_var.is_owned);
50850                 ret_arr_ptr[m] = ret_conv_12_ref;
50851         }
50852         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
50853         FREE(ret_var.data);
50854         return ret_arr;
50855 }
50856
50857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1hops(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
50858         LDKBlindedTail this_ptr_conv;
50859         this_ptr_conv.inner = untag_ptr(this_ptr);
50860         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50862         this_ptr_conv.is_owned = false;
50863         LDKCVec_BlindedHopZ val_constr;
50864         val_constr.datalen = (*env)->GetArrayLength(env, val);
50865         if (val_constr.datalen > 0)
50866                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
50867         else
50868                 val_constr.data = NULL;
50869         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
50870         for (size_t m = 0; m < val_constr.datalen; m++) {
50871                 int64_t val_conv_12 = val_vals[m];
50872                 LDKBlindedHop val_conv_12_conv;
50873                 val_conv_12_conv.inner = untag_ptr(val_conv_12);
50874                 val_conv_12_conv.is_owned = ptr_is_owned(val_conv_12);
50875                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv);
50876                 val_conv_12_conv = BlindedHop_clone(&val_conv_12_conv);
50877                 val_constr.data[m] = val_conv_12_conv;
50878         }
50879         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
50880         BlindedTail_set_hops(&this_ptr_conv, val_constr);
50881 }
50882
50883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
50884         LDKBlindedTail this_ptr_conv;
50885         this_ptr_conv.inner = untag_ptr(this_ptr);
50886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50888         this_ptr_conv.is_owned = false;
50889         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
50890         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, BlindedTail_get_blinding_point(&this_ptr_conv).compressed_form);
50891         return ret_arr;
50892 }
50893
50894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
50895         LDKBlindedTail this_ptr_conv;
50896         this_ptr_conv.inner = untag_ptr(this_ptr);
50897         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50899         this_ptr_conv.is_owned = false;
50900         LDKPublicKey val_ref;
50901         CHECK((*env)->GetArrayLength(env, val) == 33);
50902         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
50903         BlindedTail_set_blinding_point(&this_ptr_conv, val_ref);
50904 }
50905
50906 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1excess_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
50907         LDKBlindedTail this_ptr_conv;
50908         this_ptr_conv.inner = untag_ptr(this_ptr);
50909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50911         this_ptr_conv.is_owned = false;
50912         int32_t ret_conv = BlindedTail_get_excess_final_cltv_expiry_delta(&this_ptr_conv);
50913         return ret_conv;
50914 }
50915
50916 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) {
50917         LDKBlindedTail this_ptr_conv;
50918         this_ptr_conv.inner = untag_ptr(this_ptr);
50919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50921         this_ptr_conv.is_owned = false;
50922         BlindedTail_set_excess_final_cltv_expiry_delta(&this_ptr_conv, val);
50923 }
50924
50925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50926         LDKBlindedTail this_ptr_conv;
50927         this_ptr_conv.inner = untag_ptr(this_ptr);
50928         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50930         this_ptr_conv.is_owned = false;
50931         int64_t ret_conv = BlindedTail_get_final_value_msat(&this_ptr_conv);
50932         return ret_conv;
50933 }
50934
50935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedTail_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
50936         LDKBlindedTail this_ptr_conv;
50937         this_ptr_conv.inner = untag_ptr(this_ptr);
50938         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50940         this_ptr_conv.is_owned = false;
50941         BlindedTail_set_final_value_msat(&this_ptr_conv, val);
50942 }
50943
50944 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) {
50945         LDKCVec_BlindedHopZ hops_arg_constr;
50946         hops_arg_constr.datalen = (*env)->GetArrayLength(env, hops_arg);
50947         if (hops_arg_constr.datalen > 0)
50948                 hops_arg_constr.data = MALLOC(hops_arg_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
50949         else
50950                 hops_arg_constr.data = NULL;
50951         int64_t* hops_arg_vals = (*env)->GetLongArrayElements (env, hops_arg, NULL);
50952         for (size_t m = 0; m < hops_arg_constr.datalen; m++) {
50953                 int64_t hops_arg_conv_12 = hops_arg_vals[m];
50954                 LDKBlindedHop hops_arg_conv_12_conv;
50955                 hops_arg_conv_12_conv.inner = untag_ptr(hops_arg_conv_12);
50956                 hops_arg_conv_12_conv.is_owned = ptr_is_owned(hops_arg_conv_12);
50957                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_arg_conv_12_conv);
50958                 hops_arg_conv_12_conv = BlindedHop_clone(&hops_arg_conv_12_conv);
50959                 hops_arg_constr.data[m] = hops_arg_conv_12_conv;
50960         }
50961         (*env)->ReleaseLongArrayElements(env, hops_arg, hops_arg_vals, 0);
50962         LDKPublicKey blinding_point_arg_ref;
50963         CHECK((*env)->GetArrayLength(env, blinding_point_arg) == 33);
50964         (*env)->GetByteArrayRegion(env, blinding_point_arg, 0, 33, blinding_point_arg_ref.compressed_form);
50965         LDKBlindedTail ret_var = BlindedTail_new(hops_arg_constr, blinding_point_arg_ref, excess_final_cltv_expiry_delta_arg, final_value_msat_arg);
50966         int64_t ret_ref = 0;
50967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50968         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50969         return ret_ref;
50970 }
50971
50972 static inline uint64_t BlindedTail_clone_ptr(LDKBlindedTail *NONNULL_PTR arg) {
50973         LDKBlindedTail ret_var = BlindedTail_clone(arg);
50974         int64_t ret_ref = 0;
50975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50976         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50977         return ret_ref;
50978 }
50979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50980         LDKBlindedTail arg_conv;
50981         arg_conv.inner = untag_ptr(arg);
50982         arg_conv.is_owned = ptr_is_owned(arg);
50983         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50984         arg_conv.is_owned = false;
50985         int64_t ret_conv = BlindedTail_clone_ptr(&arg_conv);
50986         return ret_conv;
50987 }
50988
50989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50990         LDKBlindedTail orig_conv;
50991         orig_conv.inner = untag_ptr(orig);
50992         orig_conv.is_owned = ptr_is_owned(orig);
50993         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50994         orig_conv.is_owned = false;
50995         LDKBlindedTail ret_var = BlindedTail_clone(&orig_conv);
50996         int64_t ret_ref = 0;
50997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50998         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50999         return ret_ref;
51000 }
51001
51002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1hash(JNIEnv *env, jclass clz, int64_t o) {
51003         LDKBlindedTail o_conv;
51004         o_conv.inner = untag_ptr(o);
51005         o_conv.is_owned = ptr_is_owned(o);
51006         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51007         o_conv.is_owned = false;
51008         int64_t ret_conv = BlindedTail_hash(&o_conv);
51009         return ret_conv;
51010 }
51011
51012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedTail_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51013         LDKBlindedTail a_conv;
51014         a_conv.inner = untag_ptr(a);
51015         a_conv.is_owned = ptr_is_owned(a);
51016         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51017         a_conv.is_owned = false;
51018         LDKBlindedTail b_conv;
51019         b_conv.inner = untag_ptr(b);
51020         b_conv.is_owned = ptr_is_owned(b);
51021         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51022         b_conv.is_owned = false;
51023         jboolean ret_conv = BlindedTail_eq(&a_conv, &b_conv);
51024         return ret_conv;
51025 }
51026
51027 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedTail_1write(JNIEnv *env, jclass clz, int64_t obj) {
51028         LDKBlindedTail obj_conv;
51029         obj_conv.inner = untag_ptr(obj);
51030         obj_conv.is_owned = ptr_is_owned(obj);
51031         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51032         obj_conv.is_owned = false;
51033         LDKCVec_u8Z ret_var = BlindedTail_write(&obj_conv);
51034         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51035         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51036         CVec_u8Z_free(ret_var);
51037         return ret_arr;
51038 }
51039
51040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedTail_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51041         LDKu8slice ser_ref;
51042         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51043         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51044         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
51045         *ret_conv = BlindedTail_read(ser_ref);
51046         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51047         return tag_ptr(ret_conv, true);
51048 }
51049
51050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Path_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51051         LDKPath this_obj_conv;
51052         this_obj_conv.inner = untag_ptr(this_obj);
51053         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51055         Path_free(this_obj_conv);
51056 }
51057
51058 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Path_1get_1hops(JNIEnv *env, jclass clz, int64_t this_ptr) {
51059         LDKPath this_ptr_conv;
51060         this_ptr_conv.inner = untag_ptr(this_ptr);
51061         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51063         this_ptr_conv.is_owned = false;
51064         LDKCVec_RouteHopZ ret_var = Path_get_hops(&this_ptr_conv);
51065         int64_tArray ret_arr = NULL;
51066         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
51067         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
51068         for (size_t k = 0; k < ret_var.datalen; k++) {
51069                 LDKRouteHop ret_conv_10_var = ret_var.data[k];
51070                 int64_t ret_conv_10_ref = 0;
51071                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
51072                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
51073                 ret_arr_ptr[k] = ret_conv_10_ref;
51074         }
51075         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
51076         FREE(ret_var.data);
51077         return ret_arr;
51078 }
51079
51080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Path_1set_1hops(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
51081         LDKPath this_ptr_conv;
51082         this_ptr_conv.inner = untag_ptr(this_ptr);
51083         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51085         this_ptr_conv.is_owned = false;
51086         LDKCVec_RouteHopZ val_constr;
51087         val_constr.datalen = (*env)->GetArrayLength(env, val);
51088         if (val_constr.datalen > 0)
51089                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
51090         else
51091                 val_constr.data = NULL;
51092         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
51093         for (size_t k = 0; k < val_constr.datalen; k++) {
51094                 int64_t val_conv_10 = val_vals[k];
51095                 LDKRouteHop val_conv_10_conv;
51096                 val_conv_10_conv.inner = untag_ptr(val_conv_10);
51097                 val_conv_10_conv.is_owned = ptr_is_owned(val_conv_10);
51098                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_10_conv);
51099                 val_conv_10_conv = RouteHop_clone(&val_conv_10_conv);
51100                 val_constr.data[k] = val_conv_10_conv;
51101         }
51102         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
51103         Path_set_hops(&this_ptr_conv, val_constr);
51104 }
51105
51106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1get_1blinded_1tail(JNIEnv *env, jclass clz, int64_t this_ptr) {
51107         LDKPath this_ptr_conv;
51108         this_ptr_conv.inner = untag_ptr(this_ptr);
51109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51111         this_ptr_conv.is_owned = false;
51112         LDKBlindedTail ret_var = Path_get_blinded_tail(&this_ptr_conv);
51113         int64_t ret_ref = 0;
51114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51115         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51116         return ret_ref;
51117 }
51118
51119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Path_1set_1blinded_1tail(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51120         LDKPath this_ptr_conv;
51121         this_ptr_conv.inner = untag_ptr(this_ptr);
51122         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51124         this_ptr_conv.is_owned = false;
51125         LDKBlindedTail val_conv;
51126         val_conv.inner = untag_ptr(val);
51127         val_conv.is_owned = ptr_is_owned(val);
51128         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51129         val_conv = BlindedTail_clone(&val_conv);
51130         Path_set_blinded_tail(&this_ptr_conv, val_conv);
51131 }
51132
51133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1new(JNIEnv *env, jclass clz, int64_tArray hops_arg, int64_t blinded_tail_arg) {
51134         LDKCVec_RouteHopZ hops_arg_constr;
51135         hops_arg_constr.datalen = (*env)->GetArrayLength(env, hops_arg);
51136         if (hops_arg_constr.datalen > 0)
51137                 hops_arg_constr.data = MALLOC(hops_arg_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
51138         else
51139                 hops_arg_constr.data = NULL;
51140         int64_t* hops_arg_vals = (*env)->GetLongArrayElements (env, hops_arg, NULL);
51141         for (size_t k = 0; k < hops_arg_constr.datalen; k++) {
51142                 int64_t hops_arg_conv_10 = hops_arg_vals[k];
51143                 LDKRouteHop hops_arg_conv_10_conv;
51144                 hops_arg_conv_10_conv.inner = untag_ptr(hops_arg_conv_10);
51145                 hops_arg_conv_10_conv.is_owned = ptr_is_owned(hops_arg_conv_10);
51146                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_arg_conv_10_conv);
51147                 hops_arg_conv_10_conv = RouteHop_clone(&hops_arg_conv_10_conv);
51148                 hops_arg_constr.data[k] = hops_arg_conv_10_conv;
51149         }
51150         (*env)->ReleaseLongArrayElements(env, hops_arg, hops_arg_vals, 0);
51151         LDKBlindedTail blinded_tail_arg_conv;
51152         blinded_tail_arg_conv.inner = untag_ptr(blinded_tail_arg);
51153         blinded_tail_arg_conv.is_owned = ptr_is_owned(blinded_tail_arg);
51154         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_tail_arg_conv);
51155         blinded_tail_arg_conv = BlindedTail_clone(&blinded_tail_arg_conv);
51156         LDKPath ret_var = Path_new(hops_arg_constr, blinded_tail_arg_conv);
51157         int64_t ret_ref = 0;
51158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51159         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51160         return ret_ref;
51161 }
51162
51163 static inline uint64_t Path_clone_ptr(LDKPath *NONNULL_PTR arg) {
51164         LDKPath ret_var = Path_clone(arg);
51165         int64_t ret_ref = 0;
51166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51167         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51168         return ret_ref;
51169 }
51170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51171         LDKPath arg_conv;
51172         arg_conv.inner = untag_ptr(arg);
51173         arg_conv.is_owned = ptr_is_owned(arg);
51174         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51175         arg_conv.is_owned = false;
51176         int64_t ret_conv = Path_clone_ptr(&arg_conv);
51177         return ret_conv;
51178 }
51179
51180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51181         LDKPath orig_conv;
51182         orig_conv.inner = untag_ptr(orig);
51183         orig_conv.is_owned = ptr_is_owned(orig);
51184         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51185         orig_conv.is_owned = false;
51186         LDKPath ret_var = Path_clone(&orig_conv);
51187         int64_t ret_ref = 0;
51188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51189         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51190         return ret_ref;
51191 }
51192
51193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1hash(JNIEnv *env, jclass clz, int64_t o) {
51194         LDKPath o_conv;
51195         o_conv.inner = untag_ptr(o);
51196         o_conv.is_owned = ptr_is_owned(o);
51197         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51198         o_conv.is_owned = false;
51199         int64_t ret_conv = Path_hash(&o_conv);
51200         return ret_conv;
51201 }
51202
51203 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Path_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51204         LDKPath a_conv;
51205         a_conv.inner = untag_ptr(a);
51206         a_conv.is_owned = ptr_is_owned(a);
51207         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51208         a_conv.is_owned = false;
51209         LDKPath b_conv;
51210         b_conv.inner = untag_ptr(b);
51211         b_conv.is_owned = ptr_is_owned(b);
51212         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51213         b_conv.is_owned = false;
51214         jboolean ret_conv = Path_eq(&a_conv, &b_conv);
51215         return ret_conv;
51216 }
51217
51218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
51219         LDKPath this_arg_conv;
51220         this_arg_conv.inner = untag_ptr(this_arg);
51221         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51223         this_arg_conv.is_owned = false;
51224         int64_t ret_conv = Path_fee_msat(&this_arg_conv);
51225         return ret_conv;
51226 }
51227
51228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
51229         LDKPath this_arg_conv;
51230         this_arg_conv.inner = untag_ptr(this_arg);
51231         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51233         this_arg_conv.is_owned = false;
51234         int64_t ret_conv = Path_final_value_msat(&this_arg_conv);
51235         return ret_conv;
51236 }
51237
51238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Path_1final_1cltv_1expiry_1delta(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         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
51245         *ret_copy = Path_final_cltv_expiry_delta(&this_arg_conv);
51246         int64_t ret_ref = tag_ptr(ret_copy, true);
51247         return ret_ref;
51248 }
51249
51250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51251         LDKRoute this_obj_conv;
51252         this_obj_conv.inner = untag_ptr(this_obj);
51253         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51255         Route_free(this_obj_conv);
51256 }
51257
51258 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
51259         LDKRoute this_ptr_conv;
51260         this_ptr_conv.inner = untag_ptr(this_ptr);
51261         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51263         this_ptr_conv.is_owned = false;
51264         LDKCVec_PathZ ret_var = Route_get_paths(&this_ptr_conv);
51265         int64_tArray ret_arr = NULL;
51266         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
51267         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
51268         for (size_t g = 0; g < ret_var.datalen; g++) {
51269                 LDKPath ret_conv_6_var = ret_var.data[g];
51270                 int64_t ret_conv_6_ref = 0;
51271                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_6_var);
51272                 ret_conv_6_ref = tag_ptr(ret_conv_6_var.inner, ret_conv_6_var.is_owned);
51273                 ret_arr_ptr[g] = ret_conv_6_ref;
51274         }
51275         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
51276         FREE(ret_var.data);
51277         return ret_arr;
51278 }
51279
51280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
51281         LDKRoute this_ptr_conv;
51282         this_ptr_conv.inner = untag_ptr(this_ptr);
51283         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51285         this_ptr_conv.is_owned = false;
51286         LDKCVec_PathZ val_constr;
51287         val_constr.datalen = (*env)->GetArrayLength(env, val);
51288         if (val_constr.datalen > 0)
51289                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
51290         else
51291                 val_constr.data = NULL;
51292         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
51293         for (size_t g = 0; g < val_constr.datalen; g++) {
51294                 int64_t val_conv_6 = val_vals[g];
51295                 LDKPath val_conv_6_conv;
51296                 val_conv_6_conv.inner = untag_ptr(val_conv_6);
51297                 val_conv_6_conv.is_owned = ptr_is_owned(val_conv_6);
51298                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_6_conv);
51299                 val_conv_6_conv = Path_clone(&val_conv_6_conv);
51300                 val_constr.data[g] = val_conv_6_conv;
51301         }
51302         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
51303         Route_set_paths(&this_ptr_conv, val_constr);
51304 }
51305
51306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
51307         LDKRoute this_ptr_conv;
51308         this_ptr_conv.inner = untag_ptr(this_ptr);
51309         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51311         this_ptr_conv.is_owned = false;
51312         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
51313         int64_t ret_ref = 0;
51314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51315         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51316         return ret_ref;
51317 }
51318
51319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51320         LDKRoute this_ptr_conv;
51321         this_ptr_conv.inner = untag_ptr(this_ptr);
51322         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51324         this_ptr_conv.is_owned = false;
51325         LDKPaymentParameters val_conv;
51326         val_conv.inner = untag_ptr(val);
51327         val_conv.is_owned = ptr_is_owned(val);
51328         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51329         val_conv = PaymentParameters_clone(&val_conv);
51330         Route_set_payment_params(&this_ptr_conv, val_conv);
51331 }
51332
51333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, int64_tArray paths_arg, int64_t payment_params_arg) {
51334         LDKCVec_PathZ paths_arg_constr;
51335         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
51336         if (paths_arg_constr.datalen > 0)
51337                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
51338         else
51339                 paths_arg_constr.data = NULL;
51340         int64_t* paths_arg_vals = (*env)->GetLongArrayElements (env, paths_arg, NULL);
51341         for (size_t g = 0; g < paths_arg_constr.datalen; g++) {
51342                 int64_t paths_arg_conv_6 = paths_arg_vals[g];
51343                 LDKPath paths_arg_conv_6_conv;
51344                 paths_arg_conv_6_conv.inner = untag_ptr(paths_arg_conv_6);
51345                 paths_arg_conv_6_conv.is_owned = ptr_is_owned(paths_arg_conv_6);
51346                 CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_6_conv);
51347                 paths_arg_conv_6_conv = Path_clone(&paths_arg_conv_6_conv);
51348                 paths_arg_constr.data[g] = paths_arg_conv_6_conv;
51349         }
51350         (*env)->ReleaseLongArrayElements(env, paths_arg, paths_arg_vals, 0);
51351         LDKPaymentParameters payment_params_arg_conv;
51352         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
51353         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
51354         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
51355         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
51356         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
51357         int64_t ret_ref = 0;
51358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51359         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51360         return ret_ref;
51361 }
51362
51363 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
51364         LDKRoute ret_var = Route_clone(arg);
51365         int64_t ret_ref = 0;
51366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51368         return ret_ref;
51369 }
51370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51371         LDKRoute arg_conv;
51372         arg_conv.inner = untag_ptr(arg);
51373         arg_conv.is_owned = ptr_is_owned(arg);
51374         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51375         arg_conv.is_owned = false;
51376         int64_t ret_conv = Route_clone_ptr(&arg_conv);
51377         return ret_conv;
51378 }
51379
51380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51381         LDKRoute orig_conv;
51382         orig_conv.inner = untag_ptr(orig);
51383         orig_conv.is_owned = ptr_is_owned(orig);
51384         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51385         orig_conv.is_owned = false;
51386         LDKRoute ret_var = Route_clone(&orig_conv);
51387         int64_t ret_ref = 0;
51388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51389         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51390         return ret_ref;
51391 }
51392
51393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
51394         LDKRoute o_conv;
51395         o_conv.inner = untag_ptr(o);
51396         o_conv.is_owned = ptr_is_owned(o);
51397         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51398         o_conv.is_owned = false;
51399         int64_t ret_conv = Route_hash(&o_conv);
51400         return ret_conv;
51401 }
51402
51403 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51404         LDKRoute a_conv;
51405         a_conv.inner = untag_ptr(a);
51406         a_conv.is_owned = ptr_is_owned(a);
51407         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51408         a_conv.is_owned = false;
51409         LDKRoute b_conv;
51410         b_conv.inner = untag_ptr(b);
51411         b_conv.is_owned = ptr_is_owned(b);
51412         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51413         b_conv.is_owned = false;
51414         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
51415         return ret_conv;
51416 }
51417
51418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
51419         LDKRoute this_arg_conv;
51420         this_arg_conv.inner = untag_ptr(this_arg);
51421         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51423         this_arg_conv.is_owned = false;
51424         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
51425         return ret_conv;
51426 }
51427
51428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
51429         LDKRoute this_arg_conv;
51430         this_arg_conv.inner = untag_ptr(this_arg);
51431         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51433         this_arg_conv.is_owned = false;
51434         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
51435         return ret_conv;
51436 }
51437
51438 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
51439         LDKRoute obj_conv;
51440         obj_conv.inner = untag_ptr(obj);
51441         obj_conv.is_owned = ptr_is_owned(obj);
51442         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51443         obj_conv.is_owned = false;
51444         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
51445         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51446         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51447         CVec_u8Z_free(ret_var);
51448         return ret_arr;
51449 }
51450
51451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51452         LDKu8slice ser_ref;
51453         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51454         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51455         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
51456         *ret_conv = Route_read(ser_ref);
51457         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51458         return tag_ptr(ret_conv, true);
51459 }
51460
51461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51462         LDKRouteParameters this_obj_conv;
51463         this_obj_conv.inner = untag_ptr(this_obj);
51464         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51466         RouteParameters_free(this_obj_conv);
51467 }
51468
51469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
51470         LDKRouteParameters this_ptr_conv;
51471         this_ptr_conv.inner = untag_ptr(this_ptr);
51472         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51474         this_ptr_conv.is_owned = false;
51475         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
51476         int64_t ret_ref = 0;
51477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51478         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51479         return ret_ref;
51480 }
51481
51482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51483         LDKRouteParameters this_ptr_conv;
51484         this_ptr_conv.inner = untag_ptr(this_ptr);
51485         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51487         this_ptr_conv.is_owned = false;
51488         LDKPaymentParameters val_conv;
51489         val_conv.inner = untag_ptr(val);
51490         val_conv.is_owned = ptr_is_owned(val);
51491         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51492         val_conv = PaymentParameters_clone(&val_conv);
51493         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
51494 }
51495
51496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
51497         LDKRouteParameters this_ptr_conv;
51498         this_ptr_conv.inner = untag_ptr(this_ptr);
51499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51501         this_ptr_conv.is_owned = false;
51502         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
51503         return ret_conv;
51504 }
51505
51506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51507         LDKRouteParameters this_ptr_conv;
51508         this_ptr_conv.inner = untag_ptr(this_ptr);
51509         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51511         this_ptr_conv.is_owned = false;
51512         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
51513 }
51514
51515 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) {
51516         LDKPaymentParameters payment_params_arg_conv;
51517         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
51518         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
51519         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
51520         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
51521         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg);
51522         int64_t ret_ref = 0;
51523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51524         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51525         return ret_ref;
51526 }
51527
51528 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
51529         LDKRouteParameters ret_var = RouteParameters_clone(arg);
51530         int64_t ret_ref = 0;
51531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51532         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51533         return ret_ref;
51534 }
51535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51536         LDKRouteParameters arg_conv;
51537         arg_conv.inner = untag_ptr(arg);
51538         arg_conv.is_owned = ptr_is_owned(arg);
51539         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51540         arg_conv.is_owned = false;
51541         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
51542         return ret_conv;
51543 }
51544
51545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51546         LDKRouteParameters orig_conv;
51547         orig_conv.inner = untag_ptr(orig);
51548         orig_conv.is_owned = ptr_is_owned(orig);
51549         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51550         orig_conv.is_owned = false;
51551         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
51552         int64_t ret_ref = 0;
51553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51554         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51555         return ret_ref;
51556 }
51557
51558 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51559         LDKRouteParameters a_conv;
51560         a_conv.inner = untag_ptr(a);
51561         a_conv.is_owned = ptr_is_owned(a);
51562         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51563         a_conv.is_owned = false;
51564         LDKRouteParameters b_conv;
51565         b_conv.inner = untag_ptr(b);
51566         b_conv.is_owned = ptr_is_owned(b);
51567         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51568         b_conv.is_owned = false;
51569         jboolean ret_conv = RouteParameters_eq(&a_conv, &b_conv);
51570         return ret_conv;
51571 }
51572
51573 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
51574         LDKRouteParameters obj_conv;
51575         obj_conv.inner = untag_ptr(obj);
51576         obj_conv.is_owned = ptr_is_owned(obj);
51577         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51578         obj_conv.is_owned = false;
51579         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
51580         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51581         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51582         CVec_u8Z_free(ret_var);
51583         return ret_arr;
51584 }
51585
51586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
51587         LDKu8slice ser_ref;
51588         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51589         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51590         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
51591         *ret_conv = RouteParameters_read(ser_ref);
51592         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51593         return tag_ptr(ret_conv, true);
51594 }
51595
51596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51597         LDKPaymentParameters this_obj_conv;
51598         this_obj_conv.inner = untag_ptr(this_obj);
51599         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51601         PaymentParameters_free(this_obj_conv);
51602 }
51603
51604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
51605         LDKPaymentParameters this_ptr_conv;
51606         this_ptr_conv.inner = untag_ptr(this_ptr);
51607         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51609         this_ptr_conv.is_owned = false;
51610         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
51611         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
51612         return ret_arr;
51613 }
51614
51615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
51616         LDKPaymentParameters this_ptr_conv;
51617         this_ptr_conv.inner = untag_ptr(this_ptr);
51618         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51620         this_ptr_conv.is_owned = false;
51621         LDKPublicKey val_ref;
51622         CHECK((*env)->GetArrayLength(env, val) == 33);
51623         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
51624         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
51625 }
51626
51627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
51628         LDKPaymentParameters this_ptr_conv;
51629         this_ptr_conv.inner = untag_ptr(this_ptr);
51630         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51632         this_ptr_conv.is_owned = false;
51633         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
51634         int64_t ret_ref = 0;
51635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51636         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51637         return ret_ref;
51638 }
51639
51640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51641         LDKPaymentParameters this_ptr_conv;
51642         this_ptr_conv.inner = untag_ptr(this_ptr);
51643         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51645         this_ptr_conv.is_owned = false;
51646         LDKInvoiceFeatures val_conv;
51647         val_conv.inner = untag_ptr(val);
51648         val_conv.is_owned = ptr_is_owned(val);
51649         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51650         val_conv = InvoiceFeatures_clone(&val_conv);
51651         PaymentParameters_set_features(&this_ptr_conv, val_conv);
51652 }
51653
51654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
51655         LDKPaymentParameters this_ptr_conv;
51656         this_ptr_conv.inner = untag_ptr(this_ptr);
51657         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51659         this_ptr_conv.is_owned = false;
51660         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
51661         *ret_copy = PaymentParameters_get_route_hints(&this_ptr_conv);
51662         int64_t ret_ref = tag_ptr(ret_copy, true);
51663         return ret_ref;
51664 }
51665
51666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51667         LDKPaymentParameters this_ptr_conv;
51668         this_ptr_conv.inner = untag_ptr(this_ptr);
51669         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51671         this_ptr_conv.is_owned = false;
51672         void* val_ptr = untag_ptr(val);
51673         CHECK_ACCESS(val_ptr);
51674         LDKHints val_conv = *(LDKHints*)(val_ptr);
51675         val_conv = Hints_clone((LDKHints*)untag_ptr(val));
51676         PaymentParameters_set_route_hints(&this_ptr_conv, val_conv);
51677 }
51678
51679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
51680         LDKPaymentParameters this_ptr_conv;
51681         this_ptr_conv.inner = untag_ptr(this_ptr);
51682         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51684         this_ptr_conv.is_owned = false;
51685         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
51686         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
51687         int64_t ret_ref = tag_ptr(ret_copy, true);
51688         return ret_ref;
51689 }
51690
51691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51692         LDKPaymentParameters this_ptr_conv;
51693         this_ptr_conv.inner = untag_ptr(this_ptr);
51694         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51696         this_ptr_conv.is_owned = false;
51697         void* val_ptr = untag_ptr(val);
51698         CHECK_ACCESS(val_ptr);
51699         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
51700         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
51701         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
51702 }
51703
51704 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
51705         LDKPaymentParameters this_ptr_conv;
51706         this_ptr_conv.inner = untag_ptr(this_ptr);
51707         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51709         this_ptr_conv.is_owned = false;
51710         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
51711         return ret_conv;
51712 }
51713
51714 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) {
51715         LDKPaymentParameters this_ptr_conv;
51716         this_ptr_conv.inner = untag_ptr(this_ptr);
51717         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51719         this_ptr_conv.is_owned = false;
51720         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
51721 }
51722
51723 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
51724         LDKPaymentParameters this_ptr_conv;
51725         this_ptr_conv.inner = untag_ptr(this_ptr);
51726         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51728         this_ptr_conv.is_owned = false;
51729         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
51730         return ret_conv;
51731 }
51732
51733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
51734         LDKPaymentParameters this_ptr_conv;
51735         this_ptr_conv.inner = untag_ptr(this_ptr);
51736         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51738         this_ptr_conv.is_owned = false;
51739         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
51740 }
51741
51742 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) {
51743         LDKPaymentParameters this_ptr_conv;
51744         this_ptr_conv.inner = untag_ptr(this_ptr);
51745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51747         this_ptr_conv.is_owned = false;
51748         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
51749         return ret_conv;
51750 }
51751
51752 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) {
51753         LDKPaymentParameters this_ptr_conv;
51754         this_ptr_conv.inner = untag_ptr(this_ptr);
51755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51757         this_ptr_conv.is_owned = false;
51758         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
51759 }
51760
51761 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
51762         LDKPaymentParameters this_ptr_conv;
51763         this_ptr_conv.inner = untag_ptr(this_ptr);
51764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51766         this_ptr_conv.is_owned = false;
51767         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
51768         int64_tArray ret_arr = NULL;
51769         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
51770         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
51771         for (size_t g = 0; g < ret_var.datalen; g++) {
51772                 int64_t ret_conv_6_conv = ret_var.data[g];
51773                 ret_arr_ptr[g] = ret_conv_6_conv;
51774         }
51775         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
51776         FREE(ret_var.data);
51777         return ret_arr;
51778 }
51779
51780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
51781         LDKPaymentParameters this_ptr_conv;
51782         this_ptr_conv.inner = untag_ptr(this_ptr);
51783         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51785         this_ptr_conv.is_owned = false;
51786         LDKCVec_u64Z val_constr;
51787         val_constr.datalen = (*env)->GetArrayLength(env, val);
51788         if (val_constr.datalen > 0)
51789                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
51790         else
51791                 val_constr.data = NULL;
51792         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
51793         for (size_t g = 0; g < val_constr.datalen; g++) {
51794                 int64_t val_conv_6 = val_vals[g];
51795                 val_constr.data[g] = val_conv_6;
51796         }
51797         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
51798         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
51799 }
51800
51801 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
51802         LDKPaymentParameters this_ptr_conv;
51803         this_ptr_conv.inner = untag_ptr(this_ptr);
51804         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51806         this_ptr_conv.is_owned = false;
51807         int32_t ret_conv = PaymentParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
51808         return ret_conv;
51809 }
51810
51811 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) {
51812         LDKPaymentParameters this_ptr_conv;
51813         this_ptr_conv.inner = untag_ptr(this_ptr);
51814         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51816         this_ptr_conv.is_owned = false;
51817         PaymentParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
51818 }
51819
51820 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) {
51821         LDKPublicKey payee_pubkey_arg_ref;
51822         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
51823         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
51824         LDKInvoiceFeatures features_arg_conv;
51825         features_arg_conv.inner = untag_ptr(features_arg);
51826         features_arg_conv.is_owned = ptr_is_owned(features_arg);
51827         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
51828         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
51829         void* route_hints_arg_ptr = untag_ptr(route_hints_arg);
51830         CHECK_ACCESS(route_hints_arg_ptr);
51831         LDKHints route_hints_arg_conv = *(LDKHints*)(route_hints_arg_ptr);
51832         route_hints_arg_conv = Hints_clone((LDKHints*)untag_ptr(route_hints_arg));
51833         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
51834         CHECK_ACCESS(expiry_time_arg_ptr);
51835         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
51836         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
51837         LDKCVec_u64Z previously_failed_channels_arg_constr;
51838         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
51839         if (previously_failed_channels_arg_constr.datalen > 0)
51840                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
51841         else
51842                 previously_failed_channels_arg_constr.data = NULL;
51843         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
51844         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
51845                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
51846                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
51847         }
51848         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
51849         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);
51850         int64_t ret_ref = 0;
51851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51852         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51853         return ret_ref;
51854 }
51855
51856 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
51857         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
51858         int64_t ret_ref = 0;
51859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51860         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51861         return ret_ref;
51862 }
51863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51864         LDKPaymentParameters arg_conv;
51865         arg_conv.inner = untag_ptr(arg);
51866         arg_conv.is_owned = ptr_is_owned(arg);
51867         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51868         arg_conv.is_owned = false;
51869         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
51870         return ret_conv;
51871 }
51872
51873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51874         LDKPaymentParameters orig_conv;
51875         orig_conv.inner = untag_ptr(orig);
51876         orig_conv.is_owned = ptr_is_owned(orig);
51877         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51878         orig_conv.is_owned = false;
51879         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
51880         int64_t ret_ref = 0;
51881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51882         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51883         return ret_ref;
51884 }
51885
51886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
51887         LDKPaymentParameters o_conv;
51888         o_conv.inner = untag_ptr(o);
51889         o_conv.is_owned = ptr_is_owned(o);
51890         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51891         o_conv.is_owned = false;
51892         int64_t ret_conv = PaymentParameters_hash(&o_conv);
51893         return ret_conv;
51894 }
51895
51896 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51897         LDKPaymentParameters a_conv;
51898         a_conv.inner = untag_ptr(a);
51899         a_conv.is_owned = ptr_is_owned(a);
51900         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51901         a_conv.is_owned = false;
51902         LDKPaymentParameters b_conv;
51903         b_conv.inner = untag_ptr(b);
51904         b_conv.is_owned = ptr_is_owned(b);
51905         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51906         b_conv.is_owned = false;
51907         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
51908         return ret_conv;
51909 }
51910
51911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
51912         LDKPaymentParameters obj_conv;
51913         obj_conv.inner = untag_ptr(obj);
51914         obj_conv.is_owned = ptr_is_owned(obj);
51915         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51916         obj_conv.is_owned = false;
51917         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
51918         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
51919         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
51920         CVec_u8Z_free(ret_var);
51921         return ret_arr;
51922 }
51923
51924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser, int32_t arg) {
51925         LDKu8slice ser_ref;
51926         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
51927         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
51928         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
51929         *ret_conv = PaymentParameters_read(ser_ref, arg);
51930         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
51931         return tag_ptr(ret_conv, true);
51932 }
51933
51934 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) {
51935         LDKPublicKey payee_pubkey_ref;
51936         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
51937         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
51938         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref, final_cltv_expiry_delta);
51939         int64_t ret_ref = 0;
51940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51941         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51942         return ret_ref;
51943 }
51944
51945 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) {
51946         LDKPublicKey payee_pubkey_ref;
51947         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
51948         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
51949         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref, final_cltv_expiry_delta);
51950         int64_t ret_ref = 0;
51951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51952         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51953         return ret_ref;
51954 }
51955
51956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hints_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51957         if (!ptr_is_owned(this_ptr)) return;
51958         void* this_ptr_ptr = untag_ptr(this_ptr);
51959         CHECK_ACCESS(this_ptr_ptr);
51960         LDKHints this_ptr_conv = *(LDKHints*)(this_ptr_ptr);
51961         FREE(untag_ptr(this_ptr));
51962         Hints_free(this_ptr_conv);
51963 }
51964
51965 static inline uint64_t Hints_clone_ptr(LDKHints *NONNULL_PTR arg) {
51966         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
51967         *ret_copy = Hints_clone(arg);
51968         int64_t ret_ref = tag_ptr(ret_copy, true);
51969         return ret_ref;
51970 }
51971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51972         LDKHints* arg_conv = (LDKHints*)untag_ptr(arg);
51973         int64_t ret_conv = Hints_clone_ptr(arg_conv);
51974         return ret_conv;
51975 }
51976
51977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51978         LDKHints* orig_conv = (LDKHints*)untag_ptr(orig);
51979         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
51980         *ret_copy = Hints_clone(orig_conv);
51981         int64_t ret_ref = tag_ptr(ret_copy, true);
51982         return ret_ref;
51983 }
51984
51985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1blinded(JNIEnv *env, jclass clz, int64_tArray a) {
51986         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ a_constr;
51987         a_constr.datalen = (*env)->GetArrayLength(env, a);
51988         if (a_constr.datalen > 0)
51989                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ Elements");
51990         else
51991                 a_constr.data = NULL;
51992         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
51993         for (size_t l = 0; l < a_constr.datalen; l++) {
51994                 int64_t a_conv_37 = a_vals[l];
51995                 void* a_conv_37_ptr = untag_ptr(a_conv_37);
51996                 CHECK_ACCESS(a_conv_37_ptr);
51997                 LDKC2Tuple_BlindedPayInfoBlindedPathZ a_conv_37_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(a_conv_37_ptr);
51998                 a_conv_37_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone((LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(a_conv_37));
51999                 a_constr.data[l] = a_conv_37_conv;
52000         }
52001         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
52002         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
52003         *ret_copy = Hints_blinded(a_constr);
52004         int64_t ret_ref = tag_ptr(ret_copy, true);
52005         return ret_ref;
52006 }
52007
52008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1clear(JNIEnv *env, jclass clz, int64_tArray a) {
52009         LDKCVec_RouteHintZ a_constr;
52010         a_constr.datalen = (*env)->GetArrayLength(env, a);
52011         if (a_constr.datalen > 0)
52012                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
52013         else
52014                 a_constr.data = NULL;
52015         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
52016         for (size_t l = 0; l < a_constr.datalen; l++) {
52017                 int64_t a_conv_11 = a_vals[l];
52018                 LDKRouteHint a_conv_11_conv;
52019                 a_conv_11_conv.inner = untag_ptr(a_conv_11);
52020                 a_conv_11_conv.is_owned = ptr_is_owned(a_conv_11);
52021                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv_11_conv);
52022                 a_conv_11_conv = RouteHint_clone(&a_conv_11_conv);
52023                 a_constr.data[l] = a_conv_11_conv;
52024         }
52025         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
52026         LDKHints *ret_copy = MALLOC(sizeof(LDKHints), "LDKHints");
52027         *ret_copy = Hints_clear(a_constr);
52028         int64_t ret_ref = tag_ptr(ret_copy, true);
52029         return ret_ref;
52030 }
52031
52032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hints_1hash(JNIEnv *env, jclass clz, int64_t o) {
52033         LDKHints* o_conv = (LDKHints*)untag_ptr(o);
52034         int64_t ret_conv = Hints_hash(o_conv);
52035         return ret_conv;
52036 }
52037
52038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Hints_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52039         LDKHints* a_conv = (LDKHints*)untag_ptr(a);
52040         LDKHints* b_conv = (LDKHints*)untag_ptr(b);
52041         jboolean ret_conv = Hints_eq(a_conv, b_conv);
52042         return ret_conv;
52043 }
52044
52045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52046         LDKRouteHint this_obj_conv;
52047         this_obj_conv.inner = untag_ptr(this_obj);
52048         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52050         RouteHint_free(this_obj_conv);
52051 }
52052
52053 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
52054         LDKRouteHint this_ptr_conv;
52055         this_ptr_conv.inner = untag_ptr(this_ptr);
52056         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52058         this_ptr_conv.is_owned = false;
52059         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
52060         int64_tArray ret_arr = NULL;
52061         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
52062         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
52063         for (size_t o = 0; o < ret_var.datalen; o++) {
52064                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
52065                 int64_t ret_conv_14_ref = 0;
52066                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
52067                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
52068                 ret_arr_ptr[o] = ret_conv_14_ref;
52069         }
52070         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
52071         FREE(ret_var.data);
52072         return ret_arr;
52073 }
52074
52075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
52076         LDKRouteHint this_ptr_conv;
52077         this_ptr_conv.inner = untag_ptr(this_ptr);
52078         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52080         this_ptr_conv.is_owned = false;
52081         LDKCVec_RouteHintHopZ val_constr;
52082         val_constr.datalen = (*env)->GetArrayLength(env, val);
52083         if (val_constr.datalen > 0)
52084                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
52085         else
52086                 val_constr.data = NULL;
52087         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
52088         for (size_t o = 0; o < val_constr.datalen; o++) {
52089                 int64_t val_conv_14 = val_vals[o];
52090                 LDKRouteHintHop val_conv_14_conv;
52091                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
52092                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
52093                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
52094                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
52095                 val_constr.data[o] = val_conv_14_conv;
52096         }
52097         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
52098         RouteHint_set_a(&this_ptr_conv, val_constr);
52099 }
52100
52101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
52102         LDKCVec_RouteHintHopZ a_arg_constr;
52103         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
52104         if (a_arg_constr.datalen > 0)
52105                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
52106         else
52107                 a_arg_constr.data = NULL;
52108         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
52109         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
52110                 int64_t a_arg_conv_14 = a_arg_vals[o];
52111                 LDKRouteHintHop a_arg_conv_14_conv;
52112                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
52113                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
52114                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
52115                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
52116                 a_arg_constr.data[o] = a_arg_conv_14_conv;
52117         }
52118         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
52119         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
52120         int64_t ret_ref = 0;
52121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52122         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52123         return ret_ref;
52124 }
52125
52126 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
52127         LDKRouteHint ret_var = RouteHint_clone(arg);
52128         int64_t ret_ref = 0;
52129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52130         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52131         return ret_ref;
52132 }
52133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52134         LDKRouteHint arg_conv;
52135         arg_conv.inner = untag_ptr(arg);
52136         arg_conv.is_owned = ptr_is_owned(arg);
52137         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52138         arg_conv.is_owned = false;
52139         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
52140         return ret_conv;
52141 }
52142
52143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52144         LDKRouteHint orig_conv;
52145         orig_conv.inner = untag_ptr(orig);
52146         orig_conv.is_owned = ptr_is_owned(orig);
52147         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52148         orig_conv.is_owned = false;
52149         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
52150         int64_t ret_ref = 0;
52151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52152         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52153         return ret_ref;
52154 }
52155
52156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
52157         LDKRouteHint o_conv;
52158         o_conv.inner = untag_ptr(o);
52159         o_conv.is_owned = ptr_is_owned(o);
52160         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52161         o_conv.is_owned = false;
52162         int64_t ret_conv = RouteHint_hash(&o_conv);
52163         return ret_conv;
52164 }
52165
52166 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52167         LDKRouteHint a_conv;
52168         a_conv.inner = untag_ptr(a);
52169         a_conv.is_owned = ptr_is_owned(a);
52170         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52171         a_conv.is_owned = false;
52172         LDKRouteHint b_conv;
52173         b_conv.inner = untag_ptr(b);
52174         b_conv.is_owned = ptr_is_owned(b);
52175         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52176         b_conv.is_owned = false;
52177         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
52178         return ret_conv;
52179 }
52180
52181 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
52182         LDKRouteHint obj_conv;
52183         obj_conv.inner = untag_ptr(obj);
52184         obj_conv.is_owned = ptr_is_owned(obj);
52185         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52186         obj_conv.is_owned = false;
52187         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
52188         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52189         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52190         CVec_u8Z_free(ret_var);
52191         return ret_arr;
52192 }
52193
52194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
52195         LDKu8slice ser_ref;
52196         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
52197         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
52198         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
52199         *ret_conv = RouteHint_read(ser_ref);
52200         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
52201         return tag_ptr(ret_conv, true);
52202 }
52203
52204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52205         LDKRouteHintHop this_obj_conv;
52206         this_obj_conv.inner = untag_ptr(this_obj);
52207         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52209         RouteHintHop_free(this_obj_conv);
52210 }
52211
52212 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
52213         LDKRouteHintHop this_ptr_conv;
52214         this_ptr_conv.inner = untag_ptr(this_ptr);
52215         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52217         this_ptr_conv.is_owned = false;
52218         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
52219         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
52220         return ret_arr;
52221 }
52222
52223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
52224         LDKRouteHintHop this_ptr_conv;
52225         this_ptr_conv.inner = untag_ptr(this_ptr);
52226         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52228         this_ptr_conv.is_owned = false;
52229         LDKPublicKey val_ref;
52230         CHECK((*env)->GetArrayLength(env, val) == 33);
52231         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
52232         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
52233 }
52234
52235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
52236         LDKRouteHintHop this_ptr_conv;
52237         this_ptr_conv.inner = untag_ptr(this_ptr);
52238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52240         this_ptr_conv.is_owned = false;
52241         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
52242         return ret_conv;
52243 }
52244
52245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52246         LDKRouteHintHop this_ptr_conv;
52247         this_ptr_conv.inner = untag_ptr(this_ptr);
52248         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52250         this_ptr_conv.is_owned = false;
52251         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
52252 }
52253
52254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
52255         LDKRouteHintHop this_ptr_conv;
52256         this_ptr_conv.inner = untag_ptr(this_ptr);
52257         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52259         this_ptr_conv.is_owned = false;
52260         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
52261         int64_t ret_ref = 0;
52262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52263         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52264         return ret_ref;
52265 }
52266
52267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52268         LDKRouteHintHop this_ptr_conv;
52269         this_ptr_conv.inner = untag_ptr(this_ptr);
52270         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52272         this_ptr_conv.is_owned = false;
52273         LDKRoutingFees val_conv;
52274         val_conv.inner = untag_ptr(val);
52275         val_conv.is_owned = ptr_is_owned(val);
52276         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
52277         val_conv = RoutingFees_clone(&val_conv);
52278         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
52279 }
52280
52281 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
52282         LDKRouteHintHop this_ptr_conv;
52283         this_ptr_conv.inner = untag_ptr(this_ptr);
52284         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52286         this_ptr_conv.is_owned = false;
52287         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
52288         return ret_conv;
52289 }
52290
52291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
52292         LDKRouteHintHop this_ptr_conv;
52293         this_ptr_conv.inner = untag_ptr(this_ptr);
52294         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52296         this_ptr_conv.is_owned = false;
52297         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
52298 }
52299
52300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52301         LDKRouteHintHop this_ptr_conv;
52302         this_ptr_conv.inner = untag_ptr(this_ptr);
52303         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52305         this_ptr_conv.is_owned = false;
52306         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
52307         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
52308         int64_t ret_ref = tag_ptr(ret_copy, true);
52309         return ret_ref;
52310 }
52311
52312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52313         LDKRouteHintHop this_ptr_conv;
52314         this_ptr_conv.inner = untag_ptr(this_ptr);
52315         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52317         this_ptr_conv.is_owned = false;
52318         void* val_ptr = untag_ptr(val);
52319         CHECK_ACCESS(val_ptr);
52320         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
52321         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
52322         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
52323 }
52324
52325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52326         LDKRouteHintHop this_ptr_conv;
52327         this_ptr_conv.inner = untag_ptr(this_ptr);
52328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52330         this_ptr_conv.is_owned = false;
52331         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
52332         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
52333         int64_t ret_ref = tag_ptr(ret_copy, true);
52334         return ret_ref;
52335 }
52336
52337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52338         LDKRouteHintHop this_ptr_conv;
52339         this_ptr_conv.inner = untag_ptr(this_ptr);
52340         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52342         this_ptr_conv.is_owned = false;
52343         void* val_ptr = untag_ptr(val);
52344         CHECK_ACCESS(val_ptr);
52345         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
52346         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
52347         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
52348 }
52349
52350 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) {
52351         LDKPublicKey src_node_id_arg_ref;
52352         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
52353         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
52354         LDKRoutingFees fees_arg_conv;
52355         fees_arg_conv.inner = untag_ptr(fees_arg);
52356         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
52357         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
52358         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
52359         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
52360         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
52361         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
52362         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
52363         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
52364         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
52365         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
52366         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
52367         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);
52368         int64_t ret_ref = 0;
52369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52370         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52371         return ret_ref;
52372 }
52373
52374 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
52375         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
52376         int64_t ret_ref = 0;
52377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52378         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52379         return ret_ref;
52380 }
52381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52382         LDKRouteHintHop arg_conv;
52383         arg_conv.inner = untag_ptr(arg);
52384         arg_conv.is_owned = ptr_is_owned(arg);
52385         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52386         arg_conv.is_owned = false;
52387         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
52388         return ret_conv;
52389 }
52390
52391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52392         LDKRouteHintHop orig_conv;
52393         orig_conv.inner = untag_ptr(orig);
52394         orig_conv.is_owned = ptr_is_owned(orig);
52395         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52396         orig_conv.is_owned = false;
52397         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
52398         int64_t ret_ref = 0;
52399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52400         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52401         return ret_ref;
52402 }
52403
52404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
52405         LDKRouteHintHop o_conv;
52406         o_conv.inner = untag_ptr(o);
52407         o_conv.is_owned = ptr_is_owned(o);
52408         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52409         o_conv.is_owned = false;
52410         int64_t ret_conv = RouteHintHop_hash(&o_conv);
52411         return ret_conv;
52412 }
52413
52414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52415         LDKRouteHintHop a_conv;
52416         a_conv.inner = untag_ptr(a);
52417         a_conv.is_owned = ptr_is_owned(a);
52418         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52419         a_conv.is_owned = false;
52420         LDKRouteHintHop b_conv;
52421         b_conv.inner = untag_ptr(b);
52422         b_conv.is_owned = ptr_is_owned(b);
52423         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52424         b_conv.is_owned = false;
52425         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
52426         return ret_conv;
52427 }
52428
52429 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
52430         LDKRouteHintHop obj_conv;
52431         obj_conv.inner = untag_ptr(obj);
52432         obj_conv.is_owned = ptr_is_owned(obj);
52433         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52434         obj_conv.is_owned = false;
52435         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
52436         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52437         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52438         CVec_u8Z_free(ret_var);
52439         return ret_arr;
52440 }
52441
52442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
52443         LDKu8slice ser_ref;
52444         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
52445         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
52446         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
52447         *ret_conv = RouteHintHop_read(ser_ref);
52448         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
52449         return tag_ptr(ret_conv, true);
52450 }
52451
52452 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) {
52453         LDKPublicKey our_node_pubkey_ref;
52454         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
52455         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
52456         LDKRouteParameters route_params_conv;
52457         route_params_conv.inner = untag_ptr(route_params);
52458         route_params_conv.is_owned = ptr_is_owned(route_params);
52459         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
52460         route_params_conv.is_owned = false;
52461         LDKNetworkGraph network_graph_conv;
52462         network_graph_conv.inner = untag_ptr(network_graph);
52463         network_graph_conv.is_owned = ptr_is_owned(network_graph);
52464         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
52465         network_graph_conv.is_owned = false;
52466         LDKCVec_ChannelDetailsZ first_hops_constr;
52467         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
52468         if (first_hops != NULL) {
52469                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
52470                 if (first_hops_constr.datalen > 0)
52471                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
52472                 else
52473                         first_hops_constr.data = NULL;
52474                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
52475                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
52476                         int64_t first_hops_conv_16 = first_hops_vals[q];
52477                         LDKChannelDetails first_hops_conv_16_conv;
52478                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
52479                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
52480                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
52481                         first_hops_conv_16_conv.is_owned = false;
52482                         first_hops_constr.data[q] = first_hops_conv_16_conv;
52483                 }
52484                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
52485                 first_hops_ptr = &first_hops_constr;
52486         }
52487         void* logger_ptr = untag_ptr(logger);
52488         CHECK_ACCESS(logger_ptr);
52489         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
52490         if (logger_conv.free == LDKLogger_JCalls_free) {
52491                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52492                 LDKLogger_JCalls_cloned(&logger_conv);
52493         }
52494         void* scorer_ptr = untag_ptr(scorer);
52495         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
52496         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
52497         uint8_t random_seed_bytes_arr[32];
52498         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
52499         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
52500         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
52501         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
52502         *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);
52503         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
52504         return tag_ptr(ret_conv, true);
52505 }
52506
52507 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) {
52508         LDKPublicKey our_node_pubkey_ref;
52509         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
52510         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
52511         LDKCVec_PublicKeyZ hops_constr;
52512         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
52513         if (hops_constr.datalen > 0)
52514                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
52515         else
52516                 hops_constr.data = NULL;
52517         for (size_t i = 0; i < hops_constr.datalen; i++) {
52518                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
52519                 LDKPublicKey hops_conv_8_ref;
52520                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
52521                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
52522                 hops_constr.data[i] = hops_conv_8_ref;
52523         }
52524         LDKRouteParameters route_params_conv;
52525         route_params_conv.inner = untag_ptr(route_params);
52526         route_params_conv.is_owned = ptr_is_owned(route_params);
52527         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
52528         route_params_conv.is_owned = false;
52529         LDKNetworkGraph network_graph_conv;
52530         network_graph_conv.inner = untag_ptr(network_graph);
52531         network_graph_conv.is_owned = ptr_is_owned(network_graph);
52532         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
52533         network_graph_conv.is_owned = false;
52534         void* logger_ptr = untag_ptr(logger);
52535         CHECK_ACCESS(logger_ptr);
52536         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
52537         if (logger_conv.free == LDKLogger_JCalls_free) {
52538                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52539                 LDKLogger_JCalls_cloned(&logger_conv);
52540         }
52541         uint8_t random_seed_bytes_arr[32];
52542         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
52543         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
52544         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
52545         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
52546         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
52547         return tag_ptr(ret_conv, true);
52548 }
52549
52550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52551         if (!ptr_is_owned(this_ptr)) return;
52552         void* this_ptr_ptr = untag_ptr(this_ptr);
52553         CHECK_ACCESS(this_ptr_ptr);
52554         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
52555         FREE(untag_ptr(this_ptr));
52556         Score_free(this_ptr_conv);
52557 }
52558
52559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52560         if (!ptr_is_owned(this_ptr)) return;
52561         void* this_ptr_ptr = untag_ptr(this_ptr);
52562         CHECK_ACCESS(this_ptr_ptr);
52563         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
52564         FREE(untag_ptr(this_ptr));
52565         LockableScore_free(this_ptr_conv);
52566 }
52567
52568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52569         if (!ptr_is_owned(this_ptr)) return;
52570         void* this_ptr_ptr = untag_ptr(this_ptr);
52571         CHECK_ACCESS(this_ptr_ptr);
52572         LDKWriteableScore this_ptr_conv = *(LDKWriteableScore*)(this_ptr_ptr);
52573         FREE(untag_ptr(this_ptr));
52574         WriteableScore_free(this_ptr_conv);
52575 }
52576
52577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52578         LDKMultiThreadedLockableScore this_obj_conv;
52579         this_obj_conv.inner = untag_ptr(this_obj);
52580         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52582         MultiThreadedLockableScore_free(this_obj_conv);
52583 }
52584
52585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52586         LDKMultiThreadedScoreLock this_obj_conv;
52587         this_obj_conv.inner = untag_ptr(this_obj);
52588         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52590         MultiThreadedScoreLock_free(this_obj_conv);
52591 }
52592
52593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
52594         LDKMultiThreadedScoreLock this_arg_conv;
52595         this_arg_conv.inner = untag_ptr(this_arg);
52596         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52598         this_arg_conv.is_owned = false;
52599         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
52600         *ret_ret = MultiThreadedScoreLock_as_Score(&this_arg_conv);
52601         return tag_ptr(ret_ret, true);
52602 }
52603
52604 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1write(JNIEnv *env, jclass clz, int64_t obj) {
52605         LDKMultiThreadedScoreLock obj_conv;
52606         obj_conv.inner = untag_ptr(obj);
52607         obj_conv.is_owned = ptr_is_owned(obj);
52608         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52609         obj_conv.is_owned = false;
52610         LDKCVec_u8Z ret_var = MultiThreadedScoreLock_write(&obj_conv);
52611         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52612         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52613         CVec_u8Z_free(ret_var);
52614         return ret_arr;
52615 }
52616
52617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1LockableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
52618         LDKMultiThreadedLockableScore this_arg_conv;
52619         this_arg_conv.inner = untag_ptr(this_arg);
52620         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52622         this_arg_conv.is_owned = false;
52623         LDKLockableScore* ret_ret = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
52624         *ret_ret = MultiThreadedLockableScore_as_LockableScore(&this_arg_conv);
52625         return tag_ptr(ret_ret, true);
52626 }
52627
52628 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
52629         LDKMultiThreadedLockableScore obj_conv;
52630         obj_conv.inner = untag_ptr(obj);
52631         obj_conv.is_owned = ptr_is_owned(obj);
52632         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52633         obj_conv.is_owned = false;
52634         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
52635         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52636         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52637         CVec_u8Z_free(ret_var);
52638         return ret_arr;
52639 }
52640
52641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1WriteableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
52642         LDKMultiThreadedLockableScore this_arg_conv;
52643         this_arg_conv.inner = untag_ptr(this_arg);
52644         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52646         this_arg_conv.is_owned = false;
52647         LDKWriteableScore* ret_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
52648         *ret_ret = MultiThreadedLockableScore_as_WriteableScore(&this_arg_conv);
52649         return tag_ptr(ret_ret, true);
52650 }
52651
52652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
52653         void* score_ptr = untag_ptr(score);
52654         CHECK_ACCESS(score_ptr);
52655         LDKScore score_conv = *(LDKScore*)(score_ptr);
52656         if (score_conv.free == LDKScore_JCalls_free) {
52657                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
52658                 LDKScore_JCalls_cloned(&score_conv);
52659         }
52660         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
52661         int64_t ret_ref = 0;
52662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52663         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52664         return ret_ref;
52665 }
52666
52667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52668         LDKChannelUsage this_obj_conv;
52669         this_obj_conv.inner = untag_ptr(this_obj);
52670         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52672         ChannelUsage_free(this_obj_conv);
52673 }
52674
52675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52676         LDKChannelUsage this_ptr_conv;
52677         this_ptr_conv.inner = untag_ptr(this_ptr);
52678         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52680         this_ptr_conv.is_owned = false;
52681         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
52682         return ret_conv;
52683 }
52684
52685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52686         LDKChannelUsage this_ptr_conv;
52687         this_ptr_conv.inner = untag_ptr(this_ptr);
52688         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52690         this_ptr_conv.is_owned = false;
52691         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
52692 }
52693
52694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52695         LDKChannelUsage this_ptr_conv;
52696         this_ptr_conv.inner = untag_ptr(this_ptr);
52697         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52699         this_ptr_conv.is_owned = false;
52700         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
52701         return ret_conv;
52702 }
52703
52704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52705         LDKChannelUsage this_ptr_conv;
52706         this_ptr_conv.inner = untag_ptr(this_ptr);
52707         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52709         this_ptr_conv.is_owned = false;
52710         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
52711 }
52712
52713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
52714         LDKChannelUsage this_ptr_conv;
52715         this_ptr_conv.inner = untag_ptr(this_ptr);
52716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52718         this_ptr_conv.is_owned = false;
52719         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
52720         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
52721         int64_t ret_ref = tag_ptr(ret_copy, true);
52722         return ret_ref;
52723 }
52724
52725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52726         LDKChannelUsage this_ptr_conv;
52727         this_ptr_conv.inner = untag_ptr(this_ptr);
52728         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52730         this_ptr_conv.is_owned = false;
52731         void* val_ptr = untag_ptr(val);
52732         CHECK_ACCESS(val_ptr);
52733         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
52734         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
52735         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
52736 }
52737
52738 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) {
52739         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
52740         CHECK_ACCESS(effective_capacity_arg_ptr);
52741         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
52742         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
52743         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
52744         int64_t ret_ref = 0;
52745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52746         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52747         return ret_ref;
52748 }
52749
52750 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
52751         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
52752         int64_t ret_ref = 0;
52753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52754         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52755         return ret_ref;
52756 }
52757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52758         LDKChannelUsage arg_conv;
52759         arg_conv.inner = untag_ptr(arg);
52760         arg_conv.is_owned = ptr_is_owned(arg);
52761         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52762         arg_conv.is_owned = false;
52763         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
52764         return ret_conv;
52765 }
52766
52767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52768         LDKChannelUsage orig_conv;
52769         orig_conv.inner = untag_ptr(orig);
52770         orig_conv.is_owned = ptr_is_owned(orig);
52771         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52772         orig_conv.is_owned = false;
52773         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
52774         int64_t ret_ref = 0;
52775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52777         return ret_ref;
52778 }
52779
52780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52781         LDKFixedPenaltyScorer this_obj_conv;
52782         this_obj_conv.inner = untag_ptr(this_obj);
52783         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52785         FixedPenaltyScorer_free(this_obj_conv);
52786 }
52787
52788 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
52789         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
52790         int64_t ret_ref = 0;
52791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52792         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52793         return ret_ref;
52794 }
52795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52796         LDKFixedPenaltyScorer arg_conv;
52797         arg_conv.inner = untag_ptr(arg);
52798         arg_conv.is_owned = ptr_is_owned(arg);
52799         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52800         arg_conv.is_owned = false;
52801         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
52802         return ret_conv;
52803 }
52804
52805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52806         LDKFixedPenaltyScorer orig_conv;
52807         orig_conv.inner = untag_ptr(orig);
52808         orig_conv.is_owned = ptr_is_owned(orig);
52809         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52810         orig_conv.is_owned = false;
52811         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
52812         int64_t ret_ref = 0;
52813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52814         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52815         return ret_ref;
52816 }
52817
52818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
52819         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
52820         int64_t ret_ref = 0;
52821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52822         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52823         return ret_ref;
52824 }
52825
52826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
52827         LDKFixedPenaltyScorer this_arg_conv;
52828         this_arg_conv.inner = untag_ptr(this_arg);
52829         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52831         this_arg_conv.is_owned = false;
52832         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
52833         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
52834         return tag_ptr(ret_ret, true);
52835 }
52836
52837 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
52838         LDKFixedPenaltyScorer obj_conv;
52839         obj_conv.inner = untag_ptr(obj);
52840         obj_conv.is_owned = ptr_is_owned(obj);
52841         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
52842         obj_conv.is_owned = false;
52843         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
52844         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
52845         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
52846         CVec_u8Z_free(ret_var);
52847         return ret_arr;
52848 }
52849
52850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
52851         LDKu8slice ser_ref;
52852         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
52853         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
52854         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
52855         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
52856         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
52857         return tag_ptr(ret_conv, true);
52858 }
52859
52860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52861         LDKProbabilisticScorer this_obj_conv;
52862         this_obj_conv.inner = untag_ptr(this_obj);
52863         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52865         ProbabilisticScorer_free(this_obj_conv);
52866 }
52867
52868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52869         LDKProbabilisticScoringParameters this_obj_conv;
52870         this_obj_conv.inner = untag_ptr(this_obj);
52871         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52873         ProbabilisticScoringParameters_free(this_obj_conv);
52874 }
52875
52876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52877         LDKProbabilisticScoringParameters this_ptr_conv;
52878         this_ptr_conv.inner = untag_ptr(this_ptr);
52879         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52881         this_ptr_conv.is_owned = false;
52882         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
52883         return ret_conv;
52884 }
52885
52886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
52887         LDKProbabilisticScoringParameters this_ptr_conv;
52888         this_ptr_conv.inner = untag_ptr(this_ptr);
52889         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52891         this_ptr_conv.is_owned = false;
52892         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
52893 }
52894
52895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52896         LDKProbabilisticScoringParameters this_ptr_conv;
52897         this_ptr_conv.inner = untag_ptr(this_ptr);
52898         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52900         this_ptr_conv.is_owned = false;
52901         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
52902         return ret_conv;
52903 }
52904
52905 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) {
52906         LDKProbabilisticScoringParameters this_ptr_conv;
52907         this_ptr_conv.inner = untag_ptr(this_ptr);
52908         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52910         this_ptr_conv.is_owned = false;
52911         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
52912 }
52913
52914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52915         LDKProbabilisticScoringParameters this_ptr_conv;
52916         this_ptr_conv.inner = untag_ptr(this_ptr);
52917         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52919         this_ptr_conv.is_owned = false;
52920         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
52921         return ret_conv;
52922 }
52923
52924 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) {
52925         LDKProbabilisticScoringParameters this_ptr_conv;
52926         this_ptr_conv.inner = untag_ptr(this_ptr);
52927         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52929         this_ptr_conv.is_owned = false;
52930         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
52931 }
52932
52933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
52934         LDKProbabilisticScoringParameters this_ptr_conv;
52935         this_ptr_conv.inner = untag_ptr(this_ptr);
52936         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52938         this_ptr_conv.is_owned = false;
52939         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
52940         return ret_conv;
52941 }
52942
52943 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) {
52944         LDKProbabilisticScoringParameters this_ptr_conv;
52945         this_ptr_conv.inner = untag_ptr(this_ptr);
52946         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52948         this_ptr_conv.is_owned = false;
52949         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
52950 }
52951
52952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52953         LDKProbabilisticScoringParameters this_ptr_conv;
52954         this_ptr_conv.inner = untag_ptr(this_ptr);
52955         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52957         this_ptr_conv.is_owned = false;
52958         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
52959         return ret_conv;
52960 }
52961
52962 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) {
52963         LDKProbabilisticScoringParameters this_ptr_conv;
52964         this_ptr_conv.inner = untag_ptr(this_ptr);
52965         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52967         this_ptr_conv.is_owned = false;
52968         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
52969 }
52970
52971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
52972         LDKProbabilisticScoringParameters this_ptr_conv;
52973         this_ptr_conv.inner = untag_ptr(this_ptr);
52974         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52976         this_ptr_conv.is_owned = false;
52977         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv);
52978         return ret_conv;
52979 }
52980
52981 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) {
52982         LDKProbabilisticScoringParameters this_ptr_conv;
52983         this_ptr_conv.inner = untag_ptr(this_ptr);
52984         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52986         this_ptr_conv.is_owned = false;
52987         ProbabilisticScoringParameters_set_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
52988 }
52989
52990 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) {
52991         LDKProbabilisticScoringParameters this_ptr_conv;
52992         this_ptr_conv.inner = untag_ptr(this_ptr);
52993         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
52994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
52995         this_ptr_conv.is_owned = false;
52996         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
52997         return ret_conv;
52998 }
52999
53000 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) {
53001         LDKProbabilisticScoringParameters this_ptr_conv;
53002         this_ptr_conv.inner = untag_ptr(this_ptr);
53003         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53005         this_ptr_conv.is_owned = false;
53006         ProbabilisticScoringParameters_set_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
53007 }
53008
53009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1no_1updates_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
53010         LDKProbabilisticScoringParameters this_ptr_conv;
53011         this_ptr_conv.inner = untag_ptr(this_ptr);
53012         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53014         this_ptr_conv.is_owned = false;
53015         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_no_updates_half_life(&this_ptr_conv);
53016         return ret_conv;
53017 }
53018
53019 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) {
53020         LDKProbabilisticScoringParameters this_ptr_conv;
53021         this_ptr_conv.inner = untag_ptr(this_ptr);
53022         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53024         this_ptr_conv.is_owned = false;
53025         ProbabilisticScoringParameters_set_historical_no_updates_half_life(&this_ptr_conv, val);
53026 }
53027
53028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
53029         LDKProbabilisticScoringParameters this_ptr_conv;
53030         this_ptr_conv.inner = untag_ptr(this_ptr);
53031         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53033         this_ptr_conv.is_owned = false;
53034         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
53035         return ret_conv;
53036 }
53037
53038 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) {
53039         LDKProbabilisticScoringParameters this_ptr_conv;
53040         this_ptr_conv.inner = untag_ptr(this_ptr);
53041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53043         this_ptr_conv.is_owned = false;
53044         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
53045 }
53046
53047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
53048         LDKProbabilisticScoringParameters this_ptr_conv;
53049         this_ptr_conv.inner = untag_ptr(this_ptr);
53050         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53052         this_ptr_conv.is_owned = false;
53053         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
53054         return ret_conv;
53055 }
53056
53057 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) {
53058         LDKProbabilisticScoringParameters this_ptr_conv;
53059         this_ptr_conv.inner = untag_ptr(this_ptr);
53060         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53062         this_ptr_conv.is_owned = false;
53063         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
53064 }
53065
53066 static inline uint64_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
53067         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
53068         int64_t ret_ref = 0;
53069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53070         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53071         return ret_ref;
53072 }
53073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53074         LDKProbabilisticScoringParameters arg_conv;
53075         arg_conv.inner = untag_ptr(arg);
53076         arg_conv.is_owned = ptr_is_owned(arg);
53077         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53078         arg_conv.is_owned = false;
53079         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
53080         return ret_conv;
53081 }
53082
53083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53084         LDKProbabilisticScoringParameters orig_conv;
53085         orig_conv.inner = untag_ptr(orig);
53086         orig_conv.is_owned = ptr_is_owned(orig);
53087         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53088         orig_conv.is_owned = false;
53089         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
53090         int64_t ret_ref = 0;
53091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53092         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53093         return ret_ref;
53094 }
53095
53096 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) {
53097         LDKProbabilisticScoringParameters params_conv;
53098         params_conv.inner = untag_ptr(params);
53099         params_conv.is_owned = ptr_is_owned(params);
53100         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
53101         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
53102         LDKNetworkGraph network_graph_conv;
53103         network_graph_conv.inner = untag_ptr(network_graph);
53104         network_graph_conv.is_owned = ptr_is_owned(network_graph);
53105         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
53106         network_graph_conv.is_owned = false;
53107         void* logger_ptr = untag_ptr(logger);
53108         CHECK_ACCESS(logger_ptr);
53109         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53110         if (logger_conv.free == LDKLogger_JCalls_free) {
53111                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53112                 LDKLogger_JCalls_cloned(&logger_conv);
53113         }
53114         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
53115         int64_t ret_ref = 0;
53116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53117         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53118         return ret_ref;
53119 }
53120
53121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
53122         LDKProbabilisticScorer this_arg_conv;
53123         this_arg_conv.inner = untag_ptr(this_arg);
53124         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53126         this_arg_conv.is_owned = false;
53127         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
53128 }
53129
53130 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) {
53131         LDKProbabilisticScorer this_arg_conv;
53132         this_arg_conv.inner = untag_ptr(this_arg);
53133         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53135         this_arg_conv.is_owned = false;
53136         LDKNodeId target_conv;
53137         target_conv.inner = untag_ptr(target);
53138         target_conv.is_owned = ptr_is_owned(target);
53139         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
53140         target_conv.is_owned = false;
53141         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
53142         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
53143         int64_t ret_ref = tag_ptr(ret_copy, true);
53144         return ret_ref;
53145 }
53146
53147 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) {
53148         LDKProbabilisticScorer this_arg_conv;
53149         this_arg_conv.inner = untag_ptr(this_arg);
53150         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53152         this_arg_conv.is_owned = false;
53153         LDKNodeId target_conv;
53154         target_conv.inner = untag_ptr(target);
53155         target_conv.is_owned = ptr_is_owned(target);
53156         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
53157         target_conv.is_owned = false;
53158         LDKCOption_C2Tuple_EightU16sEightU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_EightU16sEightU16sZZ), "LDKCOption_C2Tuple_EightU16sEightU16sZZ");
53159         *ret_copy = ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(&this_arg_conv, scid, &target_conv);
53160         int64_t ret_ref = tag_ptr(ret_copy, true);
53161         return ret_ref;
53162 }
53163
53164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
53165         LDKProbabilisticScorer this_arg_conv;
53166         this_arg_conv.inner = untag_ptr(this_arg);
53167         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53169         this_arg_conv.is_owned = false;
53170         LDKNodeId node_id_conv;
53171         node_id_conv.inner = untag_ptr(node_id);
53172         node_id_conv.is_owned = ptr_is_owned(node_id);
53173         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53174         node_id_conv.is_owned = false;
53175         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
53176 }
53177
53178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
53179         LDKProbabilisticScorer this_arg_conv;
53180         this_arg_conv.inner = untag_ptr(this_arg);
53181         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53183         this_arg_conv.is_owned = false;
53184         LDKNodeId node_id_conv;
53185         node_id_conv.inner = untag_ptr(node_id);
53186         node_id_conv.is_owned = ptr_is_owned(node_id);
53187         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53188         node_id_conv.is_owned = false;
53189         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
53190 }
53191
53192 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) {
53193         LDKProbabilisticScorer this_arg_conv;
53194         this_arg_conv.inner = untag_ptr(this_arg);
53195         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53197         this_arg_conv.is_owned = false;
53198         LDKNodeId node_id_conv;
53199         node_id_conv.inner = untag_ptr(node_id);
53200         node_id_conv.is_owned = ptr_is_owned(node_id);
53201         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53202         node_id_conv.is_owned = false;
53203         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
53204 }
53205
53206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
53207         LDKProbabilisticScorer this_arg_conv;
53208         this_arg_conv.inner = untag_ptr(this_arg);
53209         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53211         this_arg_conv.is_owned = false;
53212         LDKNodeId node_id_conv;
53213         node_id_conv.inner = untag_ptr(node_id);
53214         node_id_conv.is_owned = ptr_is_owned(node_id);
53215         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
53216         node_id_conv.is_owned = false;
53217         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
53218 }
53219
53220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
53221         LDKProbabilisticScorer this_arg_conv;
53222         this_arg_conv.inner = untag_ptr(this_arg);
53223         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53225         this_arg_conv.is_owned = false;
53226         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
53227 }
53228
53229 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) {
53230         LDKProbabilisticScoringParameters this_arg_conv;
53231         this_arg_conv.inner = untag_ptr(this_arg);
53232         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53234         this_arg_conv.is_owned = false;
53235         LDKCVec_NodeIdZ node_ids_constr;
53236         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
53237         if (node_ids_constr.datalen > 0)
53238                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
53239         else
53240                 node_ids_constr.data = NULL;
53241         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
53242         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
53243                 int64_t node_ids_conv_8 = node_ids_vals[i];
53244                 LDKNodeId node_ids_conv_8_conv;
53245                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
53246                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
53247                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
53248                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
53249                 node_ids_constr.data[i] = node_ids_conv_8_conv;
53250         }
53251         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
53252         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
53253 }
53254
53255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
53256         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
53257         int64_t ret_ref = 0;
53258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53260         return ret_ref;
53261 }
53262
53263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
53264         LDKProbabilisticScorer this_arg_conv;
53265         this_arg_conv.inner = untag_ptr(this_arg);
53266         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53268         this_arg_conv.is_owned = false;
53269         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
53270         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
53271         return tag_ptr(ret_ret, true);
53272 }
53273
53274 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
53275         LDKProbabilisticScorer obj_conv;
53276         obj_conv.inner = untag_ptr(obj);
53277         obj_conv.is_owned = ptr_is_owned(obj);
53278         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53279         obj_conv.is_owned = false;
53280         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
53281         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53282         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53283         CVec_u8Z_free(ret_var);
53284         return ret_arr;
53285 }
53286
53287 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) {
53288         LDKu8slice ser_ref;
53289         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53290         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53291         LDKProbabilisticScoringParameters arg_a_conv;
53292         arg_a_conv.inner = untag_ptr(arg_a);
53293         arg_a_conv.is_owned = ptr_is_owned(arg_a);
53294         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
53295         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
53296         LDKNetworkGraph arg_b_conv;
53297         arg_b_conv.inner = untag_ptr(arg_b);
53298         arg_b_conv.is_owned = ptr_is_owned(arg_b);
53299         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
53300         arg_b_conv.is_owned = false;
53301         void* arg_c_ptr = untag_ptr(arg_c);
53302         CHECK_ACCESS(arg_c_ptr);
53303         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
53304         if (arg_c_conv.free == LDKLogger_JCalls_free) {
53305                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53306                 LDKLogger_JCalls_cloned(&arg_c_conv);
53307         }
53308         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
53309         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
53310         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53311         return tag_ptr(ret_conv, true);
53312 }
53313
53314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53315         LDKOnionMessenger this_obj_conv;
53316         this_obj_conv.inner = untag_ptr(this_obj);
53317         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53319         OnionMessenger_free(this_obj_conv);
53320 }
53321
53322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Destination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53323         if (!ptr_is_owned(this_ptr)) return;
53324         void* this_ptr_ptr = untag_ptr(this_ptr);
53325         CHECK_ACCESS(this_ptr_ptr);
53326         LDKDestination this_ptr_conv = *(LDKDestination*)(this_ptr_ptr);
53327         FREE(untag_ptr(this_ptr));
53328         Destination_free(this_ptr_conv);
53329 }
53330
53331 static inline uint64_t Destination_clone_ptr(LDKDestination *NONNULL_PTR arg) {
53332         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53333         *ret_copy = Destination_clone(arg);
53334         int64_t ret_ref = tag_ptr(ret_copy, true);
53335         return ret_ref;
53336 }
53337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53338         LDKDestination* arg_conv = (LDKDestination*)untag_ptr(arg);
53339         int64_t ret_conv = Destination_clone_ptr(arg_conv);
53340         return ret_conv;
53341 }
53342
53343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53344         LDKDestination* orig_conv = (LDKDestination*)untag_ptr(orig);
53345         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53346         *ret_copy = Destination_clone(orig_conv);
53347         int64_t ret_ref = tag_ptr(ret_copy, true);
53348         return ret_ref;
53349 }
53350
53351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1node(JNIEnv *env, jclass clz, int8_tArray a) {
53352         LDKPublicKey a_ref;
53353         CHECK((*env)->GetArrayLength(env, a) == 33);
53354         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
53355         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53356         *ret_copy = Destination_node(a_ref);
53357         int64_t ret_ref = tag_ptr(ret_copy, true);
53358         return ret_ref;
53359 }
53360
53361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1blinded_1path(JNIEnv *env, jclass clz, int64_t a) {
53362         LDKBlindedPath a_conv;
53363         a_conv.inner = untag_ptr(a);
53364         a_conv.is_owned = ptr_is_owned(a);
53365         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53366         a_conv = BlindedPath_clone(&a_conv);
53367         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
53368         *ret_copy = Destination_blinded_path(a_conv);
53369         int64_t ret_ref = tag_ptr(ret_copy, true);
53370         return ret_ref;
53371 }
53372
53373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SendError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53374         if (!ptr_is_owned(this_ptr)) return;
53375         void* this_ptr_ptr = untag_ptr(this_ptr);
53376         CHECK_ACCESS(this_ptr_ptr);
53377         LDKSendError this_ptr_conv = *(LDKSendError*)(this_ptr_ptr);
53378         FREE(untag_ptr(this_ptr));
53379         SendError_free(this_ptr_conv);
53380 }
53381
53382 static inline uint64_t SendError_clone_ptr(LDKSendError *NONNULL_PTR arg) {
53383         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53384         *ret_copy = SendError_clone(arg);
53385         int64_t ret_ref = tag_ptr(ret_copy, true);
53386         return ret_ref;
53387 }
53388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53389         LDKSendError* arg_conv = (LDKSendError*)untag_ptr(arg);
53390         int64_t ret_conv = SendError_clone_ptr(arg_conv);
53391         return ret_conv;
53392 }
53393
53394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53395         LDKSendError* orig_conv = (LDKSendError*)untag_ptr(orig);
53396         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53397         *ret_copy = SendError_clone(orig_conv);
53398         int64_t ret_ref = tag_ptr(ret_copy, true);
53399         return ret_ref;
53400 }
53401
53402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1secp256k1(JNIEnv *env, jclass clz, jclass a) {
53403         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
53404         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53405         *ret_copy = SendError_secp256k1(a_conv);
53406         int64_t ret_ref = tag_ptr(ret_copy, true);
53407         return ret_ref;
53408 }
53409
53410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1big_1packet(JNIEnv *env, jclass clz) {
53411         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53412         *ret_copy = SendError_too_big_packet();
53413         int64_t ret_ref = tag_ptr(ret_copy, true);
53414         return ret_ref;
53415 }
53416
53417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1few_1blinded_1hops(JNIEnv *env, jclass clz) {
53418         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53419         *ret_copy = SendError_too_few_blinded_hops();
53420         int64_t ret_ref = tag_ptr(ret_copy, true);
53421         return ret_ref;
53422 }
53423
53424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1first_1hop(JNIEnv *env, jclass clz) {
53425         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53426         *ret_copy = SendError_invalid_first_hop();
53427         int64_t ret_ref = tag_ptr(ret_copy, true);
53428         return ret_ref;
53429 }
53430
53431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1message(JNIEnv *env, jclass clz) {
53432         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53433         *ret_copy = SendError_invalid_message();
53434         int64_t ret_ref = tag_ptr(ret_copy, true);
53435         return ret_ref;
53436 }
53437
53438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1buffer_1full(JNIEnv *env, jclass clz) {
53439         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53440         *ret_copy = SendError_buffer_full();
53441         int64_t ret_ref = tag_ptr(ret_copy, true);
53442         return ret_ref;
53443 }
53444
53445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1get_1node_1id_1failed(JNIEnv *env, jclass clz) {
53446         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53447         *ret_copy = SendError_get_node_id_failed();
53448         int64_t ret_ref = tag_ptr(ret_copy, true);
53449         return ret_ref;
53450 }
53451
53452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1blinded_1path_1advance_1failed(JNIEnv *env, jclass clz) {
53453         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
53454         *ret_copy = SendError_blinded_path_advance_failed();
53455         int64_t ret_ref = tag_ptr(ret_copy, true);
53456         return ret_ref;
53457 }
53458
53459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SendError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53460         LDKSendError* a_conv = (LDKSendError*)untag_ptr(a);
53461         LDKSendError* b_conv = (LDKSendError*)untag_ptr(b);
53462         jboolean ret_conv = SendError_eq(a_conv, b_conv);
53463         return ret_conv;
53464 }
53465
53466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53467         if (!ptr_is_owned(this_ptr)) return;
53468         void* this_ptr_ptr = untag_ptr(this_ptr);
53469         CHECK_ACCESS(this_ptr_ptr);
53470         LDKCustomOnionMessageHandler this_ptr_conv = *(LDKCustomOnionMessageHandler*)(this_ptr_ptr);
53471         FREE(untag_ptr(this_ptr));
53472         CustomOnionMessageHandler_free(this_ptr_conv);
53473 }
53474
53475 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) {
53476         void* entropy_source_ptr = untag_ptr(entropy_source);
53477         CHECK_ACCESS(entropy_source_ptr);
53478         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
53479         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
53480                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53481                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
53482         }
53483         void* node_signer_ptr = untag_ptr(node_signer);
53484         CHECK_ACCESS(node_signer_ptr);
53485         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
53486         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
53487                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53488                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
53489         }
53490         void* logger_ptr = untag_ptr(logger);
53491         CHECK_ACCESS(logger_ptr);
53492         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53493         if (logger_conv.free == LDKLogger_JCalls_free) {
53494                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53495                 LDKLogger_JCalls_cloned(&logger_conv);
53496         }
53497         void* custom_handler_ptr = untag_ptr(custom_handler);
53498         CHECK_ACCESS(custom_handler_ptr);
53499         LDKCustomOnionMessageHandler custom_handler_conv = *(LDKCustomOnionMessageHandler*)(custom_handler_ptr);
53500         if (custom_handler_conv.free == LDKCustomOnionMessageHandler_JCalls_free) {
53501                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53502                 LDKCustomOnionMessageHandler_JCalls_cloned(&custom_handler_conv);
53503         }
53504         LDKOnionMessenger ret_var = OnionMessenger_new(entropy_source_conv, node_signer_conv, logger_conv, custom_handler_conv);
53505         int64_t ret_ref = 0;
53506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53507         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53508         return ret_ref;
53509 }
53510
53511 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) {
53512         LDKOnionMessenger this_arg_conv;
53513         this_arg_conv.inner = untag_ptr(this_arg);
53514         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53516         this_arg_conv.is_owned = false;
53517         LDKCVec_PublicKeyZ intermediate_nodes_constr;
53518         intermediate_nodes_constr.datalen = (*env)->GetArrayLength(env, intermediate_nodes);
53519         if (intermediate_nodes_constr.datalen > 0)
53520                 intermediate_nodes_constr.data = MALLOC(intermediate_nodes_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
53521         else
53522                 intermediate_nodes_constr.data = NULL;
53523         for (size_t i = 0; i < intermediate_nodes_constr.datalen; i++) {
53524                 int8_tArray intermediate_nodes_conv_8 = (*env)->GetObjectArrayElement(env, intermediate_nodes, i);
53525                 LDKPublicKey intermediate_nodes_conv_8_ref;
53526                 CHECK((*env)->GetArrayLength(env, intermediate_nodes_conv_8) == 33);
53527                 (*env)->GetByteArrayRegion(env, intermediate_nodes_conv_8, 0, 33, intermediate_nodes_conv_8_ref.compressed_form);
53528                 intermediate_nodes_constr.data[i] = intermediate_nodes_conv_8_ref;
53529         }
53530         void* destination_ptr = untag_ptr(destination);
53531         CHECK_ACCESS(destination_ptr);
53532         LDKDestination destination_conv = *(LDKDestination*)(destination_ptr);
53533         destination_conv = Destination_clone((LDKDestination*)untag_ptr(destination));
53534         void* message_ptr = untag_ptr(message);
53535         CHECK_ACCESS(message_ptr);
53536         LDKOnionMessageContents message_conv = *(LDKOnionMessageContents*)(message_ptr);
53537         message_conv = OnionMessageContents_clone((LDKOnionMessageContents*)untag_ptr(message));
53538         LDKBlindedPath reply_path_conv;
53539         reply_path_conv.inner = untag_ptr(reply_path);
53540         reply_path_conv.is_owned = ptr_is_owned(reply_path);
53541         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
53542         reply_path_conv = BlindedPath_clone(&reply_path_conv);
53543         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
53544         *ret_conv = OnionMessenger_send_onion_message(&this_arg_conv, intermediate_nodes_constr, destination_conv, message_conv, reply_path_conv);
53545         return tag_ptr(ret_conv, true);
53546 }
53547
53548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
53549         LDKOnionMessenger this_arg_conv;
53550         this_arg_conv.inner = untag_ptr(this_arg);
53551         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53553         this_arg_conv.is_owned = false;
53554         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
53555         *ret_ret = OnionMessenger_as_OnionMessageHandler(&this_arg_conv);
53556         return tag_ptr(ret_ret, true);
53557 }
53558
53559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
53560         LDKOnionMessenger this_arg_conv;
53561         this_arg_conv.inner = untag_ptr(this_arg);
53562         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53564         this_arg_conv.is_owned = false;
53565         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
53566         *ret_ret = OnionMessenger_as_OnionMessageProvider(&this_arg_conv);
53567         return tag_ptr(ret_ret, true);
53568 }
53569
53570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53571         if (!ptr_is_owned(this_ptr)) return;
53572         void* this_ptr_ptr = untag_ptr(this_ptr);
53573         CHECK_ACCESS(this_ptr_ptr);
53574         LDKOnionMessageContents this_ptr_conv = *(LDKOnionMessageContents*)(this_ptr_ptr);
53575         FREE(untag_ptr(this_ptr));
53576         OnionMessageContents_free(this_ptr_conv);
53577 }
53578
53579 static inline uint64_t OnionMessageContents_clone_ptr(LDKOnionMessageContents *NONNULL_PTR arg) {
53580         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
53581         *ret_copy = OnionMessageContents_clone(arg);
53582         int64_t ret_ref = tag_ptr(ret_copy, true);
53583         return ret_ref;
53584 }
53585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53586         LDKOnionMessageContents* arg_conv = (LDKOnionMessageContents*)untag_ptr(arg);
53587         int64_t ret_conv = OnionMessageContents_clone_ptr(arg_conv);
53588         return ret_conv;
53589 }
53590
53591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53592         LDKOnionMessageContents* orig_conv = (LDKOnionMessageContents*)untag_ptr(orig);
53593         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
53594         *ret_copy = OnionMessageContents_clone(orig_conv);
53595         int64_t ret_ref = tag_ptr(ret_copy, true);
53596         return ret_ref;
53597 }
53598
53599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1custom(JNIEnv *env, jclass clz, int64_t a) {
53600         void* a_ptr = untag_ptr(a);
53601         CHECK_ACCESS(a_ptr);
53602         LDKCustomOnionMessageContents a_conv = *(LDKCustomOnionMessageContents*)(a_ptr);
53603         if (a_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
53604                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53605                 LDKCustomOnionMessageContents_JCalls_cloned(&a_conv);
53606         }
53607         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
53608         *ret_copy = OnionMessageContents_custom(a_conv);
53609         int64_t ret_ref = tag_ptr(ret_copy, true);
53610         return ret_ref;
53611 }
53612
53613 static inline uint64_t CustomOnionMessageContents_clone_ptr(LDKCustomOnionMessageContents *NONNULL_PTR arg) {
53614         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
53615         *ret_ret = CustomOnionMessageContents_clone(arg);
53616         return tag_ptr(ret_ret, true);
53617 }
53618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53619         void* arg_ptr = untag_ptr(arg);
53620         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
53621         LDKCustomOnionMessageContents* arg_conv = (LDKCustomOnionMessageContents*)arg_ptr;
53622         int64_t ret_conv = CustomOnionMessageContents_clone_ptr(arg_conv);
53623         return ret_conv;
53624 }
53625
53626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53627         void* orig_ptr = untag_ptr(orig);
53628         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
53629         LDKCustomOnionMessageContents* orig_conv = (LDKCustomOnionMessageContents*)orig_ptr;
53630         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
53631         *ret_ret = CustomOnionMessageContents_clone(orig_conv);
53632         return tag_ptr(ret_ret, true);
53633 }
53634
53635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53636         if (!ptr_is_owned(this_ptr)) return;
53637         void* this_ptr_ptr = untag_ptr(this_ptr);
53638         CHECK_ACCESS(this_ptr_ptr);
53639         LDKCustomOnionMessageContents this_ptr_conv = *(LDKCustomOnionMessageContents*)(this_ptr_ptr);
53640         FREE(untag_ptr(this_ptr));
53641         CustomOnionMessageContents_free(this_ptr_conv);
53642 }
53643
53644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPath_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53645         LDKBlindedPath this_obj_conv;
53646         this_obj_conv.inner = untag_ptr(this_obj);
53647         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53649         BlindedPath_free(this_obj_conv);
53650 }
53651
53652 static inline uint64_t BlindedPath_clone_ptr(LDKBlindedPath *NONNULL_PTR arg) {
53653         LDKBlindedPath ret_var = BlindedPath_clone(arg);
53654         int64_t ret_ref = 0;
53655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53656         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53657         return ret_ref;
53658 }
53659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53660         LDKBlindedPath arg_conv;
53661         arg_conv.inner = untag_ptr(arg);
53662         arg_conv.is_owned = ptr_is_owned(arg);
53663         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53664         arg_conv.is_owned = false;
53665         int64_t ret_conv = BlindedPath_clone_ptr(&arg_conv);
53666         return ret_conv;
53667 }
53668
53669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53670         LDKBlindedPath orig_conv;
53671         orig_conv.inner = untag_ptr(orig);
53672         orig_conv.is_owned = ptr_is_owned(orig);
53673         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53674         orig_conv.is_owned = false;
53675         LDKBlindedPath ret_var = BlindedPath_clone(&orig_conv);
53676         int64_t ret_ref = 0;
53677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53678         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53679         return ret_ref;
53680 }
53681
53682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1hash(JNIEnv *env, jclass clz, int64_t o) {
53683         LDKBlindedPath o_conv;
53684         o_conv.inner = untag_ptr(o);
53685         o_conv.is_owned = ptr_is_owned(o);
53686         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53687         o_conv.is_owned = false;
53688         int64_t ret_conv = BlindedPath_hash(&o_conv);
53689         return ret_conv;
53690 }
53691
53692 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedPath_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53693         LDKBlindedPath a_conv;
53694         a_conv.inner = untag_ptr(a);
53695         a_conv.is_owned = ptr_is_owned(a);
53696         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53697         a_conv.is_owned = false;
53698         LDKBlindedPath b_conv;
53699         b_conv.inner = untag_ptr(b);
53700         b_conv.is_owned = ptr_is_owned(b);
53701         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53702         b_conv.is_owned = false;
53703         jboolean ret_conv = BlindedPath_eq(&a_conv, &b_conv);
53704         return ret_conv;
53705 }
53706
53707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53708         LDKBlindedHop this_obj_conv;
53709         this_obj_conv.inner = untag_ptr(this_obj);
53710         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53712         BlindedHop_free(this_obj_conv);
53713 }
53714
53715 static inline uint64_t BlindedHop_clone_ptr(LDKBlindedHop *NONNULL_PTR arg) {
53716         LDKBlindedHop ret_var = BlindedHop_clone(arg);
53717         int64_t ret_ref = 0;
53718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53719         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53720         return ret_ref;
53721 }
53722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53723         LDKBlindedHop arg_conv;
53724         arg_conv.inner = untag_ptr(arg);
53725         arg_conv.is_owned = ptr_is_owned(arg);
53726         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53727         arg_conv.is_owned = false;
53728         int64_t ret_conv = BlindedHop_clone_ptr(&arg_conv);
53729         return ret_conv;
53730 }
53731
53732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53733         LDKBlindedHop orig_conv;
53734         orig_conv.inner = untag_ptr(orig);
53735         orig_conv.is_owned = ptr_is_owned(orig);
53736         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53737         orig_conv.is_owned = false;
53738         LDKBlindedHop ret_var = BlindedHop_clone(&orig_conv);
53739         int64_t ret_ref = 0;
53740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53741         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53742         return ret_ref;
53743 }
53744
53745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
53746         LDKBlindedHop o_conv;
53747         o_conv.inner = untag_ptr(o);
53748         o_conv.is_owned = ptr_is_owned(o);
53749         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53750         o_conv.is_owned = false;
53751         int64_t ret_conv = BlindedHop_hash(&o_conv);
53752         return ret_conv;
53753 }
53754
53755 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BlindedHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53756         LDKBlindedHop a_conv;
53757         a_conv.inner = untag_ptr(a);
53758         a_conv.is_owned = ptr_is_owned(a);
53759         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53760         a_conv.is_owned = false;
53761         LDKBlindedHop b_conv;
53762         b_conv.inner = untag_ptr(b);
53763         b_conv.is_owned = ptr_is_owned(b);
53764         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53765         b_conv.is_owned = false;
53766         jboolean ret_conv = BlindedHop_eq(&a_conv, &b_conv);
53767         return ret_conv;
53768 }
53769
53770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1new_1for_1message(JNIEnv *env, jclass clz, jobjectArray node_pks, int64_t entropy_source) {
53771         LDKCVec_PublicKeyZ node_pks_constr;
53772         node_pks_constr.datalen = (*env)->GetArrayLength(env, node_pks);
53773         if (node_pks_constr.datalen > 0)
53774                 node_pks_constr.data = MALLOC(node_pks_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
53775         else
53776                 node_pks_constr.data = NULL;
53777         for (size_t i = 0; i < node_pks_constr.datalen; i++) {
53778                 int8_tArray node_pks_conv_8 = (*env)->GetObjectArrayElement(env, node_pks, i);
53779                 LDKPublicKey node_pks_conv_8_ref;
53780                 CHECK((*env)->GetArrayLength(env, node_pks_conv_8) == 33);
53781                 (*env)->GetByteArrayRegion(env, node_pks_conv_8, 0, 33, node_pks_conv_8_ref.compressed_form);
53782                 node_pks_constr.data[i] = node_pks_conv_8_ref;
53783         }
53784         void* entropy_source_ptr = untag_ptr(entropy_source);
53785         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
53786         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
53787         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
53788         *ret_conv = BlindedPath_new_for_message(node_pks_constr, entropy_source_conv);
53789         return tag_ptr(ret_conv, true);
53790 }
53791
53792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedPath_1write(JNIEnv *env, jclass clz, int64_t obj) {
53793         LDKBlindedPath obj_conv;
53794         obj_conv.inner = untag_ptr(obj);
53795         obj_conv.is_owned = ptr_is_owned(obj);
53796         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53797         obj_conv.is_owned = false;
53798         LDKCVec_u8Z ret_var = BlindedPath_write(&obj_conv);
53799         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53800         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53801         CVec_u8Z_free(ret_var);
53802         return ret_arr;
53803 }
53804
53805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53806         LDKu8slice ser_ref;
53807         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53808         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53809         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
53810         *ret_conv = BlindedPath_read(ser_ref);
53811         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53812         return tag_ptr(ret_conv, true);
53813 }
53814
53815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
53816         LDKBlindedHop obj_conv;
53817         obj_conv.inner = untag_ptr(obj);
53818         obj_conv.is_owned = ptr_is_owned(obj);
53819         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53820         obj_conv.is_owned = false;
53821         LDKCVec_u8Z ret_var = BlindedHop_write(&obj_conv);
53822         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53823         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53824         CVec_u8Z_free(ret_var);
53825         return ret_arr;
53826 }
53827
53828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53829         LDKu8slice ser_ref;
53830         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53831         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53832         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
53833         *ret_conv = BlindedHop_read(ser_ref);
53834         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53835         return tag_ptr(ret_conv, true);
53836 }
53837
53838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53839         if (!ptr_is_owned(this_ptr)) return;
53840         void* this_ptr_ptr = untag_ptr(this_ptr);
53841         CHECK_ACCESS(this_ptr_ptr);
53842         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
53843         FREE(untag_ptr(this_ptr));
53844         PaymentPurpose_free(this_ptr_conv);
53845 }
53846
53847 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
53848         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53849         *ret_copy = PaymentPurpose_clone(arg);
53850         int64_t ret_ref = tag_ptr(ret_copy, true);
53851         return ret_ref;
53852 }
53853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53854         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
53855         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
53856         return ret_conv;
53857 }
53858
53859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53860         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
53861         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53862         *ret_copy = PaymentPurpose_clone(orig_conv);
53863         int64_t ret_ref = tag_ptr(ret_copy, true);
53864         return ret_ref;
53865 }
53866
53867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
53868         LDKThirtyTwoBytes payment_preimage_ref;
53869         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
53870         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
53871         LDKThirtyTwoBytes payment_secret_ref;
53872         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
53873         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
53874         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53875         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
53876         int64_t ret_ref = tag_ptr(ret_copy, true);
53877         return ret_ref;
53878 }
53879
53880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
53881         LDKThirtyTwoBytes a_ref;
53882         CHECK((*env)->GetArrayLength(env, a) == 32);
53883         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
53884         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
53885         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
53886         int64_t ret_ref = tag_ptr(ret_copy, true);
53887         return ret_ref;
53888 }
53889
53890 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53891         LDKPaymentPurpose* a_conv = (LDKPaymentPurpose*)untag_ptr(a);
53892         LDKPaymentPurpose* b_conv = (LDKPaymentPurpose*)untag_ptr(b);
53893         jboolean ret_conv = PaymentPurpose_eq(a_conv, b_conv);
53894         return ret_conv;
53895 }
53896
53897 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
53898         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
53899         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
53900         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53901         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53902         CVec_u8Z_free(ret_var);
53903         return ret_arr;
53904 }
53905
53906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53907         LDKu8slice ser_ref;
53908         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53909         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53910         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
53911         *ret_conv = PaymentPurpose_read(ser_ref);
53912         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53913         return tag_ptr(ret_conv, true);
53914 }
53915
53916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PathFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53917         if (!ptr_is_owned(this_ptr)) return;
53918         void* this_ptr_ptr = untag_ptr(this_ptr);
53919         CHECK_ACCESS(this_ptr_ptr);
53920         LDKPathFailure this_ptr_conv = *(LDKPathFailure*)(this_ptr_ptr);
53921         FREE(untag_ptr(this_ptr));
53922         PathFailure_free(this_ptr_conv);
53923 }
53924
53925 static inline uint64_t PathFailure_clone_ptr(LDKPathFailure *NONNULL_PTR arg) {
53926         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53927         *ret_copy = PathFailure_clone(arg);
53928         int64_t ret_ref = tag_ptr(ret_copy, true);
53929         return ret_ref;
53930 }
53931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53932         LDKPathFailure* arg_conv = (LDKPathFailure*)untag_ptr(arg);
53933         int64_t ret_conv = PathFailure_clone_ptr(arg_conv);
53934         return ret_conv;
53935 }
53936
53937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53938         LDKPathFailure* orig_conv = (LDKPathFailure*)untag_ptr(orig);
53939         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53940         *ret_copy = PathFailure_clone(orig_conv);
53941         int64_t ret_ref = tag_ptr(ret_copy, true);
53942         return ret_ref;
53943 }
53944
53945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1initial_1send(JNIEnv *env, jclass clz, int64_t err) {
53946         void* err_ptr = untag_ptr(err);
53947         CHECK_ACCESS(err_ptr);
53948         LDKAPIError err_conv = *(LDKAPIError*)(err_ptr);
53949         err_conv = APIError_clone((LDKAPIError*)untag_ptr(err));
53950         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53951         *ret_copy = PathFailure_initial_send(err_conv);
53952         int64_t ret_ref = tag_ptr(ret_copy, true);
53953         return ret_ref;
53954 }
53955
53956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1on_1path(JNIEnv *env, jclass clz, int64_t network_update) {
53957         void* network_update_ptr = untag_ptr(network_update);
53958         CHECK_ACCESS(network_update_ptr);
53959         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
53960         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
53961         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
53962         *ret_copy = PathFailure_on_path(network_update_conv);
53963         int64_t ret_ref = tag_ptr(ret_copy, true);
53964         return ret_ref;
53965 }
53966
53967 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PathFailure_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
53968         LDKPathFailure* a_conv = (LDKPathFailure*)untag_ptr(a);
53969         LDKPathFailure* b_conv = (LDKPathFailure*)untag_ptr(b);
53970         jboolean ret_conv = PathFailure_eq(a_conv, b_conv);
53971         return ret_conv;
53972 }
53973
53974 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PathFailure_1write(JNIEnv *env, jclass clz, int64_t obj) {
53975         LDKPathFailure* obj_conv = (LDKPathFailure*)untag_ptr(obj);
53976         LDKCVec_u8Z ret_var = PathFailure_write(obj_conv);
53977         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
53978         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
53979         CVec_u8Z_free(ret_var);
53980         return ret_arr;
53981 }
53982
53983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PathFailure_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
53984         LDKu8slice ser_ref;
53985         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
53986         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
53987         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
53988         *ret_conv = PathFailure_read(ser_ref);
53989         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
53990         return tag_ptr(ret_conv, true);
53991 }
53992
53993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53994         if (!ptr_is_owned(this_ptr)) return;
53995         void* this_ptr_ptr = untag_ptr(this_ptr);
53996         CHECK_ACCESS(this_ptr_ptr);
53997         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
53998         FREE(untag_ptr(this_ptr));
53999         ClosureReason_free(this_ptr_conv);
54000 }
54001
54002 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
54003         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54004         *ret_copy = ClosureReason_clone(arg);
54005         int64_t ret_ref = tag_ptr(ret_copy, true);
54006         return ret_ref;
54007 }
54008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54009         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
54010         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
54011         return ret_conv;
54012 }
54013
54014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54015         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
54016         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54017         *ret_copy = ClosureReason_clone(orig_conv);
54018         int64_t ret_ref = tag_ptr(ret_copy, true);
54019         return ret_ref;
54020 }
54021
54022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, int64_t peer_msg) {
54023         LDKUntrustedString peer_msg_conv;
54024         peer_msg_conv.inner = untag_ptr(peer_msg);
54025         peer_msg_conv.is_owned = ptr_is_owned(peer_msg);
54026         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_msg_conv);
54027         peer_msg_conv = UntrustedString_clone(&peer_msg_conv);
54028         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54029         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
54030         int64_t ret_ref = tag_ptr(ret_copy, true);
54031         return ret_ref;
54032 }
54033
54034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
54035         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54036         *ret_copy = ClosureReason_holder_force_closed();
54037         int64_t ret_ref = tag_ptr(ret_copy, true);
54038         return ret_ref;
54039 }
54040
54041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
54042         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54043         *ret_copy = ClosureReason_cooperative_closure();
54044         int64_t ret_ref = tag_ptr(ret_copy, true);
54045         return ret_ref;
54046 }
54047
54048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
54049         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54050         *ret_copy = ClosureReason_commitment_tx_confirmed();
54051         int64_t ret_ref = tag_ptr(ret_copy, true);
54052         return ret_ref;
54053 }
54054
54055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
54056         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54057         *ret_copy = ClosureReason_funding_timed_out();
54058         int64_t ret_ref = tag_ptr(ret_copy, true);
54059         return ret_ref;
54060 }
54061
54062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
54063         LDKStr err_conv = java_to_owned_str(env, err);
54064         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54065         *ret_copy = ClosureReason_processing_error(err_conv);
54066         int64_t ret_ref = tag_ptr(ret_copy, true);
54067         return ret_ref;
54068 }
54069
54070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
54071         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54072         *ret_copy = ClosureReason_disconnected_peer();
54073         int64_t ret_ref = tag_ptr(ret_copy, true);
54074         return ret_ref;
54075 }
54076
54077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
54078         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
54079         *ret_copy = ClosureReason_outdated_channel_manager();
54080         int64_t ret_ref = tag_ptr(ret_copy, true);
54081         return ret_ref;
54082 }
54083
54084 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosureReason_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54085         LDKClosureReason* a_conv = (LDKClosureReason*)untag_ptr(a);
54086         LDKClosureReason* b_conv = (LDKClosureReason*)untag_ptr(b);
54087         jboolean ret_conv = ClosureReason_eq(a_conv, b_conv);
54088         return ret_conv;
54089 }
54090
54091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
54092         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
54093         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
54094         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54095         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54096         CVec_u8Z_free(ret_var);
54097         return ret_arr;
54098 }
54099
54100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54101         LDKu8slice ser_ref;
54102         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54103         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54104         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
54105         *ret_conv = ClosureReason_read(ser_ref);
54106         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54107         return tag_ptr(ret_conv, true);
54108 }
54109
54110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54111         if (!ptr_is_owned(this_ptr)) return;
54112         void* this_ptr_ptr = untag_ptr(this_ptr);
54113         CHECK_ACCESS(this_ptr_ptr);
54114         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
54115         FREE(untag_ptr(this_ptr));
54116         HTLCDestination_free(this_ptr_conv);
54117 }
54118
54119 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
54120         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54121         *ret_copy = HTLCDestination_clone(arg);
54122         int64_t ret_ref = tag_ptr(ret_copy, true);
54123         return ret_ref;
54124 }
54125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54126         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
54127         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
54128         return ret_conv;
54129 }
54130
54131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54132         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
54133         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54134         *ret_copy = HTLCDestination_clone(orig_conv);
54135         int64_t ret_ref = tag_ptr(ret_copy, true);
54136         return ret_ref;
54137 }
54138
54139 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) {
54140         LDKPublicKey node_id_ref;
54141         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54142         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54143         LDKThirtyTwoBytes channel_id_ref;
54144         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54145         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54146         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54147         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
54148         int64_t ret_ref = tag_ptr(ret_copy, true);
54149         return ret_ref;
54150 }
54151
54152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
54153         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54154         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
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_1invalid_1forward(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
54160         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54161         *ret_copy = HTLCDestination_invalid_forward(requested_forward_scid);
54162         int64_t ret_ref = tag_ptr(ret_copy, true);
54163         return ret_ref;
54164 }
54165
54166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
54167         LDKThirtyTwoBytes payment_hash_ref;
54168         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54169         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54170         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
54171         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
54172         int64_t ret_ref = tag_ptr(ret_copy, true);
54173         return ret_ref;
54174 }
54175
54176 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54177         LDKHTLCDestination* a_conv = (LDKHTLCDestination*)untag_ptr(a);
54178         LDKHTLCDestination* b_conv = (LDKHTLCDestination*)untag_ptr(b);
54179         jboolean ret_conv = HTLCDestination_eq(a_conv, b_conv);
54180         return ret_conv;
54181 }
54182
54183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
54184         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
54185         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
54186         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54187         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54188         CVec_u8Z_free(ret_var);
54189         return ret_arr;
54190 }
54191
54192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54193         LDKu8slice ser_ref;
54194         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54195         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54196         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
54197         *ret_conv = HTLCDestination_read(ser_ref);
54198         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54199         return tag_ptr(ret_conv, true);
54200 }
54201
54202 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54203         LDKPaymentFailureReason* orig_conv = (LDKPaymentFailureReason*)untag_ptr(orig);
54204         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_clone(orig_conv));
54205         return ret_conv;
54206 }
54207
54208 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1recipient_1rejected(JNIEnv *env, jclass clz) {
54209         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_recipient_rejected());
54210         return ret_conv;
54211 }
54212
54213 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1user_1abandoned(JNIEnv *env, jclass clz) {
54214         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_user_abandoned());
54215         return ret_conv;
54216 }
54217
54218 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1retries_1exhausted(JNIEnv *env, jclass clz) {
54219         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_retries_exhausted());
54220         return ret_conv;
54221 }
54222
54223 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1payment_1expired(JNIEnv *env, jclass clz) {
54224         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_payment_expired());
54225         return ret_conv;
54226 }
54227
54228 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1route_1not_1found(JNIEnv *env, jclass clz) {
54229         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_route_not_found());
54230         return ret_conv;
54231 }
54232
54233 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1unexpected_1error(JNIEnv *env, jclass clz) {
54234         jclass ret_conv = LDKPaymentFailureReason_to_java(env, PaymentFailureReason_unexpected_error());
54235         return ret_conv;
54236 }
54237
54238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54239         LDKPaymentFailureReason* a_conv = (LDKPaymentFailureReason*)untag_ptr(a);
54240         LDKPaymentFailureReason* b_conv = (LDKPaymentFailureReason*)untag_ptr(b);
54241         jboolean ret_conv = PaymentFailureReason_eq(a_conv, b_conv);
54242         return ret_conv;
54243 }
54244
54245 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
54246         LDKPaymentFailureReason* obj_conv = (LDKPaymentFailureReason*)untag_ptr(obj);
54247         LDKCVec_u8Z ret_var = PaymentFailureReason_write(obj_conv);
54248         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54249         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54250         CVec_u8Z_free(ret_var);
54251         return ret_arr;
54252 }
54253
54254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentFailureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54255         LDKu8slice ser_ref;
54256         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54257         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54258         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
54259         *ret_conv = PaymentFailureReason_read(ser_ref);
54260         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54261         return tag_ptr(ret_conv, true);
54262 }
54263
54264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54265         if (!ptr_is_owned(this_ptr)) return;
54266         void* this_ptr_ptr = untag_ptr(this_ptr);
54267         CHECK_ACCESS(this_ptr_ptr);
54268         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
54269         FREE(untag_ptr(this_ptr));
54270         Event_free(this_ptr_conv);
54271 }
54272
54273 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
54274         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54275         *ret_copy = Event_clone(arg);
54276         int64_t ret_ref = tag_ptr(ret_copy, true);
54277         return ret_ref;
54278 }
54279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54280         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
54281         int64_t ret_conv = Event_clone_ptr(arg_conv);
54282         return ret_conv;
54283 }
54284
54285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54286         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
54287         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54288         *ret_copy = Event_clone(orig_conv);
54289         int64_t ret_ref = tag_ptr(ret_copy, true);
54290         return ret_ref;
54291 }
54292
54293 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) {
54294         LDKThirtyTwoBytes temporary_channel_id_ref;
54295         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
54296         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
54297         LDKPublicKey counterparty_node_id_ref;
54298         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54299         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54300         LDKCVec_u8Z output_script_ref;
54301         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
54302         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
54303         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
54304         LDKU128 user_channel_id_ref;
54305         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54306         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54307         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54308         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id_ref);
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_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) {
54314         LDKPublicKey receiver_node_id_ref;
54315         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
54316         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
54317         LDKThirtyTwoBytes payment_hash_ref;
54318         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54319         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54320         LDKRecipientOnionFields onion_fields_conv;
54321         onion_fields_conv.inner = untag_ptr(onion_fields);
54322         onion_fields_conv.is_owned = ptr_is_owned(onion_fields);
54323         CHECK_INNER_FIELD_ACCESS_OR_NULL(onion_fields_conv);
54324         onion_fields_conv = RecipientOnionFields_clone(&onion_fields_conv);
54325         void* purpose_ptr = untag_ptr(purpose);
54326         CHECK_ACCESS(purpose_ptr);
54327         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
54328         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
54329         LDKThirtyTwoBytes via_channel_id_ref;
54330         CHECK((*env)->GetArrayLength(env, via_channel_id) == 32);
54331         (*env)->GetByteArrayRegion(env, via_channel_id, 0, 32, via_channel_id_ref.data);
54332         void* via_user_channel_id_ptr = untag_ptr(via_user_channel_id);
54333         CHECK_ACCESS(via_user_channel_id_ptr);
54334         LDKCOption_u128Z via_user_channel_id_conv = *(LDKCOption_u128Z*)(via_user_channel_id_ptr);
54335         via_user_channel_id_conv = COption_u128Z_clone((LDKCOption_u128Z*)untag_ptr(via_user_channel_id));
54336         void* claim_deadline_ptr = untag_ptr(claim_deadline);
54337         CHECK_ACCESS(claim_deadline_ptr);
54338         LDKCOption_u32Z claim_deadline_conv = *(LDKCOption_u32Z*)(claim_deadline_ptr);
54339         claim_deadline_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(claim_deadline));
54340         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54341         *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);
54342         int64_t ret_ref = tag_ptr(ret_copy, true);
54343         return ret_ref;
54344 }
54345
54346 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) {
54347         LDKPublicKey receiver_node_id_ref;
54348         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
54349         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
54350         LDKThirtyTwoBytes payment_hash_ref;
54351         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54352         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54353         void* purpose_ptr = untag_ptr(purpose);
54354         CHECK_ACCESS(purpose_ptr);
54355         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
54356         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
54357         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54358         *ret_copy = Event_payment_claimed(receiver_node_id_ref, payment_hash_ref, amount_msat, purpose_conv);
54359         int64_t ret_ref = tag_ptr(ret_copy, true);
54360         return ret_ref;
54361 }
54362
54363 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) {
54364         LDKThirtyTwoBytes payment_id_ref;
54365         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54366         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54367         LDKThirtyTwoBytes payment_preimage_ref;
54368         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
54369         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
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* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
54374         CHECK_ACCESS(fee_paid_msat_ptr);
54375         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
54376         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
54377         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54378         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_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_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_t reason) {
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_hash_ref;
54388         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54389         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54390         void* reason_ptr = untag_ptr(reason);
54391         CHECK_ACCESS(reason_ptr);
54392         LDKCOption_PaymentFailureReasonZ reason_conv = *(LDKCOption_PaymentFailureReasonZ*)(reason_ptr);
54393         reason_conv = COption_PaymentFailureReasonZ_clone((LDKCOption_PaymentFailureReasonZ*)untag_ptr(reason));
54394         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54395         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref, reason_conv);
54396         int64_t ret_ref = tag_ptr(ret_copy, true);
54397         return ret_ref;
54398 }
54399
54400 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) {
54401         LDKThirtyTwoBytes payment_id_ref;
54402         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54403         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54404         LDKThirtyTwoBytes payment_hash_ref;
54405         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54406         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54407         LDKPath path_conv;
54408         path_conv.inner = untag_ptr(path);
54409         path_conv.is_owned = ptr_is_owned(path);
54410         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54411         path_conv = Path_clone(&path_conv);
54412         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54413         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_conv);
54414         int64_t ret_ref = tag_ptr(ret_copy, true);
54415         return ret_ref;
54416 }
54417
54418 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) {
54419         LDKThirtyTwoBytes payment_id_ref;
54420         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54421         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54422         LDKThirtyTwoBytes payment_hash_ref;
54423         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54424         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54425         void* failure_ptr = untag_ptr(failure);
54426         CHECK_ACCESS(failure_ptr);
54427         LDKPathFailure failure_conv = *(LDKPathFailure*)(failure_ptr);
54428         failure_conv = PathFailure_clone((LDKPathFailure*)untag_ptr(failure));
54429         LDKPath path_conv;
54430         path_conv.inner = untag_ptr(path);
54431         path_conv.is_owned = ptr_is_owned(path);
54432         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54433         path_conv = Path_clone(&path_conv);
54434         void* short_channel_id_ptr = untag_ptr(short_channel_id);
54435         CHECK_ACCESS(short_channel_id_ptr);
54436         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
54437         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
54438         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54439         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, payment_failed_permanently, failure_conv, path_conv, short_channel_id_conv);
54440         int64_t ret_ref = tag_ptr(ret_copy, true);
54441         return ret_ref;
54442 }
54443
54444 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) {
54445         LDKThirtyTwoBytes payment_id_ref;
54446         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54447         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54448         LDKThirtyTwoBytes payment_hash_ref;
54449         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54450         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54451         LDKPath path_conv;
54452         path_conv.inner = untag_ptr(path);
54453         path_conv.is_owned = ptr_is_owned(path);
54454         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54455         path_conv = Path_clone(&path_conv);
54456         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54457         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_conv);
54458         int64_t ret_ref = tag_ptr(ret_copy, true);
54459         return ret_ref;
54460 }
54461
54462 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) {
54463         LDKThirtyTwoBytes payment_id_ref;
54464         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
54465         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
54466         LDKThirtyTwoBytes payment_hash_ref;
54467         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54468         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54469         LDKPath path_conv;
54470         path_conv.inner = untag_ptr(path);
54471         path_conv.is_owned = ptr_is_owned(path);
54472         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
54473         path_conv = Path_clone(&path_conv);
54474         void* short_channel_id_ptr = untag_ptr(short_channel_id);
54475         CHECK_ACCESS(short_channel_id_ptr);
54476         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
54477         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
54478         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54479         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_conv, short_channel_id_conv);
54480         int64_t ret_ref = tag_ptr(ret_copy, true);
54481         return ret_ref;
54482 }
54483
54484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
54485         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54486         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
54487         int64_t ret_ref = tag_ptr(ret_copy, true);
54488         return ret_ref;
54489 }
54490
54491 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) {
54492         LDKThirtyTwoBytes intercept_id_ref;
54493         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
54494         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
54495         LDKThirtyTwoBytes payment_hash_ref;
54496         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
54497         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
54498         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54499         *ret_copy = Event_htlcintercepted(intercept_id_ref, requested_next_hop_scid, payment_hash_ref, inbound_amount_msat, expected_outbound_amount_msat);
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_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
54505         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
54506         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
54507         if (outputs_constr.datalen > 0)
54508                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
54509         else
54510                 outputs_constr.data = NULL;
54511         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
54512         for (size_t b = 0; b < outputs_constr.datalen; b++) {
54513                 int64_t outputs_conv_27 = outputs_vals[b];
54514                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
54515                 CHECK_ACCESS(outputs_conv_27_ptr);
54516                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
54517                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
54518                 outputs_constr.data[b] = outputs_conv_27_conv;
54519         }
54520         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
54521         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54522         *ret_copy = Event_spendable_outputs(outputs_constr);
54523         int64_t ret_ref = tag_ptr(ret_copy, true);
54524         return ret_ref;
54525 }
54526
54527 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) {
54528         LDKThirtyTwoBytes prev_channel_id_ref;
54529         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
54530         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
54531         LDKThirtyTwoBytes next_channel_id_ref;
54532         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
54533         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
54534         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
54535         CHECK_ACCESS(fee_earned_msat_ptr);
54536         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
54537         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
54538         void* outbound_amount_forwarded_msat_ptr = untag_ptr(outbound_amount_forwarded_msat);
54539         CHECK_ACCESS(outbound_amount_forwarded_msat_ptr);
54540         LDKCOption_u64Z outbound_amount_forwarded_msat_conv = *(LDKCOption_u64Z*)(outbound_amount_forwarded_msat_ptr);
54541         outbound_amount_forwarded_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_amount_forwarded_msat));
54542         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54543         *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);
54544         int64_t ret_ref = tag_ptr(ret_copy, true);
54545         return ret_ref;
54546 }
54547
54548 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) {
54549         LDKThirtyTwoBytes channel_id_ref;
54550         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54551         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54552         LDKU128 user_channel_id_ref;
54553         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54554         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54555         LDKThirtyTwoBytes former_temporary_channel_id_ref;
54556         CHECK((*env)->GetArrayLength(env, former_temporary_channel_id) == 32);
54557         (*env)->GetByteArrayRegion(env, former_temporary_channel_id, 0, 32, former_temporary_channel_id_ref.data);
54558         LDKPublicKey counterparty_node_id_ref;
54559         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54560         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54561         LDKOutPoint funding_txo_conv;
54562         funding_txo_conv.inner = untag_ptr(funding_txo);
54563         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
54564         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
54565         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
54566         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54567         *ret_copy = Event_channel_pending(channel_id_ref, user_channel_id_ref, former_temporary_channel_id_ref, counterparty_node_id_ref, funding_txo_conv);
54568         int64_t ret_ref = tag_ptr(ret_copy, true);
54569         return ret_ref;
54570 }
54571
54572 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) {
54573         LDKThirtyTwoBytes channel_id_ref;
54574         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54575         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54576         LDKU128 user_channel_id_ref;
54577         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54578         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54579         LDKPublicKey counterparty_node_id_ref;
54580         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54581         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54582         LDKChannelTypeFeatures channel_type_conv;
54583         channel_type_conv.inner = untag_ptr(channel_type);
54584         channel_type_conv.is_owned = ptr_is_owned(channel_type);
54585         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
54586         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
54587         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54588         *ret_copy = Event_channel_ready(channel_id_ref, user_channel_id_ref, counterparty_node_id_ref, channel_type_conv);
54589         int64_t ret_ref = tag_ptr(ret_copy, true);
54590         return ret_ref;
54591 }
54592
54593 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) {
54594         LDKThirtyTwoBytes channel_id_ref;
54595         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54596         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54597         LDKU128 user_channel_id_ref;
54598         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
54599         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
54600         void* reason_ptr = untag_ptr(reason);
54601         CHECK_ACCESS(reason_ptr);
54602         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
54603         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
54604         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54605         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id_ref, reason_conv);
54606         int64_t ret_ref = tag_ptr(ret_copy, true);
54607         return ret_ref;
54608 }
54609
54610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
54611         LDKThirtyTwoBytes channel_id_ref;
54612         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
54613         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
54614         LDKTransaction transaction_ref;
54615         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
54616         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
54617         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
54618         transaction_ref.data_is_owned = true;
54619         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54620         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
54621         int64_t ret_ref = tag_ptr(ret_copy, true);
54622         return ret_ref;
54623 }
54624
54625 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) {
54626         LDKThirtyTwoBytes temporary_channel_id_ref;
54627         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
54628         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
54629         LDKPublicKey counterparty_node_id_ref;
54630         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
54631         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
54632         LDKChannelTypeFeatures channel_type_conv;
54633         channel_type_conv.inner = untag_ptr(channel_type);
54634         channel_type_conv.is_owned = ptr_is_owned(channel_type);
54635         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
54636         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
54637         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54638         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
54639         int64_t ret_ref = tag_ptr(ret_copy, true);
54640         return ret_ref;
54641 }
54642
54643 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) {
54644         LDKThirtyTwoBytes prev_channel_id_ref;
54645         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
54646         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
54647         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
54648         CHECK_ACCESS(failed_next_destination_ptr);
54649         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
54650         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
54651         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
54652         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
54653         int64_t ret_ref = tag_ptr(ret_copy, true);
54654         return ret_ref;
54655 }
54656
54657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Event_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
54658         LDKEvent* a_conv = (LDKEvent*)untag_ptr(a);
54659         LDKEvent* b_conv = (LDKEvent*)untag_ptr(b);
54660         jboolean ret_conv = Event_eq(a_conv, b_conv);
54661         return ret_conv;
54662 }
54663
54664 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
54665         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
54666         LDKCVec_u8Z ret_var = Event_write(obj_conv);
54667         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
54668         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
54669         CVec_u8Z_free(ret_var);
54670         return ret_arr;
54671 }
54672
54673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
54674         LDKu8slice ser_ref;
54675         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
54676         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
54677         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
54678         *ret_conv = Event_read(ser_ref);
54679         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
54680         return tag_ptr(ret_conv, true);
54681 }
54682
54683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
54684         if (!ptr_is_owned(this_ptr)) return;
54685         void* this_ptr_ptr = untag_ptr(this_ptr);
54686         CHECK_ACCESS(this_ptr_ptr);
54687         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
54688         FREE(untag_ptr(this_ptr));
54689         MessageSendEvent_free(this_ptr_conv);
54690 }
54691
54692 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
54693         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54694         *ret_copy = MessageSendEvent_clone(arg);
54695         int64_t ret_ref = tag_ptr(ret_copy, true);
54696         return ret_ref;
54697 }
54698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
54699         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
54700         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
54701         return ret_conv;
54702 }
54703
54704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
54705         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
54706         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54707         *ret_copy = MessageSendEvent_clone(orig_conv);
54708         int64_t ret_ref = tag_ptr(ret_copy, true);
54709         return ret_ref;
54710 }
54711
54712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54713         LDKPublicKey node_id_ref;
54714         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54715         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54716         LDKAcceptChannel msg_conv;
54717         msg_conv.inner = untag_ptr(msg);
54718         msg_conv.is_owned = ptr_is_owned(msg);
54719         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54720         msg_conv = AcceptChannel_clone(&msg_conv);
54721         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54722         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
54723         int64_t ret_ref = tag_ptr(ret_copy, true);
54724         return ret_ref;
54725 }
54726
54727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54728         LDKPublicKey node_id_ref;
54729         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54730         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54731         LDKOpenChannel msg_conv;
54732         msg_conv.inner = untag_ptr(msg);
54733         msg_conv.is_owned = ptr_is_owned(msg);
54734         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54735         msg_conv = OpenChannel_clone(&msg_conv);
54736         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54737         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
54738         int64_t ret_ref = tag_ptr(ret_copy, true);
54739         return ret_ref;
54740 }
54741
54742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54743         LDKPublicKey node_id_ref;
54744         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54745         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54746         LDKFundingCreated msg_conv;
54747         msg_conv.inner = untag_ptr(msg);
54748         msg_conv.is_owned = ptr_is_owned(msg);
54749         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54750         msg_conv = FundingCreated_clone(&msg_conv);
54751         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54752         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
54753         int64_t ret_ref = tag_ptr(ret_copy, true);
54754         return ret_ref;
54755 }
54756
54757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54758         LDKPublicKey node_id_ref;
54759         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54760         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54761         LDKFundingSigned msg_conv;
54762         msg_conv.inner = untag_ptr(msg);
54763         msg_conv.is_owned = ptr_is_owned(msg);
54764         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54765         msg_conv = FundingSigned_clone(&msg_conv);
54766         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54767         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
54768         int64_t ret_ref = tag_ptr(ret_copy, true);
54769         return ret_ref;
54770 }
54771
54772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54773         LDKPublicKey node_id_ref;
54774         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54775         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54776         LDKChannelReady msg_conv;
54777         msg_conv.inner = untag_ptr(msg);
54778         msg_conv.is_owned = ptr_is_owned(msg);
54779         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54780         msg_conv = ChannelReady_clone(&msg_conv);
54781         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54782         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
54783         int64_t ret_ref = tag_ptr(ret_copy, true);
54784         return ret_ref;
54785 }
54786
54787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54788         LDKPublicKey node_id_ref;
54789         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54790         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54791         LDKAnnouncementSignatures msg_conv;
54792         msg_conv.inner = untag_ptr(msg);
54793         msg_conv.is_owned = ptr_is_owned(msg);
54794         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54795         msg_conv = AnnouncementSignatures_clone(&msg_conv);
54796         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54797         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
54798         int64_t ret_ref = tag_ptr(ret_copy, true);
54799         return ret_ref;
54800 }
54801
54802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
54803         LDKPublicKey node_id_ref;
54804         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54805         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54806         LDKCommitmentUpdate updates_conv;
54807         updates_conv.inner = untag_ptr(updates);
54808         updates_conv.is_owned = ptr_is_owned(updates);
54809         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
54810         updates_conv = CommitmentUpdate_clone(&updates_conv);
54811         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54812         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
54813         int64_t ret_ref = tag_ptr(ret_copy, true);
54814         return ret_ref;
54815 }
54816
54817 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) {
54818         LDKPublicKey node_id_ref;
54819         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54820         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54821         LDKRevokeAndACK msg_conv;
54822         msg_conv.inner = untag_ptr(msg);
54823         msg_conv.is_owned = ptr_is_owned(msg);
54824         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54825         msg_conv = RevokeAndACK_clone(&msg_conv);
54826         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54827         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
54828         int64_t ret_ref = tag_ptr(ret_copy, true);
54829         return ret_ref;
54830 }
54831
54832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54833         LDKPublicKey node_id_ref;
54834         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54835         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54836         LDKClosingSigned msg_conv;
54837         msg_conv.inner = untag_ptr(msg);
54838         msg_conv.is_owned = ptr_is_owned(msg);
54839         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54840         msg_conv = ClosingSigned_clone(&msg_conv);
54841         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54842         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
54843         int64_t ret_ref = tag_ptr(ret_copy, true);
54844         return ret_ref;
54845 }
54846
54847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54848         LDKPublicKey node_id_ref;
54849         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54850         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54851         LDKShutdown msg_conv;
54852         msg_conv.inner = untag_ptr(msg);
54853         msg_conv.is_owned = ptr_is_owned(msg);
54854         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54855         msg_conv = Shutdown_clone(&msg_conv);
54856         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54857         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
54858         int64_t ret_ref = tag_ptr(ret_copy, true);
54859         return ret_ref;
54860 }
54861
54862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54863         LDKPublicKey node_id_ref;
54864         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54865         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54866         LDKChannelReestablish msg_conv;
54867         msg_conv.inner = untag_ptr(msg);
54868         msg_conv.is_owned = ptr_is_owned(msg);
54869         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54870         msg_conv = ChannelReestablish_clone(&msg_conv);
54871         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54872         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
54873         int64_t ret_ref = tag_ptr(ret_copy, true);
54874         return ret_ref;
54875 }
54876
54877 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) {
54878         LDKPublicKey node_id_ref;
54879         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54880         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54881         LDKChannelAnnouncement msg_conv;
54882         msg_conv.inner = untag_ptr(msg);
54883         msg_conv.is_owned = ptr_is_owned(msg);
54884         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54885         msg_conv = ChannelAnnouncement_clone(&msg_conv);
54886         LDKChannelUpdate update_msg_conv;
54887         update_msg_conv.inner = untag_ptr(update_msg);
54888         update_msg_conv.is_owned = ptr_is_owned(update_msg);
54889         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
54890         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
54891         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54892         *ret_copy = MessageSendEvent_send_channel_announcement(node_id_ref, msg_conv, update_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_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
54898         LDKChannelAnnouncement msg_conv;
54899         msg_conv.inner = untag_ptr(msg);
54900         msg_conv.is_owned = ptr_is_owned(msg);
54901         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54902         msg_conv = ChannelAnnouncement_clone(&msg_conv);
54903         LDKChannelUpdate update_msg_conv;
54904         update_msg_conv.inner = untag_ptr(update_msg);
54905         update_msg_conv.is_owned = ptr_is_owned(update_msg);
54906         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
54907         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
54908         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54909         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
54910         int64_t ret_ref = tag_ptr(ret_copy, true);
54911         return ret_ref;
54912 }
54913
54914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
54915         LDKChannelUpdate msg_conv;
54916         msg_conv.inner = untag_ptr(msg);
54917         msg_conv.is_owned = ptr_is_owned(msg);
54918         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54919         msg_conv = ChannelUpdate_clone(&msg_conv);
54920         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54921         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
54922         int64_t ret_ref = tag_ptr(ret_copy, true);
54923         return ret_ref;
54924 }
54925
54926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
54927         LDKNodeAnnouncement msg_conv;
54928         msg_conv.inner = untag_ptr(msg);
54929         msg_conv.is_owned = ptr_is_owned(msg);
54930         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54931         msg_conv = NodeAnnouncement_clone(&msg_conv);
54932         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54933         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
54934         int64_t ret_ref = tag_ptr(ret_copy, true);
54935         return ret_ref;
54936 }
54937
54938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
54939         LDKPublicKey node_id_ref;
54940         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54941         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54942         LDKChannelUpdate msg_conv;
54943         msg_conv.inner = untag_ptr(msg);
54944         msg_conv.is_owned = ptr_is_owned(msg);
54945         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54946         msg_conv = ChannelUpdate_clone(&msg_conv);
54947         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54948         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
54949         int64_t ret_ref = tag_ptr(ret_copy, true);
54950         return ret_ref;
54951 }
54952
54953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
54954         LDKPublicKey node_id_ref;
54955         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54956         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54957         void* action_ptr = untag_ptr(action);
54958         CHECK_ACCESS(action_ptr);
54959         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
54960         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
54961         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54962         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
54963         int64_t ret_ref = tag_ptr(ret_copy, true);
54964         return ret_ref;
54965 }
54966
54967 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) {
54968         LDKPublicKey node_id_ref;
54969         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54970         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54971         LDKQueryChannelRange msg_conv;
54972         msg_conv.inner = untag_ptr(msg);
54973         msg_conv.is_owned = ptr_is_owned(msg);
54974         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54975         msg_conv = QueryChannelRange_clone(&msg_conv);
54976         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54977         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
54978         int64_t ret_ref = tag_ptr(ret_copy, true);
54979         return ret_ref;
54980 }
54981
54982 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) {
54983         LDKPublicKey node_id_ref;
54984         CHECK((*env)->GetArrayLength(env, node_id) == 33);
54985         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
54986         LDKQueryShortChannelIds msg_conv;
54987         msg_conv.inner = untag_ptr(msg);
54988         msg_conv.is_owned = ptr_is_owned(msg);
54989         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
54990         msg_conv = QueryShortChannelIds_clone(&msg_conv);
54991         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
54992         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
54993         int64_t ret_ref = tag_ptr(ret_copy, true);
54994         return ret_ref;
54995 }
54996
54997 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) {
54998         LDKPublicKey node_id_ref;
54999         CHECK((*env)->GetArrayLength(env, node_id) == 33);
55000         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
55001         LDKReplyChannelRange msg_conv;
55002         msg_conv.inner = untag_ptr(msg);
55003         msg_conv.is_owned = ptr_is_owned(msg);
55004         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
55005         msg_conv = ReplyChannelRange_clone(&msg_conv);
55006         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
55007         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
55008         int64_t ret_ref = tag_ptr(ret_copy, true);
55009         return ret_ref;
55010 }
55011
55012 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) {
55013         LDKPublicKey node_id_ref;
55014         CHECK((*env)->GetArrayLength(env, node_id) == 33);
55015         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
55016         LDKGossipTimestampFilter msg_conv;
55017         msg_conv.inner = untag_ptr(msg);
55018         msg_conv.is_owned = ptr_is_owned(msg);
55019         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
55020         msg_conv = GossipTimestampFilter_clone(&msg_conv);
55021         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
55022         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
55023         int64_t ret_ref = tag_ptr(ret_copy, true);
55024         return ret_ref;
55025 }
55026
55027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55028         if (!ptr_is_owned(this_ptr)) return;
55029         void* this_ptr_ptr = untag_ptr(this_ptr);
55030         CHECK_ACCESS(this_ptr_ptr);
55031         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
55032         FREE(untag_ptr(this_ptr));
55033         MessageSendEventsProvider_free(this_ptr_conv);
55034 }
55035
55036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55037         if (!ptr_is_owned(this_ptr)) return;
55038         void* this_ptr_ptr = untag_ptr(this_ptr);
55039         CHECK_ACCESS(this_ptr_ptr);
55040         LDKOnionMessageProvider this_ptr_conv = *(LDKOnionMessageProvider*)(this_ptr_ptr);
55041         FREE(untag_ptr(this_ptr));
55042         OnionMessageProvider_free(this_ptr_conv);
55043 }
55044
55045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55046         if (!ptr_is_owned(this_ptr)) return;
55047         void* this_ptr_ptr = untag_ptr(this_ptr);
55048         CHECK_ACCESS(this_ptr_ptr);
55049         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
55050         FREE(untag_ptr(this_ptr));
55051         EventsProvider_free(this_ptr_conv);
55052 }
55053
55054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55055         if (!ptr_is_owned(this_ptr)) return;
55056         void* this_ptr_ptr = untag_ptr(this_ptr);
55057         CHECK_ACCESS(this_ptr_ptr);
55058         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
55059         FREE(untag_ptr(this_ptr));
55060         EventHandler_free(this_ptr_conv);
55061 }
55062
55063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55064         LDKFilesystemPersister this_obj_conv;
55065         this_obj_conv.inner = untag_ptr(this_obj);
55066         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55068         FilesystemPersister_free(this_obj_conv);
55069 }
55070
55071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
55072         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
55073         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
55074         int64_t ret_ref = 0;
55075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55076         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55077         return ret_ref;
55078 }
55079
55080 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
55081         LDKFilesystemPersister this_arg_conv;
55082         this_arg_conv.inner = untag_ptr(this_arg);
55083         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55085         this_arg_conv.is_owned = false;
55086         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
55087         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
55088         Str_free(ret_str);
55089         return ret_conv;
55090 }
55091
55092 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) {
55093         LDKFilesystemPersister this_arg_conv;
55094         this_arg_conv.inner = untag_ptr(this_arg);
55095         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55097         this_arg_conv.is_owned = false;
55098         void* entropy_source_ptr = untag_ptr(entropy_source);
55099         CHECK_ACCESS(entropy_source_ptr);
55100         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
55101         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
55102                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55103                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
55104         }
55105         void* signer_provider_ptr = untag_ptr(signer_provider);
55106         if (ptr_is_owned(signer_provider)) { CHECK_ACCESS(signer_provider_ptr); }
55107         LDKSignerProvider* signer_provider_conv = (LDKSignerProvider*)signer_provider_ptr;
55108         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
55109         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, entropy_source_conv, signer_provider_conv);
55110         return tag_ptr(ret_conv, true);
55111 }
55112
55113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55114         LDKBackgroundProcessor this_obj_conv;
55115         this_obj_conv.inner = untag_ptr(this_obj);
55116         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55118         BackgroundProcessor_free(this_obj_conv);
55119 }
55120
55121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55122         if (!ptr_is_owned(this_ptr)) return;
55123         void* this_ptr_ptr = untag_ptr(this_ptr);
55124         CHECK_ACCESS(this_ptr_ptr);
55125         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
55126         FREE(untag_ptr(this_ptr));
55127         GossipSync_free(this_ptr_conv);
55128 }
55129
55130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
55131         LDKP2PGossipSync a_conv;
55132         a_conv.inner = untag_ptr(a);
55133         a_conv.is_owned = ptr_is_owned(a);
55134         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55135         a_conv.is_owned = false;
55136         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
55137         *ret_copy = GossipSync_p2_p(&a_conv);
55138         int64_t ret_ref = tag_ptr(ret_copy, true);
55139         return ret_ref;
55140 }
55141
55142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
55143         LDKRapidGossipSync a_conv;
55144         a_conv.inner = untag_ptr(a);
55145         a_conv.is_owned = ptr_is_owned(a);
55146         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55147         a_conv.is_owned = false;
55148         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
55149         *ret_copy = GossipSync_rapid(&a_conv);
55150         int64_t ret_ref = tag_ptr(ret_copy, true);
55151         return ret_ref;
55152 }
55153
55154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
55155         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
55156         *ret_copy = GossipSync_none();
55157         int64_t ret_ref = tag_ptr(ret_copy, true);
55158         return ret_ref;
55159 }
55160
55161 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) {
55162         void* persister_ptr = untag_ptr(persister);
55163         CHECK_ACCESS(persister_ptr);
55164         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
55165         if (persister_conv.free == LDKPersister_JCalls_free) {
55166                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55167                 LDKPersister_JCalls_cloned(&persister_conv);
55168         }
55169         void* event_handler_ptr = untag_ptr(event_handler);
55170         CHECK_ACCESS(event_handler_ptr);
55171         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
55172         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
55173                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55174                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
55175         }
55176         LDKChainMonitor chain_monitor_conv;
55177         chain_monitor_conv.inner = untag_ptr(chain_monitor);
55178         chain_monitor_conv.is_owned = ptr_is_owned(chain_monitor);
55179         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
55180         chain_monitor_conv.is_owned = false;
55181         LDKChannelManager channel_manager_conv;
55182         channel_manager_conv.inner = untag_ptr(channel_manager);
55183         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
55184         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
55185         channel_manager_conv.is_owned = false;
55186         void* gossip_sync_ptr = untag_ptr(gossip_sync);
55187         CHECK_ACCESS(gossip_sync_ptr);
55188         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
55189         // WARNING: we may need a move here but no clone is available for LDKGossipSync
55190         LDKPeerManager peer_manager_conv;
55191         peer_manager_conv.inner = untag_ptr(peer_manager);
55192         peer_manager_conv.is_owned = ptr_is_owned(peer_manager);
55193         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
55194         peer_manager_conv.is_owned = false;
55195         void* logger_ptr = untag_ptr(logger);
55196         CHECK_ACCESS(logger_ptr);
55197         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
55198         if (logger_conv.free == LDKLogger_JCalls_free) {
55199                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55200                 LDKLogger_JCalls_cloned(&logger_conv);
55201         }
55202         void* scorer_ptr = untag_ptr(scorer);
55203         CHECK_ACCESS(scorer_ptr);
55204         LDKCOption_WriteableScoreZ scorer_conv = *(LDKCOption_WriteableScoreZ*)(scorer_ptr);
55205         // WARNING: we may need a move here but no clone is available for LDKCOption_WriteableScoreZ
55206         if (scorer_conv.tag == LDKCOption_WriteableScoreZ_Some) {
55207                 // Manually implement clone for Java trait instances
55208                 if (scorer_conv.some.free == LDKWriteableScore_JCalls_free) {
55209                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
55210                         LDKWriteableScore_JCalls_cloned(&scorer_conv.some);
55211                 }
55212         }
55213         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);
55214         int64_t ret_ref = 0;
55215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55216         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55217         return ret_ref;
55218 }
55219
55220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
55221         LDKBackgroundProcessor this_arg_conv;
55222         this_arg_conv.inner = untag_ptr(this_arg);
55223         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55225         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
55226         
55227         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
55228         *ret_conv = BackgroundProcessor_join(this_arg_conv);
55229         return tag_ptr(ret_conv, true);
55230 }
55231
55232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
55233         LDKBackgroundProcessor this_arg_conv;
55234         this_arg_conv.inner = untag_ptr(this_arg);
55235         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55237         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
55238         
55239         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
55240         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
55241         return tag_ptr(ret_conv, true);
55242 }
55243
55244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55245         if (!ptr_is_owned(this_ptr)) return;
55246         void* this_ptr_ptr = untag_ptr(this_ptr);
55247         CHECK_ACCESS(this_ptr_ptr);
55248         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
55249         FREE(untag_ptr(this_ptr));
55250         ParseError_free(this_ptr_conv);
55251 }
55252
55253 static inline uint64_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
55254         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55255         *ret_copy = ParseError_clone(arg);
55256         int64_t ret_ref = tag_ptr(ret_copy, true);
55257         return ret_ref;
55258 }
55259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55260         LDKParseError* arg_conv = (LDKParseError*)untag_ptr(arg);
55261         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
55262         return ret_conv;
55263 }
55264
55265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55266         LDKParseError* orig_conv = (LDKParseError*)untag_ptr(orig);
55267         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55268         *ret_copy = ParseError_clone(orig_conv);
55269         int64_t ret_ref = tag_ptr(ret_copy, true);
55270         return ret_ref;
55271 }
55272
55273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
55274         void* a_ptr = untag_ptr(a);
55275         CHECK_ACCESS(a_ptr);
55276         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
55277         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
55278         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55279         *ret_copy = ParseError_bech32_error(a_conv);
55280         int64_t ret_ref = tag_ptr(ret_copy, true);
55281         return ret_ref;
55282 }
55283
55284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
55285         
55286         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55287         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
55288         int64_t ret_ref = tag_ptr(ret_copy, true);
55289         return ret_ref;
55290 }
55291
55292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
55293         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
55294         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55295         *ret_copy = ParseError_malformed_signature(a_conv);
55296         int64_t ret_ref = tag_ptr(ret_copy, true);
55297         return ret_ref;
55298 }
55299
55300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
55301         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55302         *ret_copy = ParseError_bad_prefix();
55303         int64_t ret_ref = tag_ptr(ret_copy, true);
55304         return ret_ref;
55305 }
55306
55307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
55308         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55309         *ret_copy = ParseError_unknown_currency();
55310         int64_t ret_ref = tag_ptr(ret_copy, true);
55311         return ret_ref;
55312 }
55313
55314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
55315         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55316         *ret_copy = ParseError_unknown_si_prefix();
55317         int64_t ret_ref = tag_ptr(ret_copy, true);
55318         return ret_ref;
55319 }
55320
55321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
55322         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55323         *ret_copy = ParseError_malformed_hrp();
55324         int64_t ret_ref = tag_ptr(ret_copy, true);
55325         return ret_ref;
55326 }
55327
55328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
55329         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55330         *ret_copy = ParseError_too_short_data_part();
55331         int64_t ret_ref = tag_ptr(ret_copy, true);
55332         return ret_ref;
55333 }
55334
55335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
55336         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55337         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
55338         int64_t ret_ref = tag_ptr(ret_copy, true);
55339         return ret_ref;
55340 }
55341
55342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
55343         
55344         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55345         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
55346         int64_t ret_ref = tag_ptr(ret_copy, true);
55347         return ret_ref;
55348 }
55349
55350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
55351         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55352         *ret_copy = ParseError_padding_error();
55353         int64_t ret_ref = tag_ptr(ret_copy, true);
55354         return ret_ref;
55355 }
55356
55357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
55358         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55359         *ret_copy = ParseError_integer_overflow_error();
55360         int64_t ret_ref = tag_ptr(ret_copy, true);
55361         return ret_ref;
55362 }
55363
55364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
55365         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55366         *ret_copy = ParseError_invalid_seg_wit_program_length();
55367         int64_t ret_ref = tag_ptr(ret_copy, true);
55368         return ret_ref;
55369 }
55370
55371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
55372         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55373         *ret_copy = ParseError_invalid_pub_key_hash_length();
55374         int64_t ret_ref = tag_ptr(ret_copy, true);
55375         return ret_ref;
55376 }
55377
55378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
55379         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55380         *ret_copy = ParseError_invalid_script_hash_length();
55381         int64_t ret_ref = tag_ptr(ret_copy, true);
55382         return ret_ref;
55383 }
55384
55385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
55386         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55387         *ret_copy = ParseError_invalid_recovery_id();
55388         int64_t ret_ref = tag_ptr(ret_copy, true);
55389         return ret_ref;
55390 }
55391
55392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
55393         LDKStr a_conv = java_to_owned_str(env, a);
55394         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55395         *ret_copy = ParseError_invalid_slice_length(a_conv);
55396         int64_t ret_ref = tag_ptr(ret_copy, true);
55397         return ret_ref;
55398 }
55399
55400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
55401         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
55402         *ret_copy = ParseError_skip();
55403         int64_t ret_ref = tag_ptr(ret_copy, true);
55404         return ret_ref;
55405 }
55406
55407 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55408         LDKParseError* a_conv = (LDKParseError*)untag_ptr(a);
55409         LDKParseError* b_conv = (LDKParseError*)untag_ptr(b);
55410         jboolean ret_conv = ParseError_eq(a_conv, b_conv);
55411         return ret_conv;
55412 }
55413
55414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
55415         if (!ptr_is_owned(this_ptr)) return;
55416         void* this_ptr_ptr = untag_ptr(this_ptr);
55417         CHECK_ACCESS(this_ptr_ptr);
55418         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
55419         FREE(untag_ptr(this_ptr));
55420         ParseOrSemanticError_free(this_ptr_conv);
55421 }
55422
55423 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
55424         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55425         *ret_copy = ParseOrSemanticError_clone(arg);
55426         int64_t ret_ref = tag_ptr(ret_copy, true);
55427         return ret_ref;
55428 }
55429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55430         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
55431         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
55432         return ret_conv;
55433 }
55434
55435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55436         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
55437         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55438         *ret_copy = ParseOrSemanticError_clone(orig_conv);
55439         int64_t ret_ref = tag_ptr(ret_copy, true);
55440         return ret_ref;
55441 }
55442
55443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
55444         void* a_ptr = untag_ptr(a);
55445         CHECK_ACCESS(a_ptr);
55446         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
55447         a_conv = ParseError_clone((LDKParseError*)untag_ptr(a));
55448         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55449         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
55450         int64_t ret_ref = tag_ptr(ret_copy, true);
55451         return ret_ref;
55452 }
55453
55454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
55455         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
55456         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
55457         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
55458         int64_t ret_ref = tag_ptr(ret_copy, true);
55459         return ret_ref;
55460 }
55461
55462 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55463         LDKParseOrSemanticError* a_conv = (LDKParseOrSemanticError*)untag_ptr(a);
55464         LDKParseOrSemanticError* b_conv = (LDKParseOrSemanticError*)untag_ptr(b);
55465         jboolean ret_conv = ParseOrSemanticError_eq(a_conv, b_conv);
55466         return ret_conv;
55467 }
55468
55469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55470         LDKInvoice this_obj_conv;
55471         this_obj_conv.inner = untag_ptr(this_obj);
55472         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55474         Invoice_free(this_obj_conv);
55475 }
55476
55477 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55478         LDKInvoice a_conv;
55479         a_conv.inner = untag_ptr(a);
55480         a_conv.is_owned = ptr_is_owned(a);
55481         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55482         a_conv.is_owned = false;
55483         LDKInvoice b_conv;
55484         b_conv.inner = untag_ptr(b);
55485         b_conv.is_owned = ptr_is_owned(b);
55486         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55487         b_conv.is_owned = false;
55488         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
55489         return ret_conv;
55490 }
55491
55492 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
55493         LDKInvoice ret_var = Invoice_clone(arg);
55494         int64_t ret_ref = 0;
55495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55496         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55497         return ret_ref;
55498 }
55499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55500         LDKInvoice arg_conv;
55501         arg_conv.inner = untag_ptr(arg);
55502         arg_conv.is_owned = ptr_is_owned(arg);
55503         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55504         arg_conv.is_owned = false;
55505         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
55506         return ret_conv;
55507 }
55508
55509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55510         LDKInvoice orig_conv;
55511         orig_conv.inner = untag_ptr(orig);
55512         orig_conv.is_owned = ptr_is_owned(orig);
55513         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55514         orig_conv.is_owned = false;
55515         LDKInvoice ret_var = Invoice_clone(&orig_conv);
55516         int64_t ret_ref = 0;
55517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55518         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55519         return ret_ref;
55520 }
55521
55522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
55523         LDKInvoice o_conv;
55524         o_conv.inner = untag_ptr(o);
55525         o_conv.is_owned = ptr_is_owned(o);
55526         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55527         o_conv.is_owned = false;
55528         int64_t ret_conv = Invoice_hash(&o_conv);
55529         return ret_conv;
55530 }
55531
55532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55533         LDKSignedRawInvoice this_obj_conv;
55534         this_obj_conv.inner = untag_ptr(this_obj);
55535         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55537         SignedRawInvoice_free(this_obj_conv);
55538 }
55539
55540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55541         LDKSignedRawInvoice a_conv;
55542         a_conv.inner = untag_ptr(a);
55543         a_conv.is_owned = ptr_is_owned(a);
55544         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55545         a_conv.is_owned = false;
55546         LDKSignedRawInvoice b_conv;
55547         b_conv.inner = untag_ptr(b);
55548         b_conv.is_owned = ptr_is_owned(b);
55549         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55550         b_conv.is_owned = false;
55551         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
55552         return ret_conv;
55553 }
55554
55555 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
55556         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
55557         int64_t ret_ref = 0;
55558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55559         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55560         return ret_ref;
55561 }
55562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55563         LDKSignedRawInvoice arg_conv;
55564         arg_conv.inner = untag_ptr(arg);
55565         arg_conv.is_owned = ptr_is_owned(arg);
55566         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55567         arg_conv.is_owned = false;
55568         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
55569         return ret_conv;
55570 }
55571
55572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55573         LDKSignedRawInvoice orig_conv;
55574         orig_conv.inner = untag_ptr(orig);
55575         orig_conv.is_owned = ptr_is_owned(orig);
55576         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55577         orig_conv.is_owned = false;
55578         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
55579         int64_t ret_ref = 0;
55580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55581         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55582         return ret_ref;
55583 }
55584
55585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
55586         LDKSignedRawInvoice o_conv;
55587         o_conv.inner = untag_ptr(o);
55588         o_conv.is_owned = ptr_is_owned(o);
55589         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55590         o_conv.is_owned = false;
55591         int64_t ret_conv = SignedRawInvoice_hash(&o_conv);
55592         return ret_conv;
55593 }
55594
55595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55596         LDKRawInvoice this_obj_conv;
55597         this_obj_conv.inner = untag_ptr(this_obj);
55598         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55600         RawInvoice_free(this_obj_conv);
55601 }
55602
55603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
55604         LDKRawInvoice this_ptr_conv;
55605         this_ptr_conv.inner = untag_ptr(this_ptr);
55606         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55608         this_ptr_conv.is_owned = false;
55609         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
55610         int64_t ret_ref = 0;
55611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55612         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55613         return ret_ref;
55614 }
55615
55616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
55617         LDKRawInvoice this_ptr_conv;
55618         this_ptr_conv.inner = untag_ptr(this_ptr);
55619         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55621         this_ptr_conv.is_owned = false;
55622         LDKRawDataPart val_conv;
55623         val_conv.inner = untag_ptr(val);
55624         val_conv.is_owned = ptr_is_owned(val);
55625         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
55626         val_conv = RawDataPart_clone(&val_conv);
55627         RawInvoice_set_data(&this_ptr_conv, val_conv);
55628 }
55629
55630 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55631         LDKRawInvoice a_conv;
55632         a_conv.inner = untag_ptr(a);
55633         a_conv.is_owned = ptr_is_owned(a);
55634         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55635         a_conv.is_owned = false;
55636         LDKRawInvoice b_conv;
55637         b_conv.inner = untag_ptr(b);
55638         b_conv.is_owned = ptr_is_owned(b);
55639         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55640         b_conv.is_owned = false;
55641         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
55642         return ret_conv;
55643 }
55644
55645 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
55646         LDKRawInvoice ret_var = RawInvoice_clone(arg);
55647         int64_t ret_ref = 0;
55648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55649         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55650         return ret_ref;
55651 }
55652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55653         LDKRawInvoice arg_conv;
55654         arg_conv.inner = untag_ptr(arg);
55655         arg_conv.is_owned = ptr_is_owned(arg);
55656         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55657         arg_conv.is_owned = false;
55658         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
55659         return ret_conv;
55660 }
55661
55662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55663         LDKRawInvoice orig_conv;
55664         orig_conv.inner = untag_ptr(orig);
55665         orig_conv.is_owned = ptr_is_owned(orig);
55666         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55667         orig_conv.is_owned = false;
55668         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
55669         int64_t ret_ref = 0;
55670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55671         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55672         return ret_ref;
55673 }
55674
55675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
55676         LDKRawInvoice o_conv;
55677         o_conv.inner = untag_ptr(o);
55678         o_conv.is_owned = ptr_is_owned(o);
55679         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55680         o_conv.is_owned = false;
55681         int64_t ret_conv = RawInvoice_hash(&o_conv);
55682         return ret_conv;
55683 }
55684
55685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55686         LDKRawDataPart this_obj_conv;
55687         this_obj_conv.inner = untag_ptr(this_obj);
55688         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55690         RawDataPart_free(this_obj_conv);
55691 }
55692
55693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
55694         LDKRawDataPart this_ptr_conv;
55695         this_ptr_conv.inner = untag_ptr(this_ptr);
55696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55698         this_ptr_conv.is_owned = false;
55699         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
55700         int64_t ret_ref = 0;
55701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55702         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55703         return ret_ref;
55704 }
55705
55706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
55707         LDKRawDataPart this_ptr_conv;
55708         this_ptr_conv.inner = untag_ptr(this_ptr);
55709         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55711         this_ptr_conv.is_owned = false;
55712         LDKPositiveTimestamp val_conv;
55713         val_conv.inner = untag_ptr(val);
55714         val_conv.is_owned = ptr_is_owned(val);
55715         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
55716         val_conv = PositiveTimestamp_clone(&val_conv);
55717         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
55718 }
55719
55720 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55721         LDKRawDataPart a_conv;
55722         a_conv.inner = untag_ptr(a);
55723         a_conv.is_owned = ptr_is_owned(a);
55724         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55725         a_conv.is_owned = false;
55726         LDKRawDataPart b_conv;
55727         b_conv.inner = untag_ptr(b);
55728         b_conv.is_owned = ptr_is_owned(b);
55729         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55730         b_conv.is_owned = false;
55731         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
55732         return ret_conv;
55733 }
55734
55735 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
55736         LDKRawDataPart ret_var = RawDataPart_clone(arg);
55737         int64_t ret_ref = 0;
55738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55740         return ret_ref;
55741 }
55742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55743         LDKRawDataPart arg_conv;
55744         arg_conv.inner = untag_ptr(arg);
55745         arg_conv.is_owned = ptr_is_owned(arg);
55746         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55747         arg_conv.is_owned = false;
55748         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
55749         return ret_conv;
55750 }
55751
55752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55753         LDKRawDataPart orig_conv;
55754         orig_conv.inner = untag_ptr(orig);
55755         orig_conv.is_owned = ptr_is_owned(orig);
55756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55757         orig_conv.is_owned = false;
55758         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
55759         int64_t ret_ref = 0;
55760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55762         return ret_ref;
55763 }
55764
55765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1hash(JNIEnv *env, jclass clz, int64_t o) {
55766         LDKRawDataPart o_conv;
55767         o_conv.inner = untag_ptr(o);
55768         o_conv.is_owned = ptr_is_owned(o);
55769         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55770         o_conv.is_owned = false;
55771         int64_t ret_conv = RawDataPart_hash(&o_conv);
55772         return ret_conv;
55773 }
55774
55775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55776         LDKPositiveTimestamp this_obj_conv;
55777         this_obj_conv.inner = untag_ptr(this_obj);
55778         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55780         PositiveTimestamp_free(this_obj_conv);
55781 }
55782
55783 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55784         LDKPositiveTimestamp a_conv;
55785         a_conv.inner = untag_ptr(a);
55786         a_conv.is_owned = ptr_is_owned(a);
55787         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55788         a_conv.is_owned = false;
55789         LDKPositiveTimestamp b_conv;
55790         b_conv.inner = untag_ptr(b);
55791         b_conv.is_owned = ptr_is_owned(b);
55792         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55793         b_conv.is_owned = false;
55794         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
55795         return ret_conv;
55796 }
55797
55798 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
55799         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
55800         int64_t ret_ref = 0;
55801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55802         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55803         return ret_ref;
55804 }
55805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55806         LDKPositiveTimestamp arg_conv;
55807         arg_conv.inner = untag_ptr(arg);
55808         arg_conv.is_owned = ptr_is_owned(arg);
55809         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55810         arg_conv.is_owned = false;
55811         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
55812         return ret_conv;
55813 }
55814
55815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55816         LDKPositiveTimestamp orig_conv;
55817         orig_conv.inner = untag_ptr(orig);
55818         orig_conv.is_owned = ptr_is_owned(orig);
55819         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55820         orig_conv.is_owned = false;
55821         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
55822         int64_t ret_ref = 0;
55823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55824         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55825         return ret_ref;
55826 }
55827
55828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1hash(JNIEnv *env, jclass clz, int64_t o) {
55829         LDKPositiveTimestamp o_conv;
55830         o_conv.inner = untag_ptr(o);
55831         o_conv.is_owned = ptr_is_owned(o);
55832         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55833         o_conv.is_owned = false;
55834         int64_t ret_conv = PositiveTimestamp_hash(&o_conv);
55835         return ret_conv;
55836 }
55837
55838 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55839         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
55840         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
55841         return ret_conv;
55842 }
55843
55844 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
55845         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
55846         return ret_conv;
55847 }
55848
55849 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
55850         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
55851         return ret_conv;
55852 }
55853
55854 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
55855         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
55856         return ret_conv;
55857 }
55858
55859 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
55860         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
55861         return ret_conv;
55862 }
55863
55864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55865         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
55866         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
55867         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
55868         return ret_conv;
55869 }
55870
55871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1hash(JNIEnv *env, jclass clz, int64_t o) {
55872         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
55873         int64_t ret_conv = SiPrefix_hash(o_conv);
55874         return ret_conv;
55875 }
55876
55877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
55878         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
55879         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
55880         return ret_conv;
55881 }
55882
55883 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55884         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
55885         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
55886         return ret_conv;
55887 }
55888
55889 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
55890         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
55891         return ret_conv;
55892 }
55893
55894 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
55895         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
55896         return ret_conv;
55897 }
55898
55899 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
55900         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
55901         return ret_conv;
55902 }
55903
55904 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
55905         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
55906         return ret_conv;
55907 }
55908
55909 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
55910         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
55911         return ret_conv;
55912 }
55913
55914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
55915         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
55916         int64_t ret_conv = Currency_hash(o_conv);
55917         return ret_conv;
55918 }
55919
55920 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55921         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
55922         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
55923         jboolean ret_conv = Currency_eq(a_conv, b_conv);
55924         return ret_conv;
55925 }
55926
55927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
55928         LDKSha256 this_obj_conv;
55929         this_obj_conv.inner = untag_ptr(this_obj);
55930         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55932         Sha256_free(this_obj_conv);
55933 }
55934
55935 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
55936         LDKSha256 ret_var = Sha256_clone(arg);
55937         int64_t ret_ref = 0;
55938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55939         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55940         return ret_ref;
55941 }
55942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
55943         LDKSha256 arg_conv;
55944         arg_conv.inner = untag_ptr(arg);
55945         arg_conv.is_owned = ptr_is_owned(arg);
55946         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55947         arg_conv.is_owned = false;
55948         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
55949         return ret_conv;
55950 }
55951
55952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
55953         LDKSha256 orig_conv;
55954         orig_conv.inner = untag_ptr(orig);
55955         orig_conv.is_owned = ptr_is_owned(orig);
55956         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55957         orig_conv.is_owned = false;
55958         LDKSha256 ret_var = Sha256_clone(&orig_conv);
55959         int64_t ret_ref = 0;
55960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55961         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55962         return ret_ref;
55963 }
55964
55965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
55966         LDKSha256 o_conv;
55967         o_conv.inner = untag_ptr(o);
55968         o_conv.is_owned = ptr_is_owned(o);
55969         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
55970         o_conv.is_owned = false;
55971         int64_t ret_conv = Sha256_hash(&o_conv);
55972         return ret_conv;
55973 }
55974
55975 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
55976         LDKSha256 a_conv;
55977         a_conv.inner = untag_ptr(a);
55978         a_conv.is_owned = ptr_is_owned(a);
55979         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
55980         a_conv.is_owned = false;
55981         LDKSha256 b_conv;
55982         b_conv.inner = untag_ptr(b);
55983         b_conv.is_owned = ptr_is_owned(b);
55984         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
55985         b_conv.is_owned = false;
55986         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
55987         return ret_conv;
55988 }
55989
55990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1from_1bytes(JNIEnv *env, jclass clz, int8_tArray bytes) {
55991         uint8_t bytes_arr[32];
55992         CHECK((*env)->GetArrayLength(env, bytes) == 32);
55993         (*env)->GetByteArrayRegion(env, bytes, 0, 32, bytes_arr);
55994         uint8_t (*bytes_ref)[32] = &bytes_arr;
55995         LDKSha256 ret_var = Sha256_from_bytes(bytes_ref);
55996         int64_t ret_ref = 0;
55997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55998         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55999         return ret_ref;
56000 }
56001
56002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56003         LDKDescription this_obj_conv;
56004         this_obj_conv.inner = untag_ptr(this_obj);
56005         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56007         Description_free(this_obj_conv);
56008 }
56009
56010 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
56011         LDKDescription ret_var = Description_clone(arg);
56012         int64_t ret_ref = 0;
56013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56014         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56015         return ret_ref;
56016 }
56017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56018         LDKDescription arg_conv;
56019         arg_conv.inner = untag_ptr(arg);
56020         arg_conv.is_owned = ptr_is_owned(arg);
56021         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56022         arg_conv.is_owned = false;
56023         int64_t ret_conv = Description_clone_ptr(&arg_conv);
56024         return ret_conv;
56025 }
56026
56027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56028         LDKDescription orig_conv;
56029         orig_conv.inner = untag_ptr(orig);
56030         orig_conv.is_owned = ptr_is_owned(orig);
56031         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56032         orig_conv.is_owned = false;
56033         LDKDescription ret_var = Description_clone(&orig_conv);
56034         int64_t ret_ref = 0;
56035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56036         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56037         return ret_ref;
56038 }
56039
56040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
56041         LDKDescription o_conv;
56042         o_conv.inner = untag_ptr(o);
56043         o_conv.is_owned = ptr_is_owned(o);
56044         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56045         o_conv.is_owned = false;
56046         int64_t ret_conv = Description_hash(&o_conv);
56047         return ret_conv;
56048 }
56049
56050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56051         LDKDescription a_conv;
56052         a_conv.inner = untag_ptr(a);
56053         a_conv.is_owned = ptr_is_owned(a);
56054         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56055         a_conv.is_owned = false;
56056         LDKDescription b_conv;
56057         b_conv.inner = untag_ptr(b);
56058         b_conv.is_owned = ptr_is_owned(b);
56059         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56060         b_conv.is_owned = false;
56061         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
56062         return ret_conv;
56063 }
56064
56065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56066         LDKPayeePubKey this_obj_conv;
56067         this_obj_conv.inner = untag_ptr(this_obj);
56068         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56070         PayeePubKey_free(this_obj_conv);
56071 }
56072
56073 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
56074         LDKPayeePubKey this_ptr_conv;
56075         this_ptr_conv.inner = untag_ptr(this_ptr);
56076         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56078         this_ptr_conv.is_owned = false;
56079         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
56080         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
56081         return ret_arr;
56082 }
56083
56084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
56085         LDKPayeePubKey this_ptr_conv;
56086         this_ptr_conv.inner = untag_ptr(this_ptr);
56087         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56089         this_ptr_conv.is_owned = false;
56090         LDKPublicKey val_ref;
56091         CHECK((*env)->GetArrayLength(env, val) == 33);
56092         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
56093         PayeePubKey_set_a(&this_ptr_conv, val_ref);
56094 }
56095
56096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
56097         LDKPublicKey a_arg_ref;
56098         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
56099         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
56100         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
56101         int64_t ret_ref = 0;
56102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56103         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56104         return ret_ref;
56105 }
56106
56107 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
56108         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
56109         int64_t ret_ref = 0;
56110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56111         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56112         return ret_ref;
56113 }
56114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56115         LDKPayeePubKey arg_conv;
56116         arg_conv.inner = untag_ptr(arg);
56117         arg_conv.is_owned = ptr_is_owned(arg);
56118         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56119         arg_conv.is_owned = false;
56120         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
56121         return ret_conv;
56122 }
56123
56124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56125         LDKPayeePubKey orig_conv;
56126         orig_conv.inner = untag_ptr(orig);
56127         orig_conv.is_owned = ptr_is_owned(orig);
56128         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56129         orig_conv.is_owned = false;
56130         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
56131         int64_t ret_ref = 0;
56132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56133         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56134         return ret_ref;
56135 }
56136
56137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
56138         LDKPayeePubKey o_conv;
56139         o_conv.inner = untag_ptr(o);
56140         o_conv.is_owned = ptr_is_owned(o);
56141         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56142         o_conv.is_owned = false;
56143         int64_t ret_conv = PayeePubKey_hash(&o_conv);
56144         return ret_conv;
56145 }
56146
56147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56148         LDKPayeePubKey a_conv;
56149         a_conv.inner = untag_ptr(a);
56150         a_conv.is_owned = ptr_is_owned(a);
56151         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56152         a_conv.is_owned = false;
56153         LDKPayeePubKey b_conv;
56154         b_conv.inner = untag_ptr(b);
56155         b_conv.is_owned = ptr_is_owned(b);
56156         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56157         b_conv.is_owned = false;
56158         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
56159         return ret_conv;
56160 }
56161
56162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56163         LDKExpiryTime this_obj_conv;
56164         this_obj_conv.inner = untag_ptr(this_obj);
56165         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56167         ExpiryTime_free(this_obj_conv);
56168 }
56169
56170 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
56171         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
56172         int64_t ret_ref = 0;
56173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56174         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56175         return ret_ref;
56176 }
56177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56178         LDKExpiryTime arg_conv;
56179         arg_conv.inner = untag_ptr(arg);
56180         arg_conv.is_owned = ptr_is_owned(arg);
56181         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56182         arg_conv.is_owned = false;
56183         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
56184         return ret_conv;
56185 }
56186
56187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56188         LDKExpiryTime orig_conv;
56189         orig_conv.inner = untag_ptr(orig);
56190         orig_conv.is_owned = ptr_is_owned(orig);
56191         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56192         orig_conv.is_owned = false;
56193         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
56194         int64_t ret_ref = 0;
56195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56197         return ret_ref;
56198 }
56199
56200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
56201         LDKExpiryTime o_conv;
56202         o_conv.inner = untag_ptr(o);
56203         o_conv.is_owned = ptr_is_owned(o);
56204         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56205         o_conv.is_owned = false;
56206         int64_t ret_conv = ExpiryTime_hash(&o_conv);
56207         return ret_conv;
56208 }
56209
56210 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56211         LDKExpiryTime a_conv;
56212         a_conv.inner = untag_ptr(a);
56213         a_conv.is_owned = ptr_is_owned(a);
56214         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56215         a_conv.is_owned = false;
56216         LDKExpiryTime b_conv;
56217         b_conv.inner = untag_ptr(b);
56218         b_conv.is_owned = ptr_is_owned(b);
56219         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56220         b_conv.is_owned = false;
56221         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
56222         return ret_conv;
56223 }
56224
56225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56226         LDKMinFinalCltvExpiryDelta this_obj_conv;
56227         this_obj_conv.inner = untag_ptr(this_obj);
56228         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56230         MinFinalCltvExpiryDelta_free(this_obj_conv);
56231 }
56232
56233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
56234         LDKMinFinalCltvExpiryDelta this_ptr_conv;
56235         this_ptr_conv.inner = untag_ptr(this_ptr);
56236         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56238         this_ptr_conv.is_owned = false;
56239         int64_t ret_conv = MinFinalCltvExpiryDelta_get_a(&this_ptr_conv);
56240         return ret_conv;
56241 }
56242
56243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
56244         LDKMinFinalCltvExpiryDelta this_ptr_conv;
56245         this_ptr_conv.inner = untag_ptr(this_ptr);
56246         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56248         this_ptr_conv.is_owned = false;
56249         MinFinalCltvExpiryDelta_set_a(&this_ptr_conv, val);
56250 }
56251
56252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
56253         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_new(a_arg);
56254         int64_t ret_ref = 0;
56255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56256         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56257         return ret_ref;
56258 }
56259
56260 static inline uint64_t MinFinalCltvExpiryDelta_clone_ptr(LDKMinFinalCltvExpiryDelta *NONNULL_PTR arg) {
56261         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(arg);
56262         int64_t ret_ref = 0;
56263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56264         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56265         return ret_ref;
56266 }
56267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56268         LDKMinFinalCltvExpiryDelta arg_conv;
56269         arg_conv.inner = untag_ptr(arg);
56270         arg_conv.is_owned = ptr_is_owned(arg);
56271         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56272         arg_conv.is_owned = false;
56273         int64_t ret_conv = MinFinalCltvExpiryDelta_clone_ptr(&arg_conv);
56274         return ret_conv;
56275 }
56276
56277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56278         LDKMinFinalCltvExpiryDelta orig_conv;
56279         orig_conv.inner = untag_ptr(orig);
56280         orig_conv.is_owned = ptr_is_owned(orig);
56281         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56282         orig_conv.is_owned = false;
56283         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(&orig_conv);
56284         int64_t ret_ref = 0;
56285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56286         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56287         return ret_ref;
56288 }
56289
56290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1hash(JNIEnv *env, jclass clz, int64_t o) {
56291         LDKMinFinalCltvExpiryDelta o_conv;
56292         o_conv.inner = untag_ptr(o);
56293         o_conv.is_owned = ptr_is_owned(o);
56294         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56295         o_conv.is_owned = false;
56296         int64_t ret_conv = MinFinalCltvExpiryDelta_hash(&o_conv);
56297         return ret_conv;
56298 }
56299
56300 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiryDelta_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56301         LDKMinFinalCltvExpiryDelta a_conv;
56302         a_conv.inner = untag_ptr(a);
56303         a_conv.is_owned = ptr_is_owned(a);
56304         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56305         a_conv.is_owned = false;
56306         LDKMinFinalCltvExpiryDelta b_conv;
56307         b_conv.inner = untag_ptr(b);
56308         b_conv.is_owned = ptr_is_owned(b);
56309         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56310         b_conv.is_owned = false;
56311         jboolean ret_conv = MinFinalCltvExpiryDelta_eq(&a_conv, &b_conv);
56312         return ret_conv;
56313 }
56314
56315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
56316         if (!ptr_is_owned(this_ptr)) return;
56317         void* this_ptr_ptr = untag_ptr(this_ptr);
56318         CHECK_ACCESS(this_ptr_ptr);
56319         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
56320         FREE(untag_ptr(this_ptr));
56321         Fallback_free(this_ptr_conv);
56322 }
56323
56324 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
56325         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56326         *ret_copy = Fallback_clone(arg);
56327         int64_t ret_ref = tag_ptr(ret_copy, true);
56328         return ret_ref;
56329 }
56330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56331         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
56332         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
56333         return ret_conv;
56334 }
56335
56336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56337         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
56338         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56339         *ret_copy = Fallback_clone(orig_conv);
56340         int64_t ret_ref = tag_ptr(ret_copy, true);
56341         return ret_ref;
56342 }
56343
56344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
56345         
56346         LDKCVec_u8Z program_ref;
56347         program_ref.datalen = (*env)->GetArrayLength(env, program);
56348         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
56349         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
56350         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56351         *ret_copy = Fallback_seg_wit_program((LDKWitnessVersion){ ._0 = version }, program_ref);
56352         int64_t ret_ref = tag_ptr(ret_copy, true);
56353         return ret_ref;
56354 }
56355
56356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
56357         LDKTwentyBytes a_ref;
56358         CHECK((*env)->GetArrayLength(env, a) == 20);
56359         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
56360         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56361         *ret_copy = Fallback_pub_key_hash(a_ref);
56362         int64_t ret_ref = tag_ptr(ret_copy, true);
56363         return ret_ref;
56364 }
56365
56366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
56367         LDKTwentyBytes a_ref;
56368         CHECK((*env)->GetArrayLength(env, a) == 20);
56369         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
56370         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
56371         *ret_copy = Fallback_script_hash(a_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_1hash(JNIEnv *env, jclass clz, int64_t o) {
56377         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
56378         int64_t ret_conv = Fallback_hash(o_conv);
56379         return ret_conv;
56380 }
56381
56382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56383         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
56384         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
56385         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
56386         return ret_conv;
56387 }
56388
56389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56390         LDKInvoiceSignature this_obj_conv;
56391         this_obj_conv.inner = untag_ptr(this_obj);
56392         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56394         InvoiceSignature_free(this_obj_conv);
56395 }
56396
56397 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
56398         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
56399         int64_t ret_ref = 0;
56400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56401         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56402         return ret_ref;
56403 }
56404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56405         LDKInvoiceSignature arg_conv;
56406         arg_conv.inner = untag_ptr(arg);
56407         arg_conv.is_owned = ptr_is_owned(arg);
56408         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56409         arg_conv.is_owned = false;
56410         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
56411         return ret_conv;
56412 }
56413
56414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56415         LDKInvoiceSignature orig_conv;
56416         orig_conv.inner = untag_ptr(orig);
56417         orig_conv.is_owned = ptr_is_owned(orig);
56418         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56419         orig_conv.is_owned = false;
56420         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
56421         int64_t ret_ref = 0;
56422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56423         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56424         return ret_ref;
56425 }
56426
56427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1hash(JNIEnv *env, jclass clz, int64_t o) {
56428         LDKInvoiceSignature o_conv;
56429         o_conv.inner = untag_ptr(o);
56430         o_conv.is_owned = ptr_is_owned(o);
56431         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56432         o_conv.is_owned = false;
56433         int64_t ret_conv = InvoiceSignature_hash(&o_conv);
56434         return ret_conv;
56435 }
56436
56437 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56438         LDKInvoiceSignature a_conv;
56439         a_conv.inner = untag_ptr(a);
56440         a_conv.is_owned = ptr_is_owned(a);
56441         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56442         a_conv.is_owned = false;
56443         LDKInvoiceSignature b_conv;
56444         b_conv.inner = untag_ptr(b);
56445         b_conv.is_owned = ptr_is_owned(b);
56446         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56447         b_conv.is_owned = false;
56448         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
56449         return ret_conv;
56450 }
56451
56452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
56453         LDKPrivateRoute this_obj_conv;
56454         this_obj_conv.inner = untag_ptr(this_obj);
56455         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56457         PrivateRoute_free(this_obj_conv);
56458 }
56459
56460 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
56461         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
56462         int64_t ret_ref = 0;
56463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56464         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56465         return ret_ref;
56466 }
56467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
56468         LDKPrivateRoute arg_conv;
56469         arg_conv.inner = untag_ptr(arg);
56470         arg_conv.is_owned = ptr_is_owned(arg);
56471         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56472         arg_conv.is_owned = false;
56473         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
56474         return ret_conv;
56475 }
56476
56477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
56478         LDKPrivateRoute orig_conv;
56479         orig_conv.inner = untag_ptr(orig);
56480         orig_conv.is_owned = ptr_is_owned(orig);
56481         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56482         orig_conv.is_owned = false;
56483         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
56484         int64_t ret_ref = 0;
56485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56486         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56487         return ret_ref;
56488 }
56489
56490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
56491         LDKPrivateRoute o_conv;
56492         o_conv.inner = untag_ptr(o);
56493         o_conv.is_owned = ptr_is_owned(o);
56494         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56495         o_conv.is_owned = false;
56496         int64_t ret_conv = PrivateRoute_hash(&o_conv);
56497         return ret_conv;
56498 }
56499
56500 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
56501         LDKPrivateRoute a_conv;
56502         a_conv.inner = untag_ptr(a);
56503         a_conv.is_owned = ptr_is_owned(a);
56504         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56505         a_conv.is_owned = false;
56506         LDKPrivateRoute b_conv;
56507         b_conv.inner = untag_ptr(b);
56508         b_conv.is_owned = ptr_is_owned(b);
56509         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
56510         b_conv.is_owned = false;
56511         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
56512         return ret_conv;
56513 }
56514
56515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
56516         LDKSignedRawInvoice this_arg_conv;
56517         this_arg_conv.inner = untag_ptr(this_arg);
56518         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56520         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
56521         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
56522         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
56523         return tag_ptr(ret_conv, true);
56524 }
56525
56526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
56527         LDKSignedRawInvoice this_arg_conv;
56528         this_arg_conv.inner = untag_ptr(this_arg);
56529         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56531         this_arg_conv.is_owned = false;
56532         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
56533         int64_t ret_ref = 0;
56534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56535         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56536         return ret_ref;
56537 }
56538
56539 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56540         LDKSignedRawInvoice this_arg_conv;
56541         this_arg_conv.inner = untag_ptr(this_arg);
56542         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56544         this_arg_conv.is_owned = false;
56545         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56546         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_signable_hash(&this_arg_conv));
56547         return ret_arr;
56548 }
56549
56550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
56551         LDKSignedRawInvoice this_arg_conv;
56552         this_arg_conv.inner = untag_ptr(this_arg);
56553         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56555         this_arg_conv.is_owned = false;
56556         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
56557         int64_t ret_ref = 0;
56558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56559         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56560         return ret_ref;
56561 }
56562
56563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56564         LDKSignedRawInvoice this_arg_conv;
56565         this_arg_conv.inner = untag_ptr(this_arg);
56566         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56568         this_arg_conv.is_owned = false;
56569         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
56570         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
56571         return tag_ptr(ret_conv, true);
56572 }
56573
56574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
56575         LDKSignedRawInvoice this_arg_conv;
56576         this_arg_conv.inner = untag_ptr(this_arg);
56577         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56579         this_arg_conv.is_owned = false;
56580         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
56581         return ret_conv;
56582 }
56583
56584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56585         LDKRawInvoice this_arg_conv;
56586         this_arg_conv.inner = untag_ptr(this_arg);
56587         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56589         this_arg_conv.is_owned = false;
56590         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56591         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_signable_hash(&this_arg_conv).data);
56592         return ret_arr;
56593 }
56594
56595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56596         LDKRawInvoice this_arg_conv;
56597         this_arg_conv.inner = untag_ptr(this_arg);
56598         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56600         this_arg_conv.is_owned = false;
56601         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
56602         int64_t ret_ref = 0;
56603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56604         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56605         return ret_ref;
56606 }
56607
56608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
56609         LDKRawInvoice this_arg_conv;
56610         this_arg_conv.inner = untag_ptr(this_arg);
56611         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56613         this_arg_conv.is_owned = false;
56614         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
56615         int64_t ret_ref = 0;
56616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56617         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56618         return ret_ref;
56619 }
56620
56621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56622         LDKRawInvoice this_arg_conv;
56623         this_arg_conv.inner = untag_ptr(this_arg);
56624         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56626         this_arg_conv.is_owned = false;
56627         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
56628         int64_t ret_ref = 0;
56629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56631         return ret_ref;
56632 }
56633
56634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56635         LDKRawInvoice this_arg_conv;
56636         this_arg_conv.inner = untag_ptr(this_arg);
56637         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56639         this_arg_conv.is_owned = false;
56640         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
56641         int64_t ret_ref = 0;
56642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56643         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56644         return ret_ref;
56645 }
56646
56647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
56648         LDKRawInvoice this_arg_conv;
56649         this_arg_conv.inner = untag_ptr(this_arg);
56650         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56652         this_arg_conv.is_owned = false;
56653         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
56654         int64_t ret_ref = 0;
56655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56656         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56657         return ret_ref;
56658 }
56659
56660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_arg) {
56661         LDKRawInvoice this_arg_conv;
56662         this_arg_conv.inner = untag_ptr(this_arg);
56663         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56665         this_arg_conv.is_owned = false;
56666         LDKMinFinalCltvExpiryDelta ret_var = RawInvoice_min_final_cltv_expiry_delta(&this_arg_conv);
56667         int64_t ret_ref = 0;
56668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56669         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56670         return ret_ref;
56671 }
56672
56673 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
56674         LDKRawInvoice this_arg_conv;
56675         this_arg_conv.inner = untag_ptr(this_arg);
56676         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56678         this_arg_conv.is_owned = false;
56679         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56680         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
56681         return ret_arr;
56682 }
56683
56684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
56685         LDKRawInvoice this_arg_conv;
56686         this_arg_conv.inner = untag_ptr(this_arg);
56687         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56689         this_arg_conv.is_owned = false;
56690         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
56691         *ret_copy = RawInvoice_payment_metadata(&this_arg_conv);
56692         int64_t ret_ref = tag_ptr(ret_copy, true);
56693         return ret_ref;
56694 }
56695
56696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
56697         LDKRawInvoice this_arg_conv;
56698         this_arg_conv.inner = untag_ptr(this_arg);
56699         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56701         this_arg_conv.is_owned = false;
56702         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
56703         int64_t ret_ref = 0;
56704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56705         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56706         return ret_ref;
56707 }
56708
56709 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
56710         LDKRawInvoice this_arg_conv;
56711         this_arg_conv.inner = untag_ptr(this_arg);
56712         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56714         this_arg_conv.is_owned = false;
56715         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
56716         int64_tArray ret_arr = NULL;
56717         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
56718         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
56719         for (size_t o = 0; o < ret_var.datalen; o++) {
56720                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
56721                 int64_t ret_conv_14_ref = 0;
56722                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
56723                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
56724                 ret_arr_ptr[o] = ret_conv_14_ref;
56725         }
56726         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
56727         FREE(ret_var.data);
56728         return ret_arr;
56729 }
56730
56731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
56732         LDKRawInvoice this_arg_conv;
56733         this_arg_conv.inner = untag_ptr(this_arg);
56734         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56736         this_arg_conv.is_owned = false;
56737         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
56738         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
56739         int64_t ret_ref = tag_ptr(ret_copy, true);
56740         return ret_ref;
56741 }
56742
56743 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
56744         LDKRawInvoice this_arg_conv;
56745         this_arg_conv.inner = untag_ptr(this_arg);
56746         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56748         this_arg_conv.is_owned = false;
56749         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
56750         return ret_conv;
56751 }
56752
56753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
56754         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
56755         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
56756         return tag_ptr(ret_conv, true);
56757 }
56758
56759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
56760         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
56761         *ret_conv = PositiveTimestamp_from_system_time(time);
56762         return tag_ptr(ret_conv, true);
56763 }
56764
56765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
56766         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
56767         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
56768         return tag_ptr(ret_conv, true);
56769 }
56770
56771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
56772         LDKPositiveTimestamp this_arg_conv;
56773         this_arg_conv.inner = untag_ptr(this_arg);
56774         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56776         this_arg_conv.is_owned = false;
56777         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
56778         return ret_conv;
56779 }
56780
56781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
56782         LDKPositiveTimestamp this_arg_conv;
56783         this_arg_conv.inner = untag_ptr(this_arg);
56784         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56786         this_arg_conv.is_owned = false;
56787         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
56788         return ret_conv;
56789 }
56790
56791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(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_time(&this_arg_conv);
56798         return ret_conv;
56799 }
56800
56801 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
56802         LDKInvoice 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56808         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_signable_hash(&this_arg_conv).data);
56809         return ret_arr;
56810 }
56811
56812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
56813         LDKInvoice this_arg_conv;
56814         this_arg_conv.inner = untag_ptr(this_arg);
56815         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56817         this_arg_conv = Invoice_clone(&this_arg_conv);
56818         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
56819         int64_t ret_ref = 0;
56820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56821         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56822         return ret_ref;
56823 }
56824
56825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
56826         LDKInvoice this_arg_conv;
56827         this_arg_conv.inner = untag_ptr(this_arg);
56828         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56830         this_arg_conv.is_owned = false;
56831         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
56832         *ret_conv = Invoice_check_signature(&this_arg_conv);
56833         return tag_ptr(ret_conv, true);
56834 }
56835
56836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
56837         LDKSignedRawInvoice signed_invoice_conv;
56838         signed_invoice_conv.inner = untag_ptr(signed_invoice);
56839         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
56840         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
56841         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
56842         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
56843         *ret_conv = Invoice_from_signed(signed_invoice_conv);
56844         return tag_ptr(ret_conv, true);
56845 }
56846
56847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
56848         LDKInvoice this_arg_conv;
56849         this_arg_conv.inner = untag_ptr(this_arg);
56850         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56852         this_arg_conv.is_owned = false;
56853         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
56854         return ret_conv;
56855 }
56856
56857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
56858         LDKInvoice this_arg_conv;
56859         this_arg_conv.inner = untag_ptr(this_arg);
56860         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56862         this_arg_conv.is_owned = false;
56863         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
56864         return ret_conv;
56865 }
56866
56867 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56874         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
56875         return ret_arr;
56876 }
56877
56878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56879         LDKInvoice this_arg_conv;
56880         this_arg_conv.inner = untag_ptr(this_arg);
56881         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56883         this_arg_conv.is_owned = false;
56884         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
56885         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
56886         return ret_arr;
56887 }
56888
56889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
56890         LDKInvoice this_arg_conv;
56891         this_arg_conv.inner = untag_ptr(this_arg);
56892         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56894         this_arg_conv.is_owned = false;
56895         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
56896         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
56897         return ret_arr;
56898 }
56899
56900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1metadata(JNIEnv *env, jclass clz, int64_t this_arg) {
56901         LDKInvoice this_arg_conv;
56902         this_arg_conv.inner = untag_ptr(this_arg);
56903         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56905         this_arg_conv.is_owned = false;
56906         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
56907         *ret_copy = Invoice_payment_metadata(&this_arg_conv);
56908         int64_t ret_ref = tag_ptr(ret_copy, true);
56909         return ret_ref;
56910 }
56911
56912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
56913         LDKInvoice this_arg_conv;
56914         this_arg_conv.inner = untag_ptr(this_arg);
56915         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56917         this_arg_conv.is_owned = false;
56918         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
56919         int64_t ret_ref = 0;
56920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56921         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56922         return ret_ref;
56923 }
56924
56925 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
56926         LDKInvoice this_arg_conv;
56927         this_arg_conv.inner = untag_ptr(this_arg);
56928         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56930         this_arg_conv.is_owned = false;
56931         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
56932         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
56933         return ret_arr;
56934 }
56935
56936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expires_1at(JNIEnv *env, jclass clz, int64_t this_arg) {
56937         LDKInvoice this_arg_conv;
56938         this_arg_conv.inner = untag_ptr(this_arg);
56939         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56941         this_arg_conv.is_owned = false;
56942         LDKCOption_DurationZ *ret_copy = MALLOC(sizeof(LDKCOption_DurationZ), "LDKCOption_DurationZ");
56943         *ret_copy = Invoice_expires_at(&this_arg_conv);
56944         int64_t ret_ref = tag_ptr(ret_copy, true);
56945         return ret_ref;
56946 }
56947
56948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
56949         LDKInvoice this_arg_conv;
56950         this_arg_conv.inner = untag_ptr(this_arg);
56951         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56953         this_arg_conv.is_owned = false;
56954         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
56955         return ret_conv;
56956 }
56957
56958 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
56959         LDKInvoice this_arg_conv;
56960         this_arg_conv.inner = untag_ptr(this_arg);
56961         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56963         this_arg_conv.is_owned = false;
56964         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
56965         return ret_conv;
56966 }
56967
56968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1until_1expiry(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_duration_until_expiry(&this_arg_conv);
56975         return ret_conv;
56976 }
56977
56978 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) {
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         int64_t ret_conv = Invoice_expiration_remaining_from_epoch(&this_arg_conv, time);
56985         return ret_conv;
56986 }
56987
56988 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
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         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
56995         return ret_conv;
56996 }
56997
56998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_arg) {
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_min_final_cltv_expiry_delta(&this_arg_conv);
57005         return ret_conv;
57006 }
57007
57008 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Invoice_1fallback_1addresses(JNIEnv *env, jclass clz, int64_t this_arg) {
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         LDKCVec_AddressZ ret_var = Invoice_fallback_addresses(&this_arg_conv);
57015         jobjectArray ret_arr = NULL;
57016         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, String_clz, NULL);
57017         ;
57018         jstring *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
57019         for (size_t i = 0; i < ret_var.datalen; i++) {
57020                 LDKStr ret_conv_8_str = ret_var.data[i];
57021                 jstring ret_conv_8_conv = str_ref_to_java(env, ret_conv_8_str.chars, ret_conv_8_str.len);
57022                 Str_free(ret_conv_8_str);
57023                 ret_arr_ptr[i] = ret_conv_8_conv;
57024         }
57025         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
57026         FREE(ret_var.data);
57027         return ret_arr;
57028 }
57029
57030 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
57031         LDKInvoice this_arg_conv;
57032         this_arg_conv.inner = untag_ptr(this_arg);
57033         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57035         this_arg_conv.is_owned = false;
57036         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
57037         int64_tArray ret_arr = NULL;
57038         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
57039         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
57040         for (size_t o = 0; o < ret_var.datalen; o++) {
57041                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
57042                 int64_t ret_conv_14_ref = 0;
57043                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
57044                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
57045                 ret_arr_ptr[o] = ret_conv_14_ref;
57046         }
57047         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
57048         FREE(ret_var.data);
57049         return ret_arr;
57050 }
57051
57052 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
57053         LDKInvoice this_arg_conv;
57054         this_arg_conv.inner = untag_ptr(this_arg);
57055         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57057         this_arg_conv.is_owned = false;
57058         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
57059         int64_tArray ret_arr = NULL;
57060         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
57061         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
57062         for (size_t l = 0; l < ret_var.datalen; l++) {
57063                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
57064                 int64_t ret_conv_11_ref = 0;
57065                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
57066                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
57067                 ret_arr_ptr[l] = ret_conv_11_ref;
57068         }
57069         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
57070         FREE(ret_var.data);
57071         return ret_arr;
57072 }
57073
57074 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
57075         LDKInvoice this_arg_conv;
57076         this_arg_conv.inner = untag_ptr(this_arg);
57077         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57079         this_arg_conv.is_owned = false;
57080         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
57081         return ret_conv;
57082 }
57083
57084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
57085         LDKInvoice this_arg_conv;
57086         this_arg_conv.inner = untag_ptr(this_arg);
57087         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57089         this_arg_conv.is_owned = false;
57090         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
57091         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
57092         int64_t ret_ref = tag_ptr(ret_copy, true);
57093         return ret_ref;
57094 }
57095
57096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
57097         LDKStr description_conv = java_to_owned_str(env, description);
57098         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
57099         *ret_conv = Description_new(description_conv);
57100         return tag_ptr(ret_conv, true);
57101 }
57102
57103 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
57104         LDKDescription this_arg_conv;
57105         this_arg_conv.inner = untag_ptr(this_arg);
57106         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57108         this_arg_conv = Description_clone(&this_arg_conv);
57109         LDKStr ret_str = Description_into_inner(this_arg_conv);
57110         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57111         Str_free(ret_str);
57112         return ret_conv;
57113 }
57114
57115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
57116         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
57117         int64_t ret_ref = 0;
57118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57119         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57120         return ret_ref;
57121 }
57122
57123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
57124         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
57125         int64_t ret_ref = 0;
57126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57127         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57128         return ret_ref;
57129 }
57130
57131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
57132         LDKExpiryTime this_arg_conv;
57133         this_arg_conv.inner = untag_ptr(this_arg);
57134         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57136         this_arg_conv.is_owned = false;
57137         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
57138         return ret_conv;
57139 }
57140
57141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
57142         LDKExpiryTime this_arg_conv;
57143         this_arg_conv.inner = untag_ptr(this_arg);
57144         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57146         this_arg_conv.is_owned = false;
57147         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
57148         return ret_conv;
57149 }
57150
57151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
57152         LDKRouteHint hops_conv;
57153         hops_conv.inner = untag_ptr(hops);
57154         hops_conv.is_owned = ptr_is_owned(hops);
57155         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
57156         hops_conv = RouteHint_clone(&hops_conv);
57157         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
57158         *ret_conv = PrivateRoute_new(hops_conv);
57159         return tag_ptr(ret_conv, true);
57160 }
57161
57162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
57163         LDKPrivateRoute this_arg_conv;
57164         this_arg_conv.inner = untag_ptr(this_arg);
57165         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57167         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
57168         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
57169         int64_t ret_ref = 0;
57170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57171         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57172         return ret_ref;
57173 }
57174
57175 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57176         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
57177         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
57178         return ret_conv;
57179 }
57180
57181 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
57182         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
57183         return ret_conv;
57184 }
57185
57186 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
57187         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
57188         return ret_conv;
57189 }
57190
57191 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
57192         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
57193         return ret_conv;
57194 }
57195
57196 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
57197         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
57198         return ret_conv;
57199 }
57200
57201 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
57202         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
57203         return ret_conv;
57204 }
57205
57206 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1min_1final_1cltv_1expiry_1delta_1too_1short(JNIEnv *env, jclass clz) {
57207         jclass ret_conv = LDKCreationError_to_java(env, CreationError_min_final_cltv_expiry_delta_too_short());
57208         return ret_conv;
57209 }
57210
57211 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
57212         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
57213         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
57214         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
57215         return ret_conv;
57216 }
57217
57218 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57219         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
57220         LDKStr ret_str = CreationError_to_str(o_conv);
57221         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57222         Str_free(ret_str);
57223         return ret_conv;
57224 }
57225
57226 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57227         LDKSemanticError* orig_conv = (LDKSemanticError*)untag_ptr(orig);
57228         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
57229         return ret_conv;
57230 }
57231
57232 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
57233         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
57234         return ret_conv;
57235 }
57236
57237 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
57238         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
57239         return ret_conv;
57240 }
57241
57242 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
57243         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
57244         return ret_conv;
57245 }
57246
57247 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
57248         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
57249         return ret_conv;
57250 }
57251
57252 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
57253         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
57254         return ret_conv;
57255 }
57256
57257 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
57258         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
57259         return ret_conv;
57260 }
57261
57262 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
57263         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
57264         return ret_conv;
57265 }
57266
57267 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
57268         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
57269         return ret_conv;
57270 }
57271
57272 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
57273         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
57274         return ret_conv;
57275 }
57276
57277 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
57278         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
57279         return ret_conv;
57280 }
57281
57282 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
57283         LDKSemanticError* a_conv = (LDKSemanticError*)untag_ptr(a);
57284         LDKSemanticError* b_conv = (LDKSemanticError*)untag_ptr(b);
57285         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
57286         return ret_conv;
57287 }
57288
57289 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57290         LDKSemanticError* o_conv = (LDKSemanticError*)untag_ptr(o);
57291         LDKStr ret_str = SemanticError_to_str(o_conv);
57292         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57293         Str_free(ret_str);
57294         return ret_conv;
57295 }
57296
57297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
57298         if (!ptr_is_owned(this_ptr)) return;
57299         void* this_ptr_ptr = untag_ptr(this_ptr);
57300         CHECK_ACCESS(this_ptr_ptr);
57301         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
57302         FREE(untag_ptr(this_ptr));
57303         SignOrCreationError_free(this_ptr_conv);
57304 }
57305
57306 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
57307         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57308         *ret_copy = SignOrCreationError_clone(arg);
57309         int64_t ret_ref = tag_ptr(ret_copy, true);
57310         return ret_ref;
57311 }
57312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
57313         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
57314         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
57315         return ret_conv;
57316 }
57317
57318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57319         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
57320         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57321         *ret_copy = SignOrCreationError_clone(orig_conv);
57322         int64_t ret_ref = tag_ptr(ret_copy, true);
57323         return ret_ref;
57324 }
57325
57326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
57327         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57328         *ret_copy = SignOrCreationError_sign_error();
57329         int64_t ret_ref = tag_ptr(ret_copy, true);
57330         return ret_ref;
57331 }
57332
57333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
57334         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
57335         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
57336         *ret_copy = SignOrCreationError_creation_error(a_conv);
57337         int64_t ret_ref = tag_ptr(ret_copy, true);
57338         return ret_ref;
57339 }
57340
57341 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
57342         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
57343         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
57344         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
57345         return ret_conv;
57346 }
57347
57348 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57349         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
57350         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
57351         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57352         Str_free(ret_str);
57353         return ret_conv;
57354 }
57355
57356 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) {
57357         LDKInvoice invoice_conv;
57358         invoice_conv.inner = untag_ptr(invoice);
57359         invoice_conv.is_owned = ptr_is_owned(invoice);
57360         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
57361         invoice_conv.is_owned = false;
57362         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57363         CHECK_ACCESS(retry_strategy_ptr);
57364         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57365         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57366         LDKChannelManager channelmanager_conv;
57367         channelmanager_conv.inner = untag_ptr(channelmanager);
57368         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57369         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57370         channelmanager_conv.is_owned = false;
57371         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
57372         *ret_conv = pay_invoice(&invoice_conv, retry_strategy_conv, &channelmanager_conv);
57373         return tag_ptr(ret_conv, true);
57374 }
57375
57376 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) {
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         LDKThirtyTwoBytes payment_id_ref;
57383         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
57384         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
57385         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57386         CHECK_ACCESS(retry_strategy_ptr);
57387         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57388         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57389         LDKChannelManager channelmanager_conv;
57390         channelmanager_conv.inner = untag_ptr(channelmanager);
57391         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57392         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57393         channelmanager_conv.is_owned = false;
57394         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
57395         *ret_conv = pay_invoice_with_id(&invoice_conv, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
57396         return tag_ptr(ret_conv, true);
57397 }
57398
57399 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) {
57400         LDKInvoice invoice_conv;
57401         invoice_conv.inner = untag_ptr(invoice);
57402         invoice_conv.is_owned = ptr_is_owned(invoice);
57403         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
57404         invoice_conv.is_owned = false;
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_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
57415         *ret_conv = pay_zero_value_invoice(&invoice_conv, amount_msats, 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_1with_1id(JNIEnv *env, jclass clz, int64_t invoice, int64_t amount_msats, int8_tArray payment_id, 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         LDKThirtyTwoBytes payment_id_ref;
57426         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
57427         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
57428         void* retry_strategy_ptr = untag_ptr(retry_strategy);
57429         CHECK_ACCESS(retry_strategy_ptr);
57430         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
57431         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
57432         LDKChannelManager channelmanager_conv;
57433         channelmanager_conv.inner = untag_ptr(channelmanager);
57434         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57435         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57436         channelmanager_conv.is_owned = false;
57437         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
57438         *ret_conv = pay_zero_value_invoice_with_id(&invoice_conv, amount_msats, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
57439         return tag_ptr(ret_conv, true);
57440 }
57441
57442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
57443         if (!ptr_is_owned(this_ptr)) return;
57444         void* this_ptr_ptr = untag_ptr(this_ptr);
57445         CHECK_ACCESS(this_ptr_ptr);
57446         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
57447         FREE(untag_ptr(this_ptr));
57448         PaymentError_free(this_ptr_conv);
57449 }
57450
57451 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
57452         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57453         *ret_copy = PaymentError_clone(arg);
57454         int64_t ret_ref = tag_ptr(ret_copy, true);
57455         return ret_ref;
57456 }
57457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
57458         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
57459         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
57460         return ret_conv;
57461 }
57462
57463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57464         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
57465         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57466         *ret_copy = PaymentError_clone(orig_conv);
57467         int64_t ret_ref = tag_ptr(ret_copy, true);
57468         return ret_ref;
57469 }
57470
57471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
57472         LDKStr a_conv = java_to_owned_str(env, a);
57473         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57474         *ret_copy = PaymentError_invoice(a_conv);
57475         int64_t ret_ref = tag_ptr(ret_copy, true);
57476         return ret_ref;
57477 }
57478
57479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, jclass a) {
57480         LDKRetryableSendFailure a_conv = LDKRetryableSendFailure_from_java(env, a);
57481         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
57482         *ret_copy = PaymentError_sending(a_conv);
57483         int64_t ret_ref = tag_ptr(ret_copy, true);
57484         return ret_ref;
57485 }
57486
57487 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) {
57488         void* amt_msat_ptr = untag_ptr(amt_msat);
57489         CHECK_ACCESS(amt_msat_ptr);
57490         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57491         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57492         LDKThirtyTwoBytes payment_hash_ref;
57493         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
57494         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
57495         LDKStr description_conv = java_to_owned_str(env, description);
57496         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
57497         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
57498         if (phantom_route_hints_constr.datalen > 0)
57499                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
57500         else
57501                 phantom_route_hints_constr.data = NULL;
57502         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
57503         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
57504                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
57505                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
57506                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
57507                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
57508                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
57509                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
57510                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
57511         }
57512         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
57513         void* entropy_source_ptr = untag_ptr(entropy_source);
57514         CHECK_ACCESS(entropy_source_ptr);
57515         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
57516         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
57517                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57518                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
57519         }
57520         void* node_signer_ptr = untag_ptr(node_signer);
57521         CHECK_ACCESS(node_signer_ptr);
57522         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57523         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57524                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57525                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57526         }
57527         void* logger_ptr = untag_ptr(logger);
57528         CHECK_ACCESS(logger_ptr);
57529         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57530         if (logger_conv.free == LDKLogger_JCalls_free) {
57531                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57532                 LDKLogger_JCalls_cloned(&logger_conv);
57533         }
57534         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57535         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57536         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57537         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57538         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57539         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57540         *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);
57541         return tag_ptr(ret_conv, true);
57542 }
57543
57544 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) {
57545         void* amt_msat_ptr = untag_ptr(amt_msat);
57546         CHECK_ACCESS(amt_msat_ptr);
57547         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57548         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57549         LDKThirtyTwoBytes payment_hash_ref;
57550         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
57551         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
57552         LDKSha256 description_hash_conv;
57553         description_hash_conv.inner = untag_ptr(description_hash);
57554         description_hash_conv.is_owned = ptr_is_owned(description_hash);
57555         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
57556         description_hash_conv = Sha256_clone(&description_hash_conv);
57557         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
57558         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
57559         if (phantom_route_hints_constr.datalen > 0)
57560                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
57561         else
57562                 phantom_route_hints_constr.data = NULL;
57563         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
57564         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
57565                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
57566                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
57567                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
57568                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
57569                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
57570                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
57571                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
57572         }
57573         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
57574         void* entropy_source_ptr = untag_ptr(entropy_source);
57575         CHECK_ACCESS(entropy_source_ptr);
57576         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
57577         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
57578                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57579                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
57580         }
57581         void* node_signer_ptr = untag_ptr(node_signer);
57582         CHECK_ACCESS(node_signer_ptr);
57583         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57584         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57585                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57586                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57587         }
57588         void* logger_ptr = untag_ptr(logger);
57589         CHECK_ACCESS(logger_ptr);
57590         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57591         if (logger_conv.free == LDKLogger_JCalls_free) {
57592                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57593                 LDKLogger_JCalls_cloned(&logger_conv);
57594         }
57595         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57596         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57597         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57598         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57599         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57600         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57601         *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);
57602         return tag_ptr(ret_conv, true);
57603 }
57604
57605 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) {
57606         LDKChannelManager channelmanager_conv;
57607         channelmanager_conv.inner = untag_ptr(channelmanager);
57608         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57609         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57610         channelmanager_conv.is_owned = false;
57611         void* node_signer_ptr = untag_ptr(node_signer);
57612         CHECK_ACCESS(node_signer_ptr);
57613         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57614         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57615                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57616                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57617         }
57618         void* logger_ptr = untag_ptr(logger);
57619         CHECK_ACCESS(logger_ptr);
57620         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57621         if (logger_conv.free == LDKLogger_JCalls_free) {
57622                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57623                 LDKLogger_JCalls_cloned(&logger_conv);
57624         }
57625         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57626         void* amt_msat_ptr = untag_ptr(amt_msat);
57627         CHECK_ACCESS(amt_msat_ptr);
57628         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57629         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57630         LDKStr description_conv = java_to_owned_str(env, description);
57631         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57632         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57633         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57634         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57635         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57636         *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);
57637         return tag_ptr(ret_conv, true);
57638 }
57639
57640 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) {
57641         LDKChannelManager channelmanager_conv;
57642         channelmanager_conv.inner = untag_ptr(channelmanager);
57643         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57644         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57645         channelmanager_conv.is_owned = false;
57646         void* node_signer_ptr = untag_ptr(node_signer);
57647         CHECK_ACCESS(node_signer_ptr);
57648         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57649         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57650                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57651                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57652         }
57653         void* logger_ptr = untag_ptr(logger);
57654         CHECK_ACCESS(logger_ptr);
57655         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57656         if (logger_conv.free == LDKLogger_JCalls_free) {
57657                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57658                 LDKLogger_JCalls_cloned(&logger_conv);
57659         }
57660         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57661         void* amt_msat_ptr = untag_ptr(amt_msat);
57662         CHECK_ACCESS(amt_msat_ptr);
57663         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57664         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57665         LDKSha256 description_hash_conv;
57666         description_hash_conv.inner = untag_ptr(description_hash);
57667         description_hash_conv.is_owned = ptr_is_owned(description_hash);
57668         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
57669         description_hash_conv = Sha256_clone(&description_hash_conv);
57670         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57671         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57672         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57673         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57674         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57675         *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);
57676         return tag_ptr(ret_conv, true);
57677 }
57678
57679 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) {
57680         LDKChannelManager channelmanager_conv;
57681         channelmanager_conv.inner = untag_ptr(channelmanager);
57682         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57683         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57684         channelmanager_conv.is_owned = false;
57685         void* node_signer_ptr = untag_ptr(node_signer);
57686         CHECK_ACCESS(node_signer_ptr);
57687         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57688         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57689                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57690                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57691         }
57692         void* logger_ptr = untag_ptr(logger);
57693         CHECK_ACCESS(logger_ptr);
57694         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57695         if (logger_conv.free == LDKLogger_JCalls_free) {
57696                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57697                 LDKLogger_JCalls_cloned(&logger_conv);
57698         }
57699         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57700         void* amt_msat_ptr = untag_ptr(amt_msat);
57701         CHECK_ACCESS(amt_msat_ptr);
57702         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57703         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57704         LDKSha256 description_hash_conv;
57705         description_hash_conv.inner = untag_ptr(description_hash);
57706         description_hash_conv.is_owned = ptr_is_owned(description_hash);
57707         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
57708         description_hash_conv = Sha256_clone(&description_hash_conv);
57709         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57710         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57711         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57712         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57713         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57714         *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);
57715         return tag_ptr(ret_conv, true);
57716 }
57717
57718 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) {
57719         LDKChannelManager channelmanager_conv;
57720         channelmanager_conv.inner = untag_ptr(channelmanager);
57721         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57722         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57723         channelmanager_conv.is_owned = false;
57724         void* node_signer_ptr = untag_ptr(node_signer);
57725         CHECK_ACCESS(node_signer_ptr);
57726         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57727         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57728                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57729                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57730         }
57731         void* logger_ptr = untag_ptr(logger);
57732         CHECK_ACCESS(logger_ptr);
57733         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57734         if (logger_conv.free == LDKLogger_JCalls_free) {
57735                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57736                 LDKLogger_JCalls_cloned(&logger_conv);
57737         }
57738         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57739         void* amt_msat_ptr = untag_ptr(amt_msat);
57740         CHECK_ACCESS(amt_msat_ptr);
57741         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57742         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57743         LDKStr description_conv = java_to_owned_str(env, description);
57744         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57745         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57746         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57747         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57748         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57749         *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);
57750         return tag_ptr(ret_conv, true);
57751 }
57752
57753 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) {
57754         LDKChannelManager channelmanager_conv;
57755         channelmanager_conv.inner = untag_ptr(channelmanager);
57756         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
57757         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
57758         channelmanager_conv.is_owned = false;
57759         void* node_signer_ptr = untag_ptr(node_signer);
57760         CHECK_ACCESS(node_signer_ptr);
57761         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
57762         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
57763                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57764                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
57765         }
57766         void* logger_ptr = untag_ptr(logger);
57767         CHECK_ACCESS(logger_ptr);
57768         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57769         if (logger_conv.free == LDKLogger_JCalls_free) {
57770                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57771                 LDKLogger_JCalls_cloned(&logger_conv);
57772         }
57773         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
57774         void* amt_msat_ptr = untag_ptr(amt_msat);
57775         CHECK_ACCESS(amt_msat_ptr);
57776         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
57777         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
57778         LDKStr description_conv = java_to_owned_str(env, description);
57779         LDKThirtyTwoBytes payment_hash_ref;
57780         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
57781         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
57782         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
57783         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
57784         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
57785         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
57786         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
57787         *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);
57788         return tag_ptr(ret_conv, true);
57789 }
57790
57791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
57792         LDKStr s_conv = java_to_owned_str(env, s);
57793         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
57794         *ret_conv = SiPrefix_from_str(s_conv);
57795         return tag_ptr(ret_conv, true);
57796 }
57797
57798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
57799         LDKStr s_conv = java_to_owned_str(env, s);
57800         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
57801         *ret_conv = Invoice_from_str(s_conv);
57802         return tag_ptr(ret_conv, true);
57803 }
57804
57805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
57806         LDKStr s_conv = java_to_owned_str(env, s);
57807         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
57808         *ret_conv = SignedRawInvoice_from_str(s_conv);
57809         return tag_ptr(ret_conv, true);
57810 }
57811
57812 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57813         LDKParseError* o_conv = (LDKParseError*)untag_ptr(o);
57814         LDKStr ret_str = ParseError_to_str(o_conv);
57815         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57816         Str_free(ret_str);
57817         return ret_conv;
57818 }
57819
57820 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57821         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
57822         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
57823         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57824         Str_free(ret_str);
57825         return ret_conv;
57826 }
57827
57828 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57829         LDKInvoice o_conv;
57830         o_conv.inner = untag_ptr(o);
57831         o_conv.is_owned = ptr_is_owned(o);
57832         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
57833         o_conv.is_owned = false;
57834         LDKStr ret_str = Invoice_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_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57841         LDKSignedRawInvoice o_conv;
57842         o_conv.inner = untag_ptr(o);
57843         o_conv.is_owned = ptr_is_owned(o);
57844         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
57845         o_conv.is_owned = false;
57846         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
57847         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57848         Str_free(ret_str);
57849         return ret_conv;
57850 }
57851
57852 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57853         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
57854         LDKStr ret_str = Currency_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_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
57861         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
57862         LDKStr ret_str = SiPrefix_to_str(o_conv);
57863         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
57864         Str_free(ret_str);
57865         return ret_conv;
57866 }
57867
57868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
57869         LDKRapidGossipSync this_obj_conv;
57870         this_obj_conv.inner = untag_ptr(this_obj);
57871         this_obj_conv.is_owned = ptr_is_owned(this_obj);
57872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
57873         RapidGossipSync_free(this_obj_conv);
57874 }
57875
57876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
57877         LDKNetworkGraph network_graph_conv;
57878         network_graph_conv.inner = untag_ptr(network_graph);
57879         network_graph_conv.is_owned = ptr_is_owned(network_graph);
57880         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
57881         network_graph_conv.is_owned = false;
57882         void* logger_ptr = untag_ptr(logger);
57883         CHECK_ACCESS(logger_ptr);
57884         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
57885         if (logger_conv.free == LDKLogger_JCalls_free) {
57886                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
57887                 LDKLogger_JCalls_cloned(&logger_conv);
57888         }
57889         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv, logger_conv);
57890         int64_t ret_ref = 0;
57891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57892         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57893         return ret_ref;
57894 }
57895
57896 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) {
57897         LDKRapidGossipSync this_arg_conv;
57898         this_arg_conv.inner = untag_ptr(this_arg);
57899         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57901         this_arg_conv.is_owned = false;
57902         LDKu8slice update_data_ref;
57903         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
57904         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
57905         void* current_time_unix_ptr = untag_ptr(current_time_unix);
57906         CHECK_ACCESS(current_time_unix_ptr);
57907         LDKCOption_u64Z current_time_unix_conv = *(LDKCOption_u64Z*)(current_time_unix_ptr);
57908         current_time_unix_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(current_time_unix));
57909         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
57910         *ret_conv = RapidGossipSync_update_network_graph_no_std(&this_arg_conv, update_data_ref, current_time_unix_conv);
57911         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
57912         return tag_ptr(ret_conv, true);
57913 }
57914
57915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
57916         LDKRapidGossipSync this_arg_conv;
57917         this_arg_conv.inner = untag_ptr(this_arg);
57918         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57920         this_arg_conv.is_owned = false;
57921         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
57922         return ret_conv;
57923 }
57924
57925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
57926         if (!ptr_is_owned(this_ptr)) return;
57927         void* this_ptr_ptr = untag_ptr(this_ptr);
57928         CHECK_ACCESS(this_ptr_ptr);
57929         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
57930         FREE(untag_ptr(this_ptr));
57931         GraphSyncError_free(this_ptr_conv);
57932 }
57933
57934 static inline uint64_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
57935         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57936         *ret_copy = GraphSyncError_clone(arg);
57937         int64_t ret_ref = tag_ptr(ret_copy, true);
57938         return ret_ref;
57939 }
57940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
57941         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)untag_ptr(arg);
57942         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
57943         return ret_conv;
57944 }
57945
57946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
57947         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)untag_ptr(orig);
57948         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57949         *ret_copy = GraphSyncError_clone(orig_conv);
57950         int64_t ret_ref = tag_ptr(ret_copy, true);
57951         return ret_ref;
57952 }
57953
57954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
57955         void* a_ptr = untag_ptr(a);
57956         CHECK_ACCESS(a_ptr);
57957         LDKDecodeError a_conv = *(LDKDecodeError*)(a_ptr);
57958         a_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(a));
57959         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57960         *ret_copy = GraphSyncError_decode_error(a_conv);
57961         int64_t ret_ref = tag_ptr(ret_copy, true);
57962         return ret_ref;
57963 }
57964
57965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
57966         LDKLightningError a_conv;
57967         a_conv.inner = untag_ptr(a);
57968         a_conv.is_owned = ptr_is_owned(a);
57969         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
57970         a_conv = LightningError_clone(&a_conv);
57971         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
57972         *ret_copy = GraphSyncError_lightning_error(a_conv);
57973         int64_t ret_ref = tag_ptr(ret_copy, true);
57974         return ret_ref;
57975 }
57976